diff --git a/lib/flutter_datetime_picker.dart b/lib/flutter_datetime_picker.dart index dba6b566..f6cf941c 100644 --- a/lib/flutter_datetime_picker.dart +++ b/lib/flutter_datetime_picker.dart @@ -185,6 +185,19 @@ class DatePicker { } } +class _DefaultSelectionOverlay extends StatelessWidget { + const _DefaultSelectionOverlay(); + + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [const Divider(height: 1), const Divider(height: 1)], + ); + } +} + class _DatePickerRoute extends PopupRoute { _DatePickerRoute({ this.showTitleActions, @@ -194,6 +207,7 @@ class _DatePickerRoute extends PopupRoute { DatePickerTheme? theme, this.barrierLabel, this.locale, + this.selectionOverlay = const _DefaultSelectionOverlay(), RouteSettings? settings, BasePickerModel? pickerModel, }) : this.pickerModel = pickerModel ?? DatePickerModel(), @@ -207,6 +221,7 @@ class _DatePickerRoute extends PopupRoute { final LocaleType? locale; final DatePickerTheme theme; final BasePickerModel pickerModel; + final Widget? selectionOverlay; @override Duration get transitionDuration => const Duration(milliseconds: 200); @@ -351,7 +366,7 @@ class _DatePickerState extends State<_DatePickerComponent> { return Expanded( flex: layoutProportion, child: Container( - padding: EdgeInsets.all(8.0), + padding: EdgeInsets.all(0.0), height: theme.containerHeight, decoration: BoxDecoration(color: theme.backgroundColor), child: NotificationListener( @@ -367,6 +382,7 @@ class _DatePickerState extends State<_DatePickerComponent> { return false; }, child: CupertinoPicker.builder( + selectionOverlay: widget.route.selectionOverlay, key: key, backgroundColor: theme.backgroundColor, scrollController: scrollController as FixedExtentScrollController, @@ -385,6 +401,7 @@ class _DatePickerState extends State<_DatePickerComponent> { alignment: Alignment.center, child: Text( content, + maxLines: theme.itemMaxLines, style: theme.itemStyle, textAlign: TextAlign.start, ), diff --git a/lib/src/datetime_picker_theme.dart b/lib/src/datetime_picker_theme.dart index e3f616f4..45782f1a 100644 --- a/lib/src/datetime_picker_theme.dart +++ b/lib/src/datetime_picker_theme.dart @@ -7,6 +7,7 @@ class DatePickerTheme with DiagnosticableTreeMixin { final TextStyle cancelStyle; final TextStyle doneStyle; final TextStyle itemStyle; + final int itemMaxLines; final Color backgroundColor; final Color? headerColor; @@ -18,6 +19,7 @@ class DatePickerTheme with DiagnosticableTreeMixin { this.cancelStyle = const TextStyle(color: Colors.black54, fontSize: 16), this.doneStyle = const TextStyle(color: Colors.blue, fontSize: 16), this.itemStyle = const TextStyle(color: Color(0xFF000046), fontSize: 18), + this.itemMaxLines = 1, this.backgroundColor = Colors.white, this.headerColor, this.containerHeight = 210.0,