added customizable sizes for the views

This commit is contained in:
commitimpush 2022-11-15 11:47:53 +01:00
parent a407f8dcbd
commit df770c5c23
3 changed files with 19 additions and 5 deletions

View file

@ -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.

View file

@ -220,9 +220,9 @@ class _DateTimePickerState extends State<DateTimePicker> {
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<DateTimePicker> {
),
],
),
child: dragSize < 0.3
child: dragSize < _dateTimePickerController.theme.weekMonthTriggerSize
? WeekDateTimePickerSheet(
dateTimePickerController:
_dateTimePickerController,

View file

@ -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;
}