Commit 97c154c2 authored by valdi's avatar valdi

succes clear data

parent d125b466
{
"baseUrl" : "http://192.168.2.142:8000/"
}
\ No newline at end of file
import 'package:mqtt_client/mqtt_browser_client.dart'; import 'package:mqtt_client/mqtt_browser_client.dart';
const String apiUrlQueue = "http://192.168.2.142:8000/api/getqueue"; const String baseUrl = "http://192.168.2.142:8000/";
const String apiUrlUpdate = "http://192.168.2.142:8000/api/updatequeue"; const String apiUrlQueue = baseUrl + "api/getqueue";
const String apiUrlUpdate = baseUrl + "api/updatequeue";
const String apiUrlClear = baseUrl + "api/clearqueue";
const String mqttUrl = "ws://dev.ravku.com"; const String mqttUrl = "ws://dev.ravku.com";
const String queueTopic = "queuetest/1"; const String queueTopic = "queuetest/1";
const String queueMessage = "updateApi"; const String queueMessage = "updateApi";
......
...@@ -25,6 +25,7 @@ class _MainPageState extends State<MainPage> { ...@@ -25,6 +25,7 @@ class _MainPageState extends State<MainPage> {
List<String> queueSelected = []; List<String> queueSelected = [];
List<String> readySelected = []; List<String> readySelected = [];
List<String> pickUp = []; List<String> pickUp = [];
List clearData = [OrderQueue];
void setToReady(List queueSelected) async { void setToReady(List queueSelected) async {
var apiUrl = apiUrlUpdate; var apiUrl = apiUrlUpdate;
...@@ -98,6 +99,20 @@ class _MainPageState extends State<MainPage> { ...@@ -98,6 +99,20 @@ class _MainPageState extends State<MainPage> {
mqClient.publishMessage(pubTopic, MqttQos.exactlyOnce, builder.payload!); mqClient.publishMessage(pubTopic, MqttQos.exactlyOnce, builder.payload!);
} }
// ignore: non_constant_identifier_names
Future setToClear() async {
// print(readySelected);
var apiUrl = apiUrlClear;
var apiResult = await http.get(Uri.parse(apiUrl));
var jsonObject = jsonDecode(apiResult.body)['status'];
if (jsonObject == true) {
context.read<ReadyCubit>().getData();
context.read<QueueCubit>().getData();
} else {
print("gabisa");
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
context.read<QueueCubit>().getData(); context.read<QueueCubit>().getData();
...@@ -230,7 +245,7 @@ class _MainPageState extends State<MainPage> { ...@@ -230,7 +245,7 @@ class _MainPageState extends State<MainPage> {
setToReady(queueSelected); setToReady(queueSelected);
}, },
child: Container( child: Container(
width: 1000, width: 800,
height: 100, height: 100,
color: Colors.lightBlue, color: Colors.lightBlue,
alignment: Alignment.center, alignment: Alignment.center,
...@@ -253,25 +268,25 @@ class _MainPageState extends State<MainPage> { ...@@ -253,25 +268,25 @@ class _MainPageState extends State<MainPage> {
child: Container( child: Container(
color: Colors.blueGrey, color: Colors.blueGrey,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[ children: <Widget>[
Container( // Container(
width: 400, // width: 400,
height: 100, // height: 100,
margin: EdgeInsets.all(20), // margin: EdgeInsets.all(20),
decoration: BoxDecoration( // decoration: BoxDecoration(
borderRadius: BorderRadius.all( // borderRadius: BorderRadius.all(
Radius.circular(20), // Radius.circular(20),
), // ),
color: Colors.amber, // color: Colors.amber,
), // ),
alignment: Alignment.center, // alignment: Alignment.center,
child: Text( // child: Text(
"REFRESH", // "REFRESH",
style: TextStyle( // style: TextStyle(
fontSize: 30, fontWeight: FontWeight.w700), // fontSize: 30, fontWeight: FontWeight.w700),
), // ),
), // ),
InkWell( InkWell(
onTap: () { onTap: () {
print("clear"); print("clear");
...@@ -279,14 +294,15 @@ class _MainPageState extends State<MainPage> { ...@@ -279,14 +294,15 @@ class _MainPageState extends State<MainPage> {
context: context, context: context,
builder: (BuildContext context) => AlertDialog( builder: (BuildContext context) => AlertDialog(
title: Text("Clear"), title: Text("Clear"),
content: Text("Are you sure to clear?"), content: Text("Are you sure to clear data?"),
actions: <Widget>[ actions: <Widget>[
TextButton( TextButton(
onPressed: () => Navigator.pop(context), onPressed: () => Navigator.pop(context),
child: Text('Cancel'), child: Text('Cancel'),
), ),
TextButton( TextButton(
onPressed: () => Navigator.pop(context), onPressed: () =>
Navigator.pop(context, setToClear),
child: Text('OK'), child: Text('OK'),
), ),
], ],
...@@ -295,8 +311,8 @@ class _MainPageState extends State<MainPage> { ...@@ -295,8 +311,8 @@ class _MainPageState extends State<MainPage> {
}, },
child: Container( child: Container(
width: 400, width: 400,
height: 100, height: 80,
margin: EdgeInsets.all(20), margin: EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all( borderRadius: BorderRadius.all(
Radius.circular(20), Radius.circular(20),
......
...@@ -38,6 +38,7 @@ dependencies: ...@@ -38,6 +38,7 @@ dependencies:
shared_preferences: ^2.0.13 shared_preferences: ^2.0.13
uuid: ^3.0.6 uuid: ^3.0.6
dev_dependencies: dev_dependencies:
flutter_lints: ^1.0.0 flutter_lints: ^1.0.0
flutter_test: flutter_test:
...@@ -47,6 +48,8 @@ dev_dependencies: ...@@ -47,6 +48,8 @@ dev_dependencies:
# following page: https://dart.dev/tools/pub/pubspec # following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter. # The following section is specific to Flutter.
flutter: flutter:
# assets:
# - assets/baseurl.json
# The following line ensures that the Material Icons font is # The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in # included with your application, so that you can use the icons in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment