From df770c5c236c47c46293e6a00458f79466bce5a6 Mon Sep 17 00:00:00 2001 From: commitimpush Date: Tue, 15 Nov 2022 11:47:53 +0100 Subject: [PATCH] added customizable sizes for the views --- CHANGELOG.md | 3 +++ lib/src/date_time_picker.dart | 8 ++++---- lib/src/models/date_time_picker_theme.dart | 13 ++++++++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb63521..dc70be9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.2.0 +* Made date time picker height customizable + ## 1.1.0 * Added option to change background color of date picker. diff --git a/lib/src/date_time_picker.dart b/lib/src/date_time_picker.dart index 60854db..e857be6 100644 --- a/lib/src/date_time_picker.dart +++ b/lib/src/date_time_picker.dart @@ -220,9 +220,9 @@ class _DateTimePickerState extends State { child: DraggableScrollableSheet( controller: _dragController, snap: true, - minChildSize: 0.25, - initialChildSize: 0.25, - maxChildSize: 0.7, + minChildSize: _dateTimePickerController.theme.weekViewSize, + initialChildSize: _dateTimePickerController.theme.weekViewSize, + maxChildSize: _dateTimePickerController.theme.monthViewSize, builder: (context, scrollController) { double dragSize = _dragController.isAttached ? _dragController.size : 0; @@ -251,7 +251,7 @@ class _DateTimePickerState extends State { ), ], ), - child: dragSize < 0.3 + child: dragSize < _dateTimePickerController.theme.weekMonthTriggerSize ? WeekDateTimePickerSheet( dateTimePickerController: _dateTimePickerController, diff --git a/lib/src/models/date_time_picker_theme.dart b/lib/src/models/date_time_picker_theme.dart index 4c4ebe2..cebfa23 100644 --- a/lib/src/models/date_time_picker_theme.dart +++ b/lib/src/models/date_time_picker_theme.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_date_time_picker/flutter_date_time_picker.dart'; -import 'package:flutter_date_time_picker/src/models/date_time_picker_bar_theme.dart'; class DateTimePickerTheme { /// The [DateTimePickerTheme] to style [DateTimePicker] in. Define a custom shape for the dates and specifically style @@ -15,6 +14,9 @@ class DateTimePickerTheme { this.markedIndicatorColor, this.dateBoxShape = DateBoxShape.roundedRectangle, this.backgroundColor = Colors.white, + this.weekViewSize = 0.2, + this.monthViewSize = 0.6, + this.weekMonthTriggerSize = 0.3, this.baseTheme = const DateBoxBaseTheme( Colors.white, TextStyle(color: Colors.black), @@ -64,4 +66,13 @@ class DateTimePickerTheme { /// The color used for a background of the date picker. final Color backgroundColor; + + /// The size of the week view of the date picker. Enter a value between 0 and 1. + final double weekViewSize; + + /// The size of the month view of the date picker. Enter a value between 0 and 1 that's bigger than the weekViewSize. + final double monthViewSize; + + /// The position where the week view changes to month view and the other way around. Enter a value between 0 and 1 that's between the weekViewSize and the monthViewSize. + final double weekMonthTriggerSize; }