|
|
|
|
@ -100,6 +100,10 @@ class _AddSchedulesPageState extends State<AddSchedulesPage> {
|
|
|
|
|
DropValue(2, 'Customer Location', ''),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
DateTime tomorrowDate = DateTime.now().add(const Duration(days: 1)).subtract(
|
|
|
|
|
Duration(hours: DateTime.now().hour, minutes: DateTime.now().minute, seconds: DateTime.now().second, microseconds: DateTime.now().microsecond),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
@ -177,8 +181,20 @@ class _AddSchedulesPageState extends State<AddSchedulesPage> {
|
|
|
|
|
onTap: () async {
|
|
|
|
|
startDate = await Utils.pickDateFromDatePicker(
|
|
|
|
|
context,
|
|
|
|
|
initial: tomorrowDate,
|
|
|
|
|
firstDate: DateTime.now(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (endDate.isNotEmpty) {
|
|
|
|
|
DateTime sDate = DateTime.parse(startDate);
|
|
|
|
|
DateTime eDate = DateTime.parse(endDate);
|
|
|
|
|
|
|
|
|
|
if (sDate.isAfter(eDate)) {
|
|
|
|
|
startDate = "";
|
|
|
|
|
Utils.showToast(LocaleKeys.endDateAfterStartDate.tr());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FocusManager.instance.primaryFocus?.unfocus();
|
|
|
|
|
scheduleVM.refresh();
|
|
|
|
|
},
|
|
|
|
|
@ -191,12 +207,32 @@ class _AddSchedulesPageState extends State<AddSchedulesPage> {
|
|
|
|
|
size: 16,
|
|
|
|
|
),
|
|
|
|
|
value: endDate,
|
|
|
|
|
isNeedClickAll: true,
|
|
|
|
|
isNeedClickAll: true,
|
|
|
|
|
onTap: () async {
|
|
|
|
|
DateTime? firstDate;
|
|
|
|
|
DateTime? sDate;
|
|
|
|
|
if (startDate.isEmpty) {
|
|
|
|
|
Utils.showToast(LocaleKeys.pleaseEnterStartDateFirst.tr());
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
sDate = DateTime.parse(startDate);
|
|
|
|
|
|
|
|
|
|
firstDate = sDate.add(const Duration(days: 1)).subtract(
|
|
|
|
|
Duration(hours: DateTime.now().hour, minutes: DateTime.now().minute, seconds: DateTime.now().second, microseconds: DateTime.now().microsecond),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
endDate = await Utils.pickDateFromDatePicker(
|
|
|
|
|
context,
|
|
|
|
|
firstDate: DateTime.now(),
|
|
|
|
|
initial: tomorrowDate,
|
|
|
|
|
firstDate: firstDate ?? tomorrowDate,
|
|
|
|
|
);
|
|
|
|
|
DateTime eDate = DateTime.parse(endDate);
|
|
|
|
|
|
|
|
|
|
if (!eDate.isAfter(sDate)) {
|
|
|
|
|
endDate = "";
|
|
|
|
|
Utils.showToast(LocaleKeys.endDateAfterStartDate.tr());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FocusManager.instance.primaryFocus?.unfocus();
|
|
|
|
|
scheduleVM.refresh();
|
|
|
|
|
},
|
|
|
|
|
@ -231,6 +267,16 @@ class _AddSchedulesPageState extends State<AddSchedulesPage> {
|
|
|
|
|
isNeedClickAll: true,
|
|
|
|
|
onTap: () async {
|
|
|
|
|
startTime = await Utils.pickTime(context);
|
|
|
|
|
|
|
|
|
|
if (endTime.isNotEmpty) {
|
|
|
|
|
TimeOfDay sTime = TimeOfDayUtils.convertStringToTimeOfDay(startTime);
|
|
|
|
|
TimeOfDay eTime = TimeOfDayUtils.convertStringToTimeOfDay(endTime);
|
|
|
|
|
if (!eTime.isAfter(sTime)) {
|
|
|
|
|
startTime = "";
|
|
|
|
|
Utils.showToast(LocaleKeys.endTimeAfterStartTime.tr());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FocusManager.instance.primaryFocus?.unfocus();
|
|
|
|
|
scheduleVM.refresh();
|
|
|
|
|
},
|
|
|
|
|
@ -248,11 +294,23 @@ class _AddSchedulesPageState extends State<AddSchedulesPage> {
|
|
|
|
|
isNeedClickAll: true,
|
|
|
|
|
onTap: () async {
|
|
|
|
|
TimeOfDay _startTime = TimeOfDay.now();
|
|
|
|
|
if (startTime.isNotEmpty) _startTime = TimeOfDay(hour: int.parse(startTime.split(":")[0]), minute: int.parse(startTime.split(":")[1]));
|
|
|
|
|
if (startTime.isNotEmpty) {
|
|
|
|
|
_startTime = TimeOfDay(hour: int.parse(startTime.split(":")[0]), minute: int.parse(startTime.split(":")[1]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
endTime = await Utils.pickTime(
|
|
|
|
|
context,
|
|
|
|
|
initialTime: _startTime,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (startTime.isNotEmpty) {
|
|
|
|
|
TimeOfDay sTime = TimeOfDayUtils.convertStringToTimeOfDay(startTime);
|
|
|
|
|
TimeOfDay eTime = TimeOfDayUtils.convertStringToTimeOfDay(endTime);
|
|
|
|
|
if (!eTime.isAfter(sTime)) {
|
|
|
|
|
endTime = "";
|
|
|
|
|
Utils.showToast(LocaleKeys.endTimeAfterStartTime.tr());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
FocusManager.instance.primaryFocus?.unfocus();
|
|
|
|
|
scheduleVM.refresh();
|
|
|
|
|
},
|
|
|
|
|
|