Skip to content

Commit

Permalink
5.0.0-dev.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Macacoazul01 committed Aug 2, 2024
1 parent a47b107 commit 25db175
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 38 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ class _MyAppState extends State<MyApp> {
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,
),
),
),
Expand Down
2 changes: 0 additions & 2 deletions lib/src/helpers/settings/buttons_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
12 changes: 12 additions & 0 deletions lib/src/helpers/settings/header_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -12,13 +13,19 @@ 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.
///
/// 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`
Expand Down Expand 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.
Expand Down
3 changes: 2 additions & 1 deletion lib/src/month_picker_widgets/header/header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
56 changes: 30 additions & 26 deletions lib/src/month_picker_widgets/header/header_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
]
: <Widget>[
Row(
Expand All @@ -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(
Expand Down
7 changes: 2 additions & 5 deletions lib/src/month_selector/month_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<DateTime> selectedDates = [controller.selectedDate];
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/src/year_selector/year_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 25db175

Please sign in to comment.