Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 48 additions & 37 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,6 @@ class ExampleApp extends StatelessWidget {
onPressed: () {
_openDateTimePicker(
context,
CupertinoDatePickerCalendarType.fullWeek,
);
},
child: Text('Date and Time Picker', textAlign: TextAlign.center),
),
),
SizedBox(
width: buttonWidth,
child: ElevatedButton(
onPressed: () {
_openDateTimePicker(
context,
CupertinoDatePickerCalendarType.workDays,
);
},
child: Text('Workday Picker', textAlign: TextAlign.center),
Expand All @@ -194,9 +181,8 @@ class ExampleApp extends StatelessWidget {
width: buttonWidth,
child: ElevatedButton(
onPressed: () {
_openDateTimePicker(
_openDateTimePickerWeekend(
context,
CupertinoDatePickerCalendarType.weekend,
);
},
child: Text('Weekend Day Picker', textAlign: TextAlign.center),
Expand Down Expand Up @@ -312,11 +298,6 @@ class ExampleApp extends StatelessWidget {
initialDateTime: DateTime(1996, 10, 22),
maxDateTime: DateTime(1998),
minDateTime: DateTime(1980),
pickerTextStyle: TextStyle(
color: Colors.blue,
fontWeight: FontWeight.bold,
fontSize: 12,
),
onChange: (index) {
print(index);
},
Expand Down Expand Up @@ -376,11 +357,6 @@ class ExampleApp extends StatelessWidget {
initialDateTime: DateTime(1996, 10, 22),
maxDateTime: DateTime(1998),
minDateTime: DateTime(1980),
pickerTextStyle: TextStyle(
color: Colors.blue,
fontWeight: FontWeight.bold,
fontSize: 12,
),
onChange: (index) {
print(index);
},
Expand Down Expand Up @@ -445,11 +421,6 @@ class ExampleApp extends StatelessWidget {
dateOrder: DatePickerDateOrder.dmy,
initialSecondDate: DateTime.now().add(Duration(days: 230)),
itemExtent: 20,
pickerTextStyle: TextStyle(
color: Colors.blue,
fontWeight: FontWeight.bold,
fontSize: 12,
),
onRangeDateSubmitPressed: (firstDate, secondDate) {
print(firstDate);
print(secondDate);
Expand Down Expand Up @@ -484,11 +455,6 @@ class ExampleApp extends StatelessWidget {
],
);
},
pickerTextStyle: TextStyle(
color: Colors.blue,
fontWeight: FontWeight.bold,
fontSize: 12,
),
showTimeSeparator: true,
bottomPickerTheme: BottomPickerTheme.plumPlate,
onRangeTimeSubmitPressed: (firstDate, secondDate) {
Expand Down Expand Up @@ -588,7 +554,6 @@ class ExampleApp extends StatelessWidget {

void _openDateTimePicker(
BuildContext context,
CupertinoDatePickerCalendarType calendarType,
) {
BottomPicker.dateTime(
minuteInterval: 2,
Expand Down Expand Up @@ -629,7 +594,53 @@ class ExampleApp extends StatelessWidget {
Color(0xfffdcbf1),
Color(0xffe6dee9),
],
calendarType: calendarType,
calendarDays: CupertinoDatePickerWidget.workDays,
).show(context);
}

void _openDateTimePickerWeekend(
BuildContext context,
) {
BottomPicker.dateTime(
minuteInterval: 2,
headerBuilder: (context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Set the event exact time and date',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15,
color: Colors.black,
),
),
InkWell(
onTap: () {
print('Picker closed');
Navigator.pop(context);
},
child: Text(
'close',
style: TextStyle(
decoration: TextDecoration.underline,
),
),
),
],
);
},
onSubmit: (date) {
print(date);
},
minDateTime: DateTime(2021, 5, 1),
maxDateTime: DateTime(2021, 8, 2),
initialDateTime: DateTime(2021, 5, 1),
gradientColors: [
Color(0xfffdcbf1),
Color(0xffe6dee9),
],
calendarDays: CupertinoDatePickerWidget.weekend,
).show(context);
}
}
36 changes: 17 additions & 19 deletions lib/bottom_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class BottomPicker extends StatefulWidget {
this.buttonSingleColor,
this.backgroundColor = Colors.white,
this.pickerThemeData,
@Deprecated("should use pickerThemeData instead")
@Deprecated('should use pickerThemeData instead')
this.pickerTextStyle = const TextStyle(
fontSize: 14,
color: Colors.black,
Expand All @@ -75,7 +75,7 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.closeWidget,
this.closeOnSubmit = true,
this.headerBuilder,
this.calendarType = CupertinoDatePickerCalendarType.fullWeek,
this.calendarDays = CupertinoDatePickerWidget.fullWeek,
}) {
dateOrder = null;
onRangeDateSubmitPressed = null;
Expand Down Expand Up @@ -110,7 +110,7 @@ class BottomPicker extends StatefulWidget {
this.backgroundColor = Colors.white,
this.dateOrder = DatePickerDateOrder.ymd,
this.pickerThemeData,
@Deprecated("should use pickerThemeData instead")
@Deprecated('should use pickerThemeData instead')
this.pickerTextStyle = const TextStyle(
fontSize: 14,
color: Colors.black,
Expand All @@ -130,7 +130,7 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.closeWidget,
this.closeOnSubmit = true,
this.headerBuilder,
this.calendarType = CupertinoDatePickerCalendarType.fullWeek,
this.calendarDays = CupertinoDatePickerWidget.fullWeek,
}) {
datePickerMode = CupertinoDatePickerMode.date;
bottomPickerType = BottomPickerType.dateTime;
Expand Down Expand Up @@ -161,7 +161,7 @@ class BottomPicker extends StatefulWidget {
this.buttonSingleColor,
this.backgroundColor = Colors.white,
this.pickerThemeData,
@Deprecated("should use pickerThemeData instead")
@Deprecated('should use pickerThemeData instead')
this.pickerTextStyle = const TextStyle(
fontSize: 14,
color: Colors.black,
Expand All @@ -181,7 +181,7 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.closeWidget,
this.closeOnSubmit = true,
this.headerBuilder,
this.calendarType = CupertinoDatePickerCalendarType.fullWeek,
this.calendarDays = CupertinoDatePickerWidget.fullWeek,
}) {
datePickerMode = CupertinoDatePickerMode.monthYear;
bottomPickerType = BottomPickerType.dateTime;
Expand Down Expand Up @@ -216,7 +216,7 @@ class BottomPicker extends StatefulWidget {
this.backgroundColor = Colors.white,
this.dateOrder = DatePickerDateOrder.ymd,
this.pickerThemeData,
@Deprecated("should use pickerThemeData instead")
@Deprecated('should use pickerThemeData instead')
this.pickerTextStyle = const TextStyle(
fontSize: 14,
color: Colors.black,
Expand All @@ -237,7 +237,7 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.closeWidget,
this.closeOnSubmit = true,
this.headerBuilder,
this.calendarType = CupertinoDatePickerCalendarType.fullWeek,
this.calendarDays = CupertinoDatePickerWidget.fullWeek,
}) {
datePickerMode = CupertinoDatePickerMode.dateAndTime;
bottomPickerType = BottomPickerType.dateTime;
Expand Down Expand Up @@ -269,7 +269,7 @@ class BottomPicker extends StatefulWidget {
this.buttonSingleColor,
this.backgroundColor = Colors.white,
this.pickerThemeData,
@Deprecated("should use pickerThemeData instead")
@Deprecated('should use pickerThemeData instead')
this.pickerTextStyle = const TextStyle(
fontSize: 14,
color: Colors.black,
Expand All @@ -290,7 +290,7 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.closeWidget,
this.closeOnSubmit = true,
this.headerBuilder,
this.calendarType = CupertinoDatePickerCalendarType.fullWeek,
this.calendarDays = CupertinoDatePickerWidget.fullWeek,
}) {
datePickerMode = CupertinoDatePickerMode.time;
bottomPickerType = BottomPickerType.time;
Expand Down Expand Up @@ -324,7 +324,7 @@ class BottomPicker extends StatefulWidget {
this.buttonSingleColor,
this.backgroundColor = Colors.white,
this.pickerThemeData,
@Deprecated("should use pickerThemeData instead")
@Deprecated('should use pickerThemeData instead')
this.pickerTextStyle = const TextStyle(
fontSize: 14,
color: Colors.black,
Expand All @@ -343,7 +343,7 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.closeWidget,
this.closeOnSubmit = true,
this.headerBuilder,
this.calendarType = CupertinoDatePickerCalendarType.fullWeek,
this.calendarDays = CupertinoDatePickerWidget.fullWeek,
}) {
dateOrder = null;
onRangeDateSubmitPressed = null;
Expand Down Expand Up @@ -371,7 +371,7 @@ class BottomPicker extends StatefulWidget {
this.buttonSingleColor,
this.backgroundColor = Colors.white,
this.pickerThemeData,
@Deprecated("should use pickerThemeData instead")
@Deprecated('should use pickerThemeData instead')
this.pickerTextStyle = const TextStyle(
fontSize: 14,
color: Colors.black,
Expand All @@ -397,7 +397,7 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.closeWidget,
this.closeOnSubmit = true,
this.headerBuilder,
this.calendarType = CupertinoDatePickerCalendarType.fullWeek,
this.calendarDays = CupertinoDatePickerWidget.fullWeek,
}) {
datePickerMode = CupertinoDatePickerMode.date;
bottomPickerType = BottomPickerType.rangeDate;
Expand Down Expand Up @@ -440,7 +440,7 @@ class BottomPicker extends StatefulWidget {
this.buttonSingleColor,
this.backgroundColor = Colors.white,
this.pickerThemeData,
@Deprecated("should use pickerThemeData instead")
@Deprecated('should use pickerThemeData instead')
this.pickerTextStyle = const TextStyle(
fontSize: 14,
color: Colors.black,
Expand All @@ -467,7 +467,7 @@ class BottomPicker extends StatefulWidget {
@Deprecated('should use headerBuilder instead') this.closeWidget,
this.closeOnSubmit = true,
this.headerBuilder,
this.calendarType = CupertinoDatePickerCalendarType.fullWeek,
this.calendarDays = CupertinoDatePickerWidget.fullWeek,
}) {
datePickerMode = CupertinoDatePickerMode.time;
bottomPickerType = BottomPickerType.rangeTime;
Expand Down Expand Up @@ -763,7 +763,7 @@ class BottomPicker extends StatefulWidget {
final bool closeOnSubmit;

/// The datepicker calendar type
final CupertinoDatePickerCalendarType calendarType;
final List<int> calendarDays;

///display the bottom picker popup
///[context] the app context to display the popup
Expand Down Expand Up @@ -954,7 +954,6 @@ class BottomPickerState extends State<BottomPicker> {
textStyle: widget.pickerTextStyle,
itemExtent: widget.itemExtent,
showTimeSeparator: widget.showTimeSeparator,
calendarType: widget.calendarType,
pickerThemeData: widget.pickerThemeData,
)
: widget.bottomPickerType == BottomPickerType.dateTime
Expand All @@ -973,7 +972,6 @@ class BottomPickerState extends State<BottomPicker> {
textStyle: widget.pickerTextStyle,
itemExtent: widget.itemExtent,
showTimeSeparator: widget.showTimeSeparator,
calendarType: widget.calendarType,
pickerThemeData: widget.pickerThemeData,
)
: widget.bottomPickerType ==
Expand Down
Loading