showGlobalDatePicker function

Future<JPickerValue?> showGlobalDatePicker({
  1. required BuildContext context,
  2. PickerType pickerType = PickerType.JHijri,
  3. JDateModel? startDate,
  4. JDateModel? endDate,
  5. JDateModel? selectedDate,
  6. DatePickerMode? pickerMode,
  7. String? okButtonText,
  8. String? cancelButtonText,
  9. Widget? headerTitle,
  10. dynamic onOk(
    1. JPickerValue datetime
    )?,
  11. dynamic onChange(
    1. JPickerValue datetime
    )?,
  12. VoidCallback? onCancel,
  13. ThemeData? pickerTheme,
  14. Color? primaryColor,
  15. Color? backgroundColor,
  16. Color? calendarTextColor,
  17. Color? buttonTextColor,
  18. Color? cancelButtonColor,
  19. Color? okButtonColor,
  20. Radius? borderRadius,
  21. Widget? buttons,
  22. TextDirection? textDirection,
  23. Locale? locale,
  24. SelectableDayPredicate? selectableDayPredicate,
  25. JSelectableDayPredicate? jSelectableDayPredicate,
})

Implementation

Future<JPickerValue?> showGlobalDatePicker({
  required BuildContext context,
  PickerType pickerType = PickerType.JHijri,
  JDateModel? startDate,
  JDateModel? endDate,
  JDateModel? selectedDate,
  DatePickerMode? pickerMode,
  String? okButtonText,
  String? cancelButtonText,
  Widget? headerTitle,
  Function(JPickerValue datetime)? onOk,
  Function(JPickerValue datetime)? onChange,
  VoidCallback? onCancel,
  ThemeData? pickerTheme,
  Color? primaryColor,
  Color? backgroundColor,
  Color? calendarTextColor,
  Color? buttonTextColor,
  Color? cancelButtonColor,
  Color? okButtonColor,
  Radius? borderRadius,
  Widget? buttons,
  TextDirection? textDirection,
  Locale? locale,
  SelectableDayPredicate? selectableDayPredicate,
  JSelectableDayPredicate? jSelectableDayPredicate,
}) {
  JHijri _select = JHijri();
  JHijri _start = JHijri(fYear: 2000);
  JHijri _end = JHijri(fYear: 2060);
  JDateModel _startDate = startDate != null
      ? startDate
      : pickerType == PickerType.JHijri
          ? JDateModel(jhijri: _start)
          : JDateModel(dateTime: _start.dateTime);
  JDateModel _endDate = endDate != null
      ? endDate
      : pickerType == PickerType.JHijri
          ? JDateModel(jhijri: _end)
          : JDateModel(dateTime: _end.dateTime);
  JDateModel _selectedDate = selectedDate != null
      ? selectedDate
      : pickerType == PickerType.JHijri
          ? JDateModel(jhijri: _select)
          : JDateModel(dateTime: _select.dateTime);
  return showDialog<JPickerValue?>(
    context: context,
    builder: (BuildContext context) {
      return JGlobalDatePicker(
          pickerType: pickerType,
          selectableDayPredicate: selectableDayPredicate,
          jSelectableDayPredicate: jSelectableDayPredicate,
          locale: locale,
          textDirection: textDirection,
          buttons: buttons,
          borderRadius: borderRadius,
          okButtonText: okButtonText,
          okButtonColor: okButtonColor,
          cancelButtonText: cancelButtonText,
          cancelButtonColor: cancelButtonColor,
          calendarTextColor: calendarTextColor,
          primaryColor: primaryColor,
          pickerTheme: pickerTheme,
          pickerMode: pickerMode,
          onCancel: onCancel,
          onChange: onChange,
          onOk: onOk,
          headerTitle: headerTitle,
          backgroundColor: backgroundColor,
          buttonTextColor: buttonTextColor,
          selectedDate: _selectedDate,
          startDate: _startDate,
          endDate: _endDate);
    },
  );
}