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';
const String apiUrlQueue = "http://192.168.2.142:8000/api/getqueue";
const String apiUrlUpdate = "http://192.168.2.142:8000/api/updatequeue";
const String baseUrl = "http://192.168.2.142:8000/";
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 queueTopic = "queuetest/1";
const String queueMessage = "updateApi";
......
......@@ -25,6 +25,7 @@ class _MainPageState extends State<MainPage> {
List<String> queueSelected = [];
List<String> readySelected = [];
List<String> pickUp = [];
List clearData = [OrderQueue];
void setToReady(List queueSelected) async {
var apiUrl = apiUrlUpdate;
......@@ -98,6 +99,20 @@ class _MainPageState extends State<MainPage> {
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
Widget build(BuildContext context) {
context.read<QueueCubit>().getData();
......@@ -230,7 +245,7 @@ class _MainPageState extends State<MainPage> {
setToReady(queueSelected);
},
child: Container(
width: 1000,
width: 800,
height: 100,
color: Colors.lightBlue,
alignment: Alignment.center,
......@@ -253,25 +268,25 @@ class _MainPageState extends State<MainPage> {
child: Container(
color: Colors.blueGrey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
width: 400,
height: 100,
margin: EdgeInsets.all(20),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(20),
),
color: Colors.amber,
),
alignment: Alignment.center,
child: Text(
"REFRESH",
style: TextStyle(
fontSize: 30, fontWeight: FontWeight.w700),
),
),
// Container(
// width: 400,
// height: 100,
// margin: EdgeInsets.all(20),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.all(
// Radius.circular(20),
// ),
// color: Colors.amber,
// ),
// alignment: Alignment.center,
// child: Text(
// "REFRESH",
// style: TextStyle(
// fontSize: 30, fontWeight: FontWeight.w700),
// ),
// ),
InkWell(
onTap: () {
print("clear");
......@@ -279,14 +294,15 @@ class _MainPageState extends State<MainPage> {
context: context,
builder: (BuildContext context) => AlertDialog(
title: Text("Clear"),
content: Text("Are you sure to clear?"),
content: Text("Are you sure to clear data?"),
actions: <Widget>[
TextButton(
onPressed: () => Navigator.pop(context),
child: Text('Cancel'),
),
TextButton(
onPressed: () => Navigator.pop(context),
onPressed: () =>
Navigator.pop(context, setToClear),
child: Text('OK'),
),
],
......@@ -295,8 +311,8 @@ class _MainPageState extends State<MainPage> {
},
child: Container(
width: 400,
height: 100,
margin: EdgeInsets.all(20),
height: 80,
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(20),
......
......@@ -38,6 +38,7 @@ dependencies:
shared_preferences: ^2.0.13
uuid: ^3.0.6
dev_dependencies:
flutter_lints: ^1.0.0
flutter_test:
......@@ -47,6 +48,8 @@ dev_dependencies:
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# assets:
# - assets/baseurl.json
# The following line ensures that the Material Icons font is
# 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