119 lines
4.5 KiB
Dart
119 lines
4.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:queue_mgr/backend/DataManager.dart';
|
|
|
|
class NewService extends StatefulWidget {
|
|
const NewService({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<NewService> createState() => _NewServiceState();
|
|
}
|
|
|
|
class _NewServiceState extends State<NewService> {
|
|
TextEditingController nameController = TextEditingController();
|
|
DateTime sDate = DateTime.now();
|
|
TimeOfDay sTime = TimeOfDay(hour: 2, minute: 2);
|
|
DateTime eDate = DateTime.now();
|
|
TimeOfDay eTime = TimeOfDay(hour: 2, minute: 2);
|
|
TimeOfDay duration = TimeOfDay(hour:0, minute: 15);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: Text("New Service")),
|
|
body: Container(
|
|
padding: EdgeInsets.all(20),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Column(
|
|
children: [
|
|
ListTile(
|
|
title: Text("Service Name"),
|
|
subtitle: TextField(
|
|
controller: nameController,
|
|
),
|
|
),
|
|
ListTile(
|
|
title: Text("Starting Time"),
|
|
subtitle: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
ElevatedButton(
|
|
child: Text("${sDate.year}-${sDate.month}-${sDate.day}"),
|
|
onPressed: () async{
|
|
sDate = await showDatePicker(context: context, initialDate: DateTime.now(), firstDate: DateTime.now().subtract(const Duration(days: 350)), lastDate: DateTime.now().add(const Duration(days: 350))) ?? sDate;
|
|
setState(() {
|
|
|
|
});
|
|
},
|
|
),
|
|
ElevatedButton(
|
|
child: Text("${sTime.hour}:${sTime.minute}"),
|
|
onPressed: () async{
|
|
sTime = await showTimePicker(context: context, initialTime: sTime) ?? sTime;
|
|
setState(() {
|
|
|
|
});
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
ListTile(
|
|
title: Text("Ending Time"),
|
|
subtitle: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
ElevatedButton(
|
|
child: Text("${eDate.year}-${eDate.month}-${eDate.day}"),
|
|
onPressed: () async{
|
|
eDate = await showDatePicker(context: context, initialDate: DateTime.now(), firstDate: DateTime.now().subtract(const Duration(days: 350)), lastDate: DateTime.now().add(const Duration(days: 350))) ?? eDate;
|
|
setState(() {
|
|
|
|
});
|
|
},
|
|
),
|
|
ElevatedButton(
|
|
child: Text("${eTime.hour}:${eTime.minute}"),
|
|
onPressed: () async{
|
|
eTime = await showTimePicker(context: context, initialTime: eTime) ?? eTime;
|
|
setState(() {
|
|
|
|
});
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
ListTile(
|
|
title:Text("Duration for each"),
|
|
subtitle: ElevatedButton(
|
|
child: Text("${duration.hour}:${duration.minute}"),
|
|
onPressed: () async{
|
|
duration = await showTimePicker(context: context, initialTime: duration) ?? duration;
|
|
setState(() {
|
|
|
|
});
|
|
},
|
|
),
|
|
)
|
|
],
|
|
),
|
|
Container(margin: EdgeInsets.all(20),width:200,height:50,child: ElevatedButton(onPressed: () async{
|
|
DateTime s_date = DateTime(sDate.year, sDate.month, sDate.day, sTime.hour, sTime.minute);
|
|
DateTime e_date = DateTime(eDate.year, eDate.month, eDate.day, eTime.hour, eTime.minute);
|
|
await DataManager.instance().AddService(nameController.text, s_date, e_date,duration);
|
|
setState(() {
|
|
|
|
});
|
|
|
|
Navigator.pop(context);
|
|
|
|
}, child: Text("Add")))
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|