Skip to content

Commit

Permalink
Merge pull request #99 from sivaprasadnk/master
Browse files Browse the repository at this point in the history
adding textStyle for month texts
  • Loading branch information
Macacoazul01 authored Jul 19, 2024
2 parents 19c0e35 + 0d9eb0a commit 9f0cb99
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "edu.hm.krivoj.monthpickerdialogexample"
minSdkVersion 20
minSdkVersion flutter.minSdkVersion
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=C:\flutter"
export "FLUTTER_APPLICATION_PATH=C:\Users\gian_\Desktop\month_picker_dialog\example"
export "FLUTTER_ROOT=C:\Users\HP\Downloads\flutter\flutter"
export "FLUTTER_APPLICATION_PATH=D:\SP\flutterProj\sample_projs\forked_repos\month_picker_dialog\example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
Expand Down
4 changes: 4 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ class _MyAppState extends State<MyApp> {
}); */
showMonthRangePicker(
context: context,
textStyle: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
),
firstDate: DateTime(DateTime.now().year - 5, 5),
lastDate: DateTime(DateTime.now().year + 8, 9),
initialDate: selectedDate ?? widget.initialDate,
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 @@ -43,9 +43,11 @@ class MonthpickerController {
required this.headerTitle,
required this.rangeMode,
required this.rangeList,
required this.textSyle,
});

//User defined variables
final TextStyle? textSyle;
final ThemeData theme;
final DateTime? firstDate, lastDate, initialDate;
final Locale? locale;
Expand Down
6 changes: 6 additions & 0 deletions lib/src/month_selector/month_button.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

import '/month_picker_dialog.dart';

///The button to be used on the grid of months.
Expand Down Expand Up @@ -88,6 +89,11 @@ class MonthButton extends StatelessWidget {
}

return TextButton.styleFrom(
textStyle: controller.textSyle ??
theme.textTheme.labelLarge ??
TextStyle(
fontWeight: FontWeight.bold,
),
foregroundColor: foregroundColor,
backgroundColor: backgroundColor,
shape: controller.buttonBorder,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/month_selector/month_year_grid.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';

import '/month_picker_dialog.dart';

///The month grid. It has all of the avaliable options to be selected.
Expand All @@ -25,6 +26,7 @@ class MonthYearGridBuilder extends StatelessWidget {
12,
(final int index) => MonthButton(
theme: controller.theme,

date: DateTime(
controller.localFirstDate != null
? controller.localFirstDate!.year + page
Expand Down
2 changes: 2 additions & 0 deletions lib/src/show_month_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import '/month_picker_dialog.dart';
///
Future<DateTime?> showMonthPicker({
required BuildContext context,
TextStyle? textStyle,
DateTime? initialDate,
DateTime? firstDate,
DateTime? lastDate,
Expand Down Expand Up @@ -110,6 +111,7 @@ Future<DateTime?> showMonthPicker({
'forceSelectedDate can only be used with dismissible = true');
final ThemeData theme = Theme.of(context);
final MonthpickerController controller = MonthpickerController(
textSyle: textStyle,
initialDate: initialDate,
firstDate: firstDate,
lastDate: lastDate,
Expand Down
4 changes: 4 additions & 0 deletions lib/src/show_month_range_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import '/month_picker_dialog.dart';
///
/// `monthStylePredicate:` allows you to individually customize each month.
///
/// `textStyle:` allows you to customize text-style of month.
///
/// `yearStylePredicate:` allows you to individually customize each year.
///
/// `capitalizeFirstLetter:` lets you control if your months names are capitalized or not.
Expand Down Expand Up @@ -73,6 +75,7 @@ import '/month_picker_dialog.dart';
///
Future<List<DateTime>?> showMonthRangePicker({
required BuildContext context,
TextStyle? textStyle,
DateTime? initialDate,
DateTime? firstDate,
DateTime? lastDate,
Expand Down Expand Up @@ -113,6 +116,7 @@ Future<List<DateTime>?> showMonthRangePicker({
'forceSelectedDate can only be used with dismissible = true');
final ThemeData theme = Theme.of(context);
final MonthpickerController controller = MonthpickerController(
textSyle: textStyle,
initialDate: initialDate,
firstDate: firstDate,
lastDate: lastDate,
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
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

import '/month_picker_dialog.dart';

///The button to be used on the grid of years.
Expand Down
8 changes: 8 additions & 0 deletions test/month_picker_dialog_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import 'package:month_picker_dialog/src/helpers/controller.dart';
void main() {
test('default_controller_test', () {
final MonthpickerController controller = MonthpickerController(
textSyle: ThemeData.fallback().textTheme.labelLarge ??
TextStyle(
fontWeight: FontWeight.bold,
),
capitalizeFirstLetter: false,
yearFirst: true,
roundedCornersRadius: 0,
Expand Down Expand Up @@ -39,6 +43,10 @@ void main() {

test('controller_with_parameters_test', () {
final MonthpickerController controller = MonthpickerController(
textSyle: ThemeData.fallback().textTheme.labelLarge ??
TextStyle(
fontWeight: FontWeight.bold,
),
capitalizeFirstLetter: false,
yearFirst: true,
roundedCornersRadius: 0,
Expand Down

0 comments on commit 9f0cb99

Please sign in to comment.