Skip to content

增加两个设置项 #266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
19 changes: 18 additions & 1 deletion lib/flutter_datetime_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> extends PopupRoute<T> {
_DatePickerRoute({
this.showTitleActions,
Expand All @@ -194,6 +207,7 @@ class _DatePickerRoute<T> extends PopupRoute<T> {
DatePickerTheme? theme,
this.barrierLabel,
this.locale,
this.selectionOverlay = const _DefaultSelectionOverlay(),
RouteSettings? settings,
BasePickerModel? pickerModel,
}) : this.pickerModel = pickerModel ?? DatePickerModel(),
Expand All @@ -207,6 +221,7 @@ class _DatePickerRoute<T> extends PopupRoute<T> {
final LocaleType? locale;
final DatePickerTheme theme;
final BasePickerModel pickerModel;
final Widget? selectionOverlay;

@override
Duration get transitionDuration => const Duration(milliseconds: 200);
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand All @@ -385,6 +401,7 @@ class _DatePickerState extends State<_DatePickerComponent> {
alignment: Alignment.center,
child: Text(
content,
maxLines: theme.itemMaxLines,
style: theme.itemStyle,
textAlign: TextAlign.start,
),
Expand Down
2 changes: 2 additions & 0 deletions lib/src/datetime_picker_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
Expand Down