Skip to content

Commit

Permalink
Merge pull request #92 from AppFacile/master
Browse files Browse the repository at this point in the history
New Parameters: outlinedBorder and outlinedBorder
  • Loading branch information
Macacoazul01 committed May 13, 2024
2 parents bd25191 + d53f0b9 commit 7309a7a
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ class _MyAppState extends State<MyApp> {
roundedCornersRadius: 20,
yearFirst: true,
backgroundColor: Colors.blueGrey[50],
outlinedBorder: RoundedRectangleBorder(),
headerTitle: Text('Month Picker Dialog'),
// customDivider: Divider(
// color: Colors.black,
// endIndent: 25,
Expand Down
4 changes: 4 additions & 0 deletions lib/src/helpers/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class MonthpickerController {
this.customDivider,
required this.blockScrolling,
required this.dialogBorderSide,
required this.outlinedBorder,
required this.headerTitle,
});

//User defined variables
Expand Down Expand Up @@ -66,6 +68,8 @@ class MonthpickerController {
final double roundedCornersRadius, selectedMonthPadding, customWidth;
final int animationMilliseconds;
final BorderSide dialogBorderSide;
final OutlinedBorder outlinedBorder;
final Widget? headerTitle;

//local variables
final GlobalKey<YearSelectorState> yearSelectorState = GlobalKey();
Expand Down
1 change: 1 addition & 0 deletions lib/src/month_picker_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class MonthPickerDialogState extends State<MonthPickerDialog> {
onSelectYear: _onSelectYear,
portrait: portrait,
controller: widget.controller,
headerTitle: widget.controller.headerTitle,
);

return Theme(
Expand Down
3 changes: 3 additions & 0 deletions lib/src/month_picker_widgets/header/header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ class PickerHeader extends StatelessWidget {
required this.onSelectYear,
required this.portrait,
required this.controller,
required this.headerTitle,
});
final ThemeData theme;
final String localeString;
final bool isMonthSelector, portrait;
final VoidCallback onSelectYear;
final MonthpickerController controller;
final Widget? headerTitle;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -52,6 +54,7 @@ class PickerHeader extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (headerTitle != null) headerTitle!,
HeaderSelectedDate(
theme: theme,
localeString: localeString,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/month_selector/month_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class MonthButton extends StatelessWidget {
date.year == controller.selectedDate.year
? backgroundColor
: null,
shape: const CircleBorder(),
shape: controller.outlinedBorder,
);
return monthStyle;
}
Expand Down
7 changes: 6 additions & 1 deletion lib/src/show_month_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ Future<DateTime?> showMonthPicker(
bool forcePortrait = false,
Widget? customDivider,
bool blockScrolling = true,
BorderSide dialogBorderSide = BorderSide.none}) async {
BorderSide dialogBorderSide = BorderSide.none,
OutlinedBorder outlinedBorder = const CircleBorder(),
Widget? headerTitle = null,
}) async {
assert(forceSelectedDate == dismissible || !forceSelectedDate,
'forceSelectedDate can only be used with dismissible = true');
final ThemeData theme = Theme.of(context);
Expand Down Expand Up @@ -136,6 +139,8 @@ Future<DateTime?> showMonthPicker(
customDivider: customDivider,
blockScrolling: blockScrolling,
dialogBorderSide: dialogBorderSide,
outlinedBorder: outlinedBorder,
headerTitle: headerTitle,
);
final DateTime? dialogDate = await showDialog<DateTime>(
context: context,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/year_selector/year_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class YearButton extends StatelessWidget {
: controller.unselectedMonthTextColor,
backgroundColor:
year == controller.selectedDate.year ? backgroundColor : null,
shape: const CircleBorder(),
shape: controller.outlinedBorder,
);
return yearStyle;
}
Expand Down
4 changes: 4 additions & 0 deletions test/month_picker_dialog_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ void main() {
customWidth: 320,
blockScrolling: false,
dialogBorderSide: BorderSide.none,
outlinedBorder: const CircleBorder(),
headerTitle: null,
);
controller.initialize();
expect(controller.yearItemCount, 9999);
Expand Down Expand Up @@ -53,6 +55,8 @@ void main() {
forcePortrait: true,
blockScrolling: false,
dialogBorderSide: BorderSide.none,
outlinedBorder: const CircleBorder(),
headerTitle: null,
);
controller.initialize();
expect(controller.yearItemCount, 6);
Expand Down

0 comments on commit 7309a7a

Please sign in to comment.