aa
This commit is contained in:
@@ -2,11 +2,14 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:queue_mgr/backend/DebugHelper.dart';
|
||||
// DateFormat dateFormat;
|
||||
|
||||
final String API_ENDPOINT= "https://vps.playpoolstudios.com/qms/api/";
|
||||
|
||||
DateFormat dateFormat = DateFormat("yyyy/MM/dd");
|
||||
DateFormat timeFormat = DateFormat("hh:mm a");
|
||||
DateFormat dateTimeFormat = DateFormat("yyyy/MM/dd hh:mm a");
|
||||
class DataManager{
|
||||
static _DataManager? m_instance = null;
|
||||
static _DataManager instance(){
|
||||
@@ -33,10 +36,9 @@ class _DataManager{
|
||||
}catch(e){
|
||||
Debug.LogError(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Future<void> AddService(String name, DateTime sTime, DateTime eTime,TimeOfDay duration) async {
|
||||
Future<void> AddService(String name, DateTime sTime, DateTime eTime,Duration duration) async {
|
||||
try{
|
||||
var response = (await http.post(
|
||||
Uri.parse('${API_ENDPOINT}add_service.php'),
|
||||
@@ -44,7 +46,7 @@ class _DataManager{
|
||||
'name':name,
|
||||
'stime':sTime.toString(),
|
||||
'etime':eTime.toString(),
|
||||
'duration':"${duration.hour}:${duration.minute}"
|
||||
'duration':"${duration.ToHoursAndMinutes()}"
|
||||
}));
|
||||
Debug.LogResponse(response.body.toString());
|
||||
services = jsonDecode(response.body.toString());
|
||||
@@ -53,4 +55,22 @@ class _DataManager{
|
||||
Debug.LogError(e);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String,dynamic> GetServiceById(String id){
|
||||
for (var service in services) {
|
||||
Map<String,dynamic> s = jsonDecode(service.toString());
|
||||
|
||||
if(s['id']==id){
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension DurationExtensions on Duration{
|
||||
String ToHoursAndMinutes(){
|
||||
return "${this.inHours}:${this.inMinutes}";
|
||||
}
|
||||
}
|
||||
113
lib/backend/Dialogs.dart
Normal file
113
lib/backend/Dialogs.dart
Normal file
@@ -0,0 +1,113 @@
|
||||
// import 'package:fhub/backend/login_mgr.dart';
|
||||
|
||||
import 'package:duration_picker/duration_picker.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:queue_mgr/backend/DebugHelper.dart';
|
||||
// import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
// import 'package:shared_preferences/shared_preferences.dart';
|
||||
// import 'package:url_launcher/url_launcher.dart';
|
||||
import '../main.dart';
|
||||
|
||||
class Dialogs{
|
||||
|
||||
static showAlertDialog(BuildContext context, String title, String message) {
|
||||
// set up the button
|
||||
Widget okButton = TextButton(
|
||||
child: Text("OK"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
|
||||
// set up the AlertDialog
|
||||
AlertDialog alert = AlertDialog(
|
||||
backgroundColor: Color(0xFF1F1F1F),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)),
|
||||
title: Text(title,textAlign: TextAlign.center,),
|
||||
content: Text(message,textAlign: TextAlign.center,),
|
||||
actions: [
|
||||
okButton,
|
||||
],
|
||||
|
||||
);
|
||||
|
||||
// show the dialog
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return alert;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
static bool showing = false;
|
||||
static BuildContext? context;
|
||||
static waiting(){
|
||||
showing=true;
|
||||
// context=navigatorKey.currentContext;
|
||||
if(context!=null) {
|
||||
return showDialog(
|
||||
context: context!,
|
||||
barrierDismissible: false,
|
||||
routeSettings: const RouteSettings(name: "Progress"),
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
|
||||
backgroundColor: Color(0xaa101010),
|
||||
title: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// SpinKitChasingDots(color: Colors.green),
|
||||
Expanded(child: Text("Loading",textAlign: TextAlign.center,)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static showDurationPicker(BuildContext context, String title) {
|
||||
// set up the button
|
||||
Widget okButton = TextButton(
|
||||
child: Text("OK"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
|
||||
// set up the AlertDialog
|
||||
AlertDialog alert = AlertDialog(
|
||||
backgroundColor: Color(0xFF1F1F1F),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)),
|
||||
title: Text(title,textAlign: TextAlign.center,),
|
||||
// content: DurationPicker(onChange: (Duration value) { return value; },),
|
||||
content: Container(
|
||||
child: DurationPicker(onChange: (val){
|
||||
Debug.Log(val);
|
||||
},),
|
||||
),
|
||||
actions: [
|
||||
okButton,
|
||||
],
|
||||
|
||||
);
|
||||
|
||||
// show the dialog
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return alert;
|
||||
},
|
||||
);
|
||||
}
|
||||
// static hide(){
|
||||
// showing=false;
|
||||
// Navigator.of(navigatorKey.currentContext!).popUntil((route){
|
||||
// return route.settings.name!="Progress";
|
||||
// });
|
||||
// }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user