|
|
|
@ -4,10 +4,15 @@ import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/api/vacation_rule_api_client.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/date_uitl.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/models/generic_response_model.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/models/vacation_rule/create_vacation_rule_list_model.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/models/vacation_rule/get_item_type_notifications_list_model.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/models/vacation_rule/get_notification_reassign_mode_list_model.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/models/vacation_rule/respond_attributes_list_model.dart';
|
|
|
|
@ -18,6 +23,7 @@ import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/bottom_sheet.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/bottom_sheets/search_employee_bottom_sheet.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/item_detail_view_widget.dart';
|
|
|
|
|
|
|
|
|
@ -41,11 +47,18 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
GetNotificationReassignModeList? notificationReassignMode;
|
|
|
|
|
|
|
|
|
|
List<RespondAttributesList>? respondAttributesList;
|
|
|
|
|
List<String>? roleList = [];
|
|
|
|
|
List<WFLookUpList>? wfLookupList;
|
|
|
|
|
|
|
|
|
|
ReplacementList? selectedReplacementEmployee;
|
|
|
|
|
|
|
|
|
|
String varcharInput = "";
|
|
|
|
|
String numInput = "";
|
|
|
|
|
DateTime? dateInput;
|
|
|
|
|
WFLookUpList? wfLook;
|
|
|
|
|
|
|
|
|
|
int currentStage = 0;
|
|
|
|
|
String message = "";
|
|
|
|
|
|
|
|
|
|
DateTime startTime = DateTime.now();
|
|
|
|
|
DateTime? endTime;
|
|
|
|
@ -89,14 +102,23 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
List results = await Future.wait([
|
|
|
|
|
VacationRuleApiClient().getNotificationReassignMode(),
|
|
|
|
|
VacationRuleApiClient().getRespondAttributes(selectedItemType!.iTEMTYPE!, selectedItemTypeNotification!.nOTIFICATIONNAME!),
|
|
|
|
|
// VacationRuleApiClient().getWfLookup(P_LOOKUP_TYPE),
|
|
|
|
|
]);
|
|
|
|
|
notificationReassignModeList = results[0];
|
|
|
|
|
GenericResponseModel respondAttribute = results[1];
|
|
|
|
|
respondAttributesList = respondAttribute.respondAttributesList;
|
|
|
|
|
if (respondAttributesList?.isNotEmpty ?? false) {
|
|
|
|
|
int index = respondAttributesList!.indexWhere((element) => element.aTTRIBUTETYPE == "LOOKUP");
|
|
|
|
|
if (index > -1) {
|
|
|
|
|
wfLookupList = await VacationRuleApiClient().getWfLookup(respondAttributesList![index].aTTRIBUTEFORMAT!);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
roleList = respondAttribute.respondRolesList;
|
|
|
|
|
|
|
|
|
|
if (selectedItemType!.iTEMTYPE != "*") {
|
|
|
|
|
notificationReassignModeList!.add(
|
|
|
|
|
GetNotificationReassignModeList(
|
|
|
|
|
rADIOBUTTONLABEL: "Deliver notifications to me regardless of any general rules",
|
|
|
|
|
rADIOBUTTONACTION: "deliver_notification",
|
|
|
|
|
rADIOBUTTONACTION: "DELIVER", // ionic: DELIVER
|
|
|
|
|
rADIOBUTTONSEQ: 1,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
@ -105,13 +127,25 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
notificationReassignModeList!.add(
|
|
|
|
|
GetNotificationReassignModeList(
|
|
|
|
|
rADIOBUTTONLABEL: "Close",
|
|
|
|
|
rADIOBUTTONACTION: "close",
|
|
|
|
|
rADIOBUTTONACTION: "CLOSE", // ionic: CLOSE
|
|
|
|
|
rADIOBUTTONSEQ: 1,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (respondAttributesList!.isNotEmpty && !(selectedItemTypeNotification!.fYIFLAG == "Y")) {
|
|
|
|
|
notificationReassignModeList!.add(
|
|
|
|
|
GetNotificationReassignModeList(
|
|
|
|
|
rADIOBUTTONLABEL: "Respond",
|
|
|
|
|
rADIOBUTTONACTION: "RESPOND", // ionic: RESPOND
|
|
|
|
|
rADIOBUTTONSEQ: 1,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
respondAttributesList = results[1];
|
|
|
|
|
// wfLookupList = results[2];
|
|
|
|
|
|
|
|
|
|
if (notificationReassignModeList!.isNotEmpty) {
|
|
|
|
|
notificationReassignMode = notificationReassignModeList!.first;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
currentStage = 3;
|
|
|
|
|
setState(() {});
|
|
|
|
@ -121,6 +155,111 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Widget> getDynamicWidgetList() {
|
|
|
|
|
List<Widget> respondAttributesWidgetList = [];
|
|
|
|
|
for (int i = 0; i < respondAttributesList!.length; i++) {
|
|
|
|
|
if (respondAttributesList![i].aTTRIBUTETYPE == "VARCHAR2") {
|
|
|
|
|
respondAttributesWidgetList.add(
|
|
|
|
|
DynamicTextFieldWidget(respondAttributesList![i].aTTRIBUTEDISPLAYNAME!, respondAttributesList![i].aTTRIBUTENAME!, onChange: (message) {
|
|
|
|
|
varcharInput = message;
|
|
|
|
|
}).paddingOnly(bottom: 12),
|
|
|
|
|
);
|
|
|
|
|
} else if (respondAttributesList![i].aTTRIBUTETYPE == "LOOKUP") {
|
|
|
|
|
respondAttributesWidgetList.add(
|
|
|
|
|
PopupMenuButton(
|
|
|
|
|
child: DynamicTextFieldWidget(
|
|
|
|
|
respondAttributesList![i].aTTRIBUTEDISPLAYNAME!,
|
|
|
|
|
wfLook?.lOOKUPMEANING ?? respondAttributesList![i].aTTRIBUTENAME!,
|
|
|
|
|
isEnable: false,
|
|
|
|
|
isPopup: true,
|
|
|
|
|
).paddingOnly(bottom: 12),
|
|
|
|
|
itemBuilder: (_) => <PopupMenuItem<int>>[
|
|
|
|
|
for (int i = 0; i < wfLookupList!.length; i++) PopupMenuItem<int>(value: i, child: Text(wfLookupList![i].lOOKUPMEANING!)),
|
|
|
|
|
],
|
|
|
|
|
onSelected: (int popupIndex) {
|
|
|
|
|
wfLook = wfLookupList![popupIndex];
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else if (respondAttributesList![i].aTTRIBUTETYPE == "DATE") {
|
|
|
|
|
respondAttributesWidgetList.add(DynamicTextFieldWidget(
|
|
|
|
|
respondAttributesList![i].aTTRIBUTEDISPLAYNAME!,
|
|
|
|
|
dateInput?.toString() ?? respondAttributesList![i].aTTRIBUTENAME!,
|
|
|
|
|
suffixIconData: Icons.calendar_today,
|
|
|
|
|
isEnable: false,
|
|
|
|
|
onTap: () async {
|
|
|
|
|
dateInput = await _selectDate(context);
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
).paddingOnly(bottom: 12));
|
|
|
|
|
} else if (respondAttributesList![i].aTTRIBUTETYPE == "NUMBER") {
|
|
|
|
|
respondAttributesWidgetList.add(
|
|
|
|
|
DynamicTextFieldWidget(
|
|
|
|
|
respondAttributesList![i].aTTRIBUTEDISPLAYNAME!,
|
|
|
|
|
respondAttributesList![i].aTTRIBUTENAME!,
|
|
|
|
|
isInputTypeNum: true,
|
|
|
|
|
onChange: (input) {
|
|
|
|
|
numInput = input;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return respondAttributesWidgetList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void createVacationRule(List<Map<String, dynamic>> respondAttributeList) async {
|
|
|
|
|
try {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
CreateVacationRuleList? createVacationRuleList = await VacationRuleApiClient().createVacationRule(DateUtil.convertDateToStringLocation(startTime), DateUtil.convertDateToStringLocation(endTime!),
|
|
|
|
|
selectedItemType!.iTEMTYPE!, selectedItemTypeNotification!.nOTIFICATIONNAME!, message, getPAction(), selectedReplacementEmployee!.userName!, respondAttributeList);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.showToast("Vacation rule added.");
|
|
|
|
|
Navigator.popUntil(context, ModalRoute.withName('AppRoutes.dashboard'));
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.handleException(ex, context, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String getPAction() {
|
|
|
|
|
String pAction = "";
|
|
|
|
|
switch (notificationReassignMode?.rADIOBUTTONACTION ?? "") {
|
|
|
|
|
case 'DELEGATE':
|
|
|
|
|
{
|
|
|
|
|
pAction = "FORWARD";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 'RESPOND':
|
|
|
|
|
{
|
|
|
|
|
pAction = "RESPOND";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 'CLOSE':
|
|
|
|
|
{
|
|
|
|
|
pAction = "RESPOND";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 'DELIVER':
|
|
|
|
|
{
|
|
|
|
|
pAction = "NOOP";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 'TRANSFER':
|
|
|
|
|
{
|
|
|
|
|
pAction = "TRANSFER";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
pAction = "";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return pAction;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
@ -132,7 +271,7 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
appBar: AppBarWidget(
|
|
|
|
|
context,
|
|
|
|
|
title: LocaleKeys.vacationRule.tr(), // todo @Sikander change title to 'Vacation Type'
|
|
|
|
|
title: LocaleKeys.vacationType.tr(),
|
|
|
|
|
),
|
|
|
|
|
body: vrItemTypesList == null
|
|
|
|
|
? const SizedBox()
|
|
|
|
@ -233,46 +372,75 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
"Message",
|
|
|
|
|
"Write a message",
|
|
|
|
|
lines: 2,
|
|
|
|
|
onChange: (message) {},
|
|
|
|
|
// isEnable: false,
|
|
|
|
|
// isPopup: true,
|
|
|
|
|
).paddingOnly(bottom: 12),
|
|
|
|
|
PopupMenuButton(
|
|
|
|
|
child: DynamicTextFieldWidget(
|
|
|
|
|
"Notification Reassign",
|
|
|
|
|
notificationReassignMode == null ? "Select Notification" : notificationReassignMode!.rADIOBUTTONLABEL ?? "",
|
|
|
|
|
isEnable: false,
|
|
|
|
|
isPopup: true,
|
|
|
|
|
).paddingOnly(bottom: 12),
|
|
|
|
|
itemBuilder: (_) => <PopupMenuItem<int>>[
|
|
|
|
|
for (int i = 0; i < notificationReassignModeList!.length; i++) PopupMenuItem<int>(value: i, child: Text(notificationReassignModeList![i].rADIOBUTTONLABEL!)),
|
|
|
|
|
],
|
|
|
|
|
onSelected: (int popupIndex) {
|
|
|
|
|
if (notificationReassignMode == notificationReassignModeList![popupIndex]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
notificationReassignMode = notificationReassignModeList![popupIndex];
|
|
|
|
|
setState(() {});
|
|
|
|
|
}),
|
|
|
|
|
DynamicTextFieldWidget(
|
|
|
|
|
"Select Employee",
|
|
|
|
|
selectedReplacementEmployee == null ? "Search employee for replacement" : selectedReplacementEmployee!.employeeDisplayName ?? "",
|
|
|
|
|
isEnable: false,
|
|
|
|
|
onTap: () {
|
|
|
|
|
showMyBottomSheet(
|
|
|
|
|
context,
|
|
|
|
|
child: SearchEmployeeBottomSheet(
|
|
|
|
|
title: "Search for Employee",
|
|
|
|
|
apiMode: "DELEGATE",
|
|
|
|
|
onSelectEmployee: (_selectedEmployee) {
|
|
|
|
|
// Navigator.pop(context);
|
|
|
|
|
selectedReplacementEmployee = _selectedEmployee;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
onChange: (message) {
|
|
|
|
|
this.message = message;
|
|
|
|
|
},
|
|
|
|
|
).paddingOnly(bottom: 12),
|
|
|
|
|
ListView.separated(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
itemBuilder: (cxt, index) {
|
|
|
|
|
return Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
width: 20,
|
|
|
|
|
height: 20,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.transparent,
|
|
|
|
|
border: Border.all(color: MyColors.borderColor, width: 1),
|
|
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(100)),
|
|
|
|
|
),
|
|
|
|
|
padding: const EdgeInsets.all(4),
|
|
|
|
|
child: Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: double.infinity,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: notificationReassignModeList![index] == notificationReassignMode ? MyColors.grey3AColor : Colors.transparent,
|
|
|
|
|
borderRadius: BorderRadius.all(const Radius.circular(100)),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
9.width,
|
|
|
|
|
(notificationReassignModeList![index].rADIOBUTTONLABEL!).toText12(color: MyColors.grey57Color).expanded
|
|
|
|
|
],
|
|
|
|
|
).onPress(() {
|
|
|
|
|
if (notificationReassignMode == notificationReassignModeList![index]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
notificationReassignMode = notificationReassignModeList![index];
|
|
|
|
|
setState(() {});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
separatorBuilder: (cxt, index) => 12.height,
|
|
|
|
|
itemCount: notificationReassignModeList!.length)
|
|
|
|
|
.objectContainerBorderView(title: "Notification Reassign"),
|
|
|
|
|
12.height,
|
|
|
|
|
if (respondAttributesList?.isNotEmpty ?? false) ...getDynamicWidgetList(),
|
|
|
|
|
if (roleList!.isNotEmpty && notificationReassignMode?.rADIOBUTTONACTION == 'RESPOND' ||
|
|
|
|
|
// if (notificationReassignMode?.rADIOBUTTONACTION == 'RESPOND' ||
|
|
|
|
|
(notificationReassignMode?.rADIOBUTTONACTION == 'DELEGATE') ||
|
|
|
|
|
(notificationReassignMode?.rADIOBUTTONACTION == 'TRANSFER'))
|
|
|
|
|
DynamicTextFieldWidget(
|
|
|
|
|
"Select Employee",
|
|
|
|
|
selectedReplacementEmployee == null ? "Search employee for replacement" : selectedReplacementEmployee!.employeeDisplayName ?? "",
|
|
|
|
|
isEnable: false,
|
|
|
|
|
onTap: () {
|
|
|
|
|
showMyBottomSheet(
|
|
|
|
|
context,
|
|
|
|
|
child: SearchEmployeeBottomSheet(
|
|
|
|
|
title: "Search for Employee",
|
|
|
|
|
apiMode: "DELEGATE",
|
|
|
|
|
onSelectEmployee: (_selectedEmployee) {
|
|
|
|
|
// Navigator.pop(context);
|
|
|
|
|
selectedReplacementEmployee = _selectedEmployee;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
).paddingOnly(bottom: 12),
|
|
|
|
|
],
|
|
|
|
|
).objectContainerView(title: "Step 3")
|
|
|
|
|
]
|
|
|
|
@ -283,11 +451,54 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
currentStage != 3
|
|
|
|
|
? null
|
|
|
|
|
: () {
|
|
|
|
|
if (currentStage == 1) {
|
|
|
|
|
getItemTypeNotificationsList();
|
|
|
|
|
} else if (currentStage == 2) {
|
|
|
|
|
callCombineApis();
|
|
|
|
|
if (endTime == null) {
|
|
|
|
|
Utils.showToast("Please specify End Time");
|
|
|
|
|
return;
|
|
|
|
|
} else if (notificationReassignMode == null) {
|
|
|
|
|
Utils.showToast("Please select notification reassign");
|
|
|
|
|
return;
|
|
|
|
|
} else if (selectedReplacementEmployee == null) {
|
|
|
|
|
Utils.showToast("Please select employee for replacement");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Map<String, dynamic>> list = [];
|
|
|
|
|
|
|
|
|
|
if (respondAttributesList?.isNotEmpty ?? false) {
|
|
|
|
|
for (int i = 0; i < respondAttributesList!.length; i++) {
|
|
|
|
|
if (respondAttributesList![i].aTTRIBUTETYPE == "VARCHAR2") {
|
|
|
|
|
list.add({"ATTRIBUTE_NAME": respondAttributesList![i].aTTRIBUTENAME, "ATTRIBUTE_TEXT_VALUE": varcharInput});
|
|
|
|
|
}
|
|
|
|
|
if (respondAttributesList![i].aTTRIBUTETYPE == "LOOKUP") {
|
|
|
|
|
if (wfLook == null) {
|
|
|
|
|
Utils.showToast('Please select action');
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
list.add({"ATTRIBUTE_NAME": respondAttributesList![i].aTTRIBUTENAME, "ATTRIBUTE_TEXT_VALUE": wfLook!.lOOKUPCODE});
|
|
|
|
|
}
|
|
|
|
|
if (respondAttributesList![i].aTTRIBUTETYPE == "DATE") {
|
|
|
|
|
if (dateInput == null) {
|
|
|
|
|
Utils.showToast('Please select date');
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
list.add({"ATTRIBUTE_NAME": respondAttributesList![i].aTTRIBUTENAME, "ATTRIBUTE_TEXT_VALUE": DateUtil.convertDateToStringLocation(dateInput!)});
|
|
|
|
|
}
|
|
|
|
|
if (respondAttributesList![i].aTTRIBUTETYPE == "NUMBER") {
|
|
|
|
|
list.add({"ATTRIBUTE_NAME": respondAttributesList![i].aTTRIBUTENAME, "ATTRIBUTE_TEXT_VALUE": numInput});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (cxt) => ConfirmDialog(
|
|
|
|
|
message: LocaleKeys.areYouSureYouWantToSubmit.tr(),
|
|
|
|
|
onTap: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
createVacationRule(list);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
).insideContainer,
|
|
|
|
|
],
|
|
|
|
@ -338,4 +549,35 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
|
|
|
|
|
if (_time == null) return "Select date and time";
|
|
|
|
|
return DateFormat("MM/dd/yyyy hh:mm:ss a").format(_time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<DateTime> _selectDate(BuildContext context) async {
|
|
|
|
|
DateTime time = dateInput ?? DateTime.now();
|
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
|
await showCupertinoModalPopup(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (cxt) => Container(
|
|
|
|
|
height: 250,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: CupertinoDatePicker(
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
mode: CupertinoDatePickerMode.date,
|
|
|
|
|
onDateTimeChanged: (value) {
|
|
|
|
|
if (value != null && value != dateInput) {
|
|
|
|
|
time = value;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
initialDateTime: dateInput,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
final DateTime? picked =
|
|
|
|
|
await showDatePicker(context: context, initialDate: dateInput ?? DateTime.now(), initialEntryMode: DatePickerEntryMode.calendarOnly, firstDate: DateTime(2015, 8), lastDate: DateTime(2101));
|
|
|
|
|
if (picked != null && picked != dateInput) {
|
|
|
|
|
time = picked;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
time = DateTime(time.year, time.month, time.day);
|
|
|
|
|
return time;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|