diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b8dca9..eb11255 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 5.0.0-dev.4 - 2024-08-02 +- Added `headerSettings.headerPadding`and `headerSettings.hideHeaderArrows`. +- Fixed `monthTextStyle` and `yearTextStyle`. + ## 5.0.0-dev.3 - 2024-08-02 - Added `showYearPicker` function to the package. Now its possible to return only a year. - Updated sample. diff --git a/example/lib/main.dart b/example/lib/main.dart index 6792617..11e4013 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -184,11 +184,11 @@ class _MyAppState extends State { unselectedMonthsTextColor: Colors.black, currentMonthTextColor: Colors.green, yearTextStyle: const TextStyle( - color: Colors.amber, + fontSize: 10, ), monthTextStyle: const TextStyle( - color: Colors.red, fontWeight: FontWeight.bold, + fontSize: 18, ), ), ), diff --git a/lib/src/helpers/settings/buttons_settings.dart b/lib/src/helpers/settings/buttons_settings.dart index 3822ed5..87798da 100644 --- a/lib/src/helpers/settings/buttons_settings.dart +++ b/lib/src/helpers/settings/buttons_settings.dart @@ -20,8 +20,6 @@ class PickerButtonsSettings { currentYearTextColor = currentYearTextColor ?? currentMonthTextColor, yearTextStyle = yearTextStyle ?? monthTextStyle; - //TODO implement monthTextStyle, yearTextStyle - /// The text style of all months on the page. /// /// default: `null` diff --git a/lib/src/helpers/settings/header_settings.dart b/lib/src/helpers/settings/header_settings.dart index 445655b..db8268d 100644 --- a/lib/src/helpers/settings/header_settings.dart +++ b/lib/src/helpers/settings/header_settings.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; class PickerHeaderSettings { const PickerHeaderSettings({ this.hideHeaderRow = false, + this.hideHeaderArrows = false, this.previousIcon = Icons.keyboard_arrow_up, this.nextIcon = Icons.keyboard_arrow_down, this.headerIconsSize, @@ -12,6 +13,7 @@ class PickerHeaderSettings { this.headerSelectedIntervalTextStyle, this.headerCurrentPageTextStyle, this.titleSpacing = 5, + this.headerPadding = const EdgeInsets.all(16.0), }); /// Hides the row with the arrows + years/months page range from the header, forcing the user to scroll to change the page. @@ -19,6 +21,11 @@ class PickerHeaderSettings { /// default: `false` final bool hideHeaderRow; + /// Hides only the arrows part of the header, forcing the user to scroll to change the page. + /// + /// default: `false` + final bool hideHeaderArrows; + /// The icon that will make the calendar to go back one page when clicked. /// /// default: `Icons.keyboard_arrow_up` @@ -60,6 +67,11 @@ class PickerHeaderSettings { /// /// default: `5` final double titleSpacing; + + /// The header padding. + /// + /// default: `EdgeInsets.all(16.0)` + final EdgeInsets headerPadding; } ///The default settings for the Header style. diff --git a/lib/src/month_picker_widgets/header/header.dart b/lib/src/month_picker_widgets/header/header.dart index 50bc19b..31e42ac 100644 --- a/lib/src/month_picker_widgets/header/header.dart +++ b/lib/src/month_picker_widgets/header/header.dart @@ -44,7 +44,8 @@ class PickerHeader extends StatelessWidget { ), ), child: Padding( - padding: const EdgeInsets.all(16.0), + padding: + controller.monthPickerDialogSettings.headerSettings.headerPadding, child: controller.monthPickerDialogSettings.headerSettings.hideHeaderRow ? Row( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/src/month_picker_widgets/header/header_row.dart b/lib/src/month_picker_widgets/header/header_row.dart index 821995e..c35d7ca 100644 --- a/lib/src/month_picker_widgets/header/header_row.dart +++ b/lib/src/month_picker_widgets/header/header_row.dart @@ -54,19 +54,21 @@ class HeaderRow extends StatelessWidget { textScaler: scaler, ), ), - HeaderArrows( - arrowcolors: arrowcolors, - onUpButtonPressed: controller.onUpButtonPressed, - onDownButtonPressed: controller.onDownButtonPressed, - downState: monthProvider.enableState.downState, - upState: monthProvider.enableState.upState, - arrowSize: controller - .monthPickerDialogSettings.headerSettings.headerIconsSize, - previousIcon: controller - .monthPickerDialogSettings.headerSettings.previousIcon, - nextIcon: - controller.monthPickerDialogSettings.headerSettings.nextIcon, - ), + if (!controller + .monthPickerDialogSettings.headerSettings.hideHeaderArrows) + HeaderArrows( + arrowcolors: arrowcolors, + onUpButtonPressed: controller.onUpButtonPressed, + onDownButtonPressed: controller.onDownButtonPressed, + downState: monthProvider.enableState.downState, + upState: monthProvider.enableState.upState, + arrowSize: controller + .monthPickerDialogSettings.headerSettings.headerIconsSize, + previousIcon: controller + .monthPickerDialogSettings.headerSettings.previousIcon, + nextIcon: controller + .monthPickerDialogSettings.headerSettings.nextIcon, + ), ] : [ Row( @@ -91,19 +93,21 @@ class HeaderRow extends StatelessWidget { ), ], ), - HeaderArrows( - arrowcolors: arrowcolors, - onUpButtonPressed: controller.onUpButtonPressed, - onDownButtonPressed: controller.onDownButtonPressed, - downState: yearProvider.enableState.downState, - upState: yearProvider.enableState.upState, - arrowSize: controller - .monthPickerDialogSettings.headerSettings.headerIconsSize, - previousIcon: controller - .monthPickerDialogSettings.headerSettings.previousIcon, - nextIcon: - controller.monthPickerDialogSettings.headerSettings.nextIcon, - ), + if (!controller + .monthPickerDialogSettings.headerSettings.hideHeaderArrows) + HeaderArrows( + arrowcolors: arrowcolors, + onUpButtonPressed: controller.onUpButtonPressed, + onDownButtonPressed: controller.onDownButtonPressed, + downState: yearProvider.enableState.downState, + upState: yearProvider.enableState.upState, + arrowSize: controller + .monthPickerDialogSettings.headerSettings.headerIconsSize, + previousIcon: controller + .monthPickerDialogSettings.headerSettings.previousIcon, + nextIcon: controller + .monthPickerDialogSettings.headerSettings.nextIcon, + ), ]; return portrait ? Row( diff --git a/lib/src/month_selector/month_button.dart b/lib/src/month_selector/month_button.dart index b1ab08e..fd9bbc6 100644 --- a/lib/src/month_selector/month_button.dart +++ b/lib/src/month_selector/month_button.dart @@ -51,9 +51,6 @@ class MonthButton extends StatelessWidget { /// If not provided, the customization will be built from the app's theme. ButtonStyle _buildDefaultMonthStyle() { Color? backgroundColor; - //TODO fix. Breaks predicate and range in the way it is today. - - // TextStyle? textStyle = controller.monthPickerDialogSettings.buttonsSettings.monthTextStyle ?? theme.textTheme.labelLarge; Color? foregroundColor = controller .monthPickerDialogSettings.buttonsSettings.unselectedMonthsTextColor; final List selectedDates = [controller.selectedDate]; @@ -101,7 +98,8 @@ class MonthButton extends StatelessWidget { } return TextButton.styleFrom( - //textStyle: textStyle, + textStyle: + controller.monthPickerDialogSettings.buttonsSettings.monthTextStyle, foregroundColor: foregroundColor, backgroundColor: backgroundColor, shape: controller.monthPickerDialogSettings.buttonsSettings.buttonBorder, @@ -135,7 +133,6 @@ class MonthButton extends StatelessWidget { ? toBeginningOfSentenceCase( DateFormat.MMM(localeString).format(date))! : DateFormat.MMM(localeString).format(date).toLowerCase(), - style: monthStyle.textStyle?.resolve({}), textScaler: controller.monthPickerDialogSettings.dialogSettings .textScaleFactor != null diff --git a/lib/src/year_selector/year_button.dart b/lib/src/year_selector/year_button.dart index 499d08b..cbec317 100644 --- a/lib/src/year_selector/year_button.dart +++ b/lib/src/year_selector/year_button.dart @@ -61,6 +61,8 @@ class YearButton extends StatelessWidget { .buttonsSettings.selectedMonthBackgroundColor ?? theme.colorScheme.secondary; final ButtonStyle yearStyle = TextButton.styleFrom( + textStyle: + controller.monthPickerDialogSettings.buttonsSettings.yearTextStyle, foregroundColor: isTheSelectedYear ? theme.textTheme.labelLarge! .copyWith( @@ -107,7 +109,6 @@ class YearButton extends StatelessWidget { style: yearStyle, child: Text( DateFormat.y(localeString).format(DateTime(year)), - style: yearStyle.textStyle?.resolve({}), textScaler: controller.monthPickerDialogSettings.dialogSettings .textScaleFactor != null diff --git a/pubspec.yaml b/pubspec.yaml index 947c9fd..3b09bfb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: month_picker_dialog description: Internationalized dialog for picking a single month from an infinite list of years. -version: 5.0.0-dev.3 +version: 5.0.0-dev.4 homepage: https://github.com/hmkrivoj/month_picker_dialog environment: