You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aku_new_community/lib/widget/picker/bee_day_picker.dart

72 lines
1.6 KiB

import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:aku_new_community/widget/picker/bee_choose_date_picker.dart';
class BeeDayPicker {
static Future<DateTime?> pick(
DateTime initDate, {
CupertinoDatePickerMode mode = CupertinoDatePickerMode.date,
DateTime? min,
DateTime? max,
}) async {
return await Get.bottomSheet(_BeeDayPicker(
date: initDate,
mode: mode,
min: min ?? DateTime.now().subtract(Duration(days: 1)),
max: max,
));
}
}
class _BeeDayPicker extends StatefulWidget {
final DateTime date;
final bool use24H;
final DateTime? max;
final DateTime? min;
final CupertinoDatePickerMode? mode;
_BeeDayPicker({
Key? key,
required this.date,
this.use24H = false,
this.max,
this.min,
this.mode,
}) : super(key: key);
@override
__BeeDayPickerState createState() => __BeeDayPickerState();
}
class __BeeDayPickerState extends State<_BeeDayPicker> {
DateTime _date = DateTime.now();
@override
void initState() {
super.initState();
_date = widget.date;
}
@override
Widget build(BuildContext context) {
return BeeChooseDatePicker(
onPressed: () async{
Get.back(result: _date);
// await FacilityPreorderDatePicker();
},
body: CupertinoDatePicker(
use24hFormat: widget.use24H,
maximumDate: widget.max,
minimumDate: widget.min,
initialDateTime: _date,
onDateTimeChanged: (date) => _date = date,
mode: widget.mode ?? CupertinoDatePickerMode.date,
).expand(),
);
}
}