Skip to content

Commit

Permalink
Merge pull request #77 from byga-net/master
Browse files Browse the repository at this point in the history
Add textScaleFactor as optional parameter
  • Loading branch information
Macacoazul01 authored Nov 3, 2023
2 parents 037eca1 + 737fd0e commit 9922b0d
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 30 deletions.
55 changes: 29 additions & 26 deletions lib/month_picker_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,37 +85,40 @@ Future<DateTime?> showMonthPicker({
bool forceSelectedDate = false,
int animationMilliseconds = 450,
bool hideHeaderRow = false,
double? textScaleFactor,
}) async {
assert(forceSelectedDate == dismissible || !forceSelectedDate,
'forceSelectedDate can only be used with dismissible = true');
final ThemeData theme = Theme.of(context);
final MonthpickerController controller = MonthpickerController(
initialDate: initialDate,
firstDate: firstDate,
lastDate: lastDate,
locale: locale,
selectableMonthPredicate: selectableMonthPredicate,
monthStylePredicate: monthStylePredicate,
yearStylePredicate: yearStylePredicate,
capitalizeFirstLetter: capitalizeFirstLetter,
headerColor: headerColor,
headerTextColor: headerTextColor,
selectedMonthBackgroundColor: selectedMonthBackgroundColor,
selectedMonthTextColor: selectedMonthTextColor,
unselectedMonthTextColor: unselectedMonthTextColor,
selectedMonthPadding: selectedMonthPadding,
backgroundColor: backgroundColor,
confirmWidget: confirmWidget,
cancelWidget: cancelWidget,
customHeight: customHeight,
customWidth: customWidth,
yearFirst: yearFirst,
roundedCornersRadius: roundedCornersRadius,
forceSelectedDate: forceSelectedDate,
animationMilliseconds: animationMilliseconds,
hideHeaderRow: hideHeaderRow,
theme: theme,
useMaterial3: theme.useMaterial3);
initialDate: initialDate,
firstDate: firstDate,
lastDate: lastDate,
locale: locale,
selectableMonthPredicate: selectableMonthPredicate,
monthStylePredicate: monthStylePredicate,
yearStylePredicate: yearStylePredicate,
capitalizeFirstLetter: capitalizeFirstLetter,
headerColor: headerColor,
headerTextColor: headerTextColor,
selectedMonthBackgroundColor: selectedMonthBackgroundColor,
selectedMonthTextColor: selectedMonthTextColor,
unselectedMonthTextColor: unselectedMonthTextColor,
selectedMonthPadding: selectedMonthPadding,
backgroundColor: backgroundColor,
confirmWidget: confirmWidget,
cancelWidget: cancelWidget,
customHeight: customHeight,
customWidth: customWidth,
yearFirst: yearFirst,
roundedCornersRadius: roundedCornersRadius,
forceSelectedDate: forceSelectedDate,
animationMilliseconds: animationMilliseconds,
hideHeaderRow: hideHeaderRow,
theme: theme,
useMaterial3: theme.useMaterial3,
textScaleFactor: textScaleFactor
);
final DateTime? dialogDate = await showDialog<DateTime>(
context: context,
barrierDismissible: dismissible,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/helpers/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class MonthpickerController {
required this.hideHeaderRow,
required this.theme,
required this.useMaterial3,
required this.textScaleFactor,
});

//User defined variables
Expand All @@ -57,6 +58,7 @@ class MonthpickerController {
final double? customHeight, customWidth;
final double roundedCornersRadius, selectedMonthPadding;
final int animationMilliseconds;
final double? textScaleFactor;

//local variables
final GlobalKey<YearSelectorState> yearSelectorState = GlobalKey();
Expand Down
13 changes: 10 additions & 3 deletions lib/src/month_picker_widgets/button_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@ class PickerButtonBar extends StatelessWidget {
children: <Widget>[
TextButton(
onPressed: () => controller.cancelFunction(context),
child:
controller.cancelWidget ?? Text(localizations.cancelButtonLabel),
child: controller.cancelWidget ??
Text(
localizations.cancelButtonLabel,
textScaleFactor: controller.textScaleFactor,
),
),
TextButton(
onPressed: () => controller.okFunction(context),
child: controller.confirmWidget ?? Text(localizations.okButtonLabel),
child: controller.confirmWidget ??
Text(
localizations.okButtonLabel,
textScaleFactor: controller.textScaleFactor,
),
)
],
);
Expand Down
4 changes: 4 additions & 0 deletions lib/src/month_picker_widgets/header/header_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class HeaderRow extends StatelessWidget {
DateFormat.y(localeString)
.format(DateTime(monthProvider.pageLimit.upLimit)),
style: headline5,
textScaleFactor: controller.textScaleFactor,
),
),
HeaderArrows(
Expand All @@ -60,15 +61,18 @@ class HeaderRow extends StatelessWidget {
DateFormat.y(localeString)
.format(DateTime(yearProvider.pageLimit.upLimit)),
style: headline5,
textScaleFactor: controller.textScaleFactor,
),
Text(
'-',
style: headline5,
textScaleFactor: controller.textScaleFactor,
),
Text(
DateFormat.y(localeString)
.format(DateTime(yearProvider.pageLimit.downLimit)),
style: headline5,
textScaleFactor: controller.textScaleFactor,
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class HeaderSelectedDate extends StatelessWidget {
: DateFormat.yMMM(localeString)
.format(controller.selectedDate)
.toLowerCase(),
textScaleFactor: controller.textScaleFactor,
style: controller.headerTextColor == null
? theme.primaryTextTheme.titleMedium
: theme.primaryTextTheme.titleMedium!
Expand Down
1 change: 1 addition & 0 deletions lib/src/month_selector/month_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class MonthButton extends StatelessWidget {
DateFormat.MMM(localeString).format(date))!
: DateFormat.MMM(localeString).format(date).toLowerCase(),
style: monthStyle.textStyle?.resolve({}),
textScaleFactor: controller.textScaleFactor,
),
),
);
Expand Down
1 change: 1 addition & 0 deletions lib/src/year_selector/year_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class YearButton extends StatelessWidget {
child: Text(
DateFormat.y(localeString).format(DateTime(year)),
style: yearStyle.textStyle?.resolve({}),
textScaleFactor: controller.textScaleFactor,
),
),
);
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: 2.1.0
version: 2.1.1
homepage: https://github.com/hmkrivoj/month_picker_dialog

environment:
Expand Down

0 comments on commit 9922b0d

Please sign in to comment.