diff --git a/example/lib/main.dart b/example/lib/main.dart index 943aafd..130dba7 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -31,7 +31,21 @@ class DatePickerDemo extends StatelessWidget { @override Widget build(BuildContext context) { return DateTimePicker( - dateTimePickerTheme: const DateTimePickerTheme(), + dateTimePickerTheme: const DateTimePickerTheme( + markedIndicatorColor: Colors.red, + selectedTheme: DateBoxSelectedTheme( + Color(0x4BF44336), + TextStyle( + color: Colors.red, + ), + ), + highlightTheme: DateBoxHighlightTheme( + Colors.red, + TextStyle( + color: Colors.white, + ), + )), + markedDates: [DateTime(2022, 9, 6)], ); } } diff --git a/lib/src/date_time_picker.dart b/lib/src/date_time_picker.dart index b5ad742..9e6c4ec 100644 --- a/lib/src/date_time_picker.dart +++ b/lib/src/date_time_picker.dart @@ -7,107 +7,107 @@ import 'package:flutter_date_time_picker/src/widgets/month_date_time_picker.dart import 'package:flutter_date_time_picker/src/widgets/week_date_time_picker/week_date_time_picker_sheet.dart'; import 'package:intl/date_symbol_data_local.dart'; -/// A widget that displays a date picker from a sheet form the top of the screen. -/// This sheet displays initially displays a week but can be dragged down to show a full month. -/// Both views can be dragged sideways to show the next or previous week/month. -/// -/// Example: -/// ```dart -/// DatePicker( -/// dateTimePickerTheme: const DateTimePickerTheme() -/// initialDate: selectedDate, -/// highlightToday: true, -/// onTapDay: (date) { -/// setState(() { -/// selectedDate = date; -/// }); -/// }, -/// markedDates: [ -/// DateTime(2022, 3, 14), -/// ], -/// wrongTimeDialog: -/// AlertDialog( -/// title: const Text('Invalid Time'), -/// content: SingleChildScrollView( -/// child: ListBody( -/// children: const [ -/// Text( -/// 'The time you try to choose is diabled, try to pick another time.'), -/// ], -/// ), -/// ), -/// actions: [ -/// TextButton( -/// child: const Text('OK'), -/// onPressed: () { -/// Navigator.pop(context); -/// }, -/// ), -/// ], -/// ), -/// header: Container( -/// height: 100, -/// width: MediaQuery.of(context).size.width, -/// padding: const EdgeInsets.only(bottom: 10), -/// child: Row( -/// crossAxisAlignment: CrossAxisAlignment.end, -/// mainAxisAlignment: MainAxisAlignment.center, -/// children: [ -/// const SizedBox( -/// width: 160, -/// height: 34, -/// child: Center( -/// child: Text( -/// 'Personal calendar', -/// style: TextStyle( -/// fontSize: 16, -/// fontWeight: FontWeight.w900, -/// ), -/// ), -/// ), -/// ), -/// const SizedBox( -/// width: 4, -/// ), -/// Container( -/// width: 160, -/// height: 34, -/// decoration: BoxDecoration( -/// color: const Color(0xFF00273D), -/// borderRadius: const BorderRadius.all( -/// Radius.circular(10), -/// ), -/// boxShadow: [ -/// BoxShadow( -/// color: const Color(0xFF000000).withOpacity(0.50), -/// offset: const Offset(0, 6), -/// blurRadius: 9, -/// ), -/// ], -/// ), -/// child: const Center( -/// child: Text( -/// 'Work calendar', -/// style: TextStyle( -/// color: Colors.white, -/// fontSize: 16, -/// fontWeight: FontWeight.w900, -/// ), -/// ), -/// ), -/// ), -/// ], -/// ), -/// ), -/// child: Container( -/// margin: const EdgeInsets.only( -/// top: 195, -/// ), -/// child: HolidayRoster(), -/// ), -/// ), -///``` class DateTimePicker extends StatefulWidget { + /// A widget that displays a date picker from a sheet form the top of the screen. + /// This sheet displays initially displays a week but can be dragged down to show a full month. + /// Both views can be dragged sideways to show the next or previous week/month. + /// + /// Example: + /// ```dart + /// DatePicker( + /// dateTimePickerTheme: const DateTimePickerTheme() + /// initialDate: selectedDate, + /// highlightToday: true, + /// onTapDay: (date) { + /// setState(() { + /// selectedDate = date; + /// }); + /// }, + /// markedDates: [ + /// DateTime(2022, 3, 14), + /// ], + /// wrongTimeDialog: + /// AlertDialog( + /// title: const Text('Invalid Time'), + /// content: SingleChildScrollView( + /// child: ListBody( + /// children: const [ + /// Text( + /// 'The time you try to choose is diabled, try to pick another time.'), + /// ], + /// ), + /// ), + /// actions: [ + /// TextButton( + /// child: const Text('OK'), + /// onPressed: () { + /// Navigator.pop(context); + /// }, + /// ), + /// ], + /// ), + /// header: Container( + /// height: 100, + /// width: MediaQuery.of(context).size.width, + /// padding: const EdgeInsets.only(bottom: 10), + /// child: Row( + /// crossAxisAlignment: CrossAxisAlignment.end, + /// mainAxisAlignment: MainAxisAlignment.center, + /// children: [ + /// const SizedBox( + /// width: 160, + /// height: 34, + /// child: Center( + /// child: Text( + /// 'Personal calendar', + /// style: TextStyle( + /// fontSize: 16, + /// fontWeight: FontWeight.w900, + /// ), + /// ), + /// ), + /// ), + /// const SizedBox( + /// width: 4, + /// ), + /// Container( + /// width: 160, + /// height: 34, + /// decoration: BoxDecoration( + /// color: const Color(0xFF00273D), + /// borderRadius: const BorderRadius.all( + /// Radius.circular(10), + /// ), + /// boxShadow: [ + /// BoxShadow( + /// color: const Color(0xFF000000).withOpacity(0.50), + /// offset: const Offset(0, 6), + /// blurRadius: 9, + /// ), + /// ], + /// ), + /// child: const Center( + /// child: Text( + /// 'Work calendar', + /// style: TextStyle( + /// color: Colors.white, + /// fontSize: 16, + /// fontWeight: FontWeight.w900, + /// ), + /// ), + /// ), + /// ), + /// ], + /// ), + /// ), + /// child: Container( + /// margin: const EdgeInsets.only( + /// top: 195, + /// ), + /// child: HolidayRoster(), + /// ), + /// ), + ///``` DateTimePicker({ this.dateTimePickerTheme = const DateTimePickerTheme(), this.header, diff --git a/lib/src/widgets/month_date_time_picker.dart/month_date_time_picker.dart b/lib/src/widgets/month_date_time_picker.dart/month_date_time_picker.dart index e9702f9..593fb28 100644 --- a/lib/src/widgets/month_date_time_picker.dart/month_date_time_picker.dart +++ b/lib/src/widgets/month_date_time_picker.dart/month_date_time_picker.dart @@ -61,13 +61,6 @@ class MonthDateTimePicker extends StatelessWidget { ? null : () async { TimeOfDay? timeOfDay; - // await dateTimePickerController.getDragController().animateTo( - // 0.26, - // duration: const Duration( - // milliseconds: 350, - // ), - // curve: Curves.ease, - // ); DateTime selectedDate = DateTime( date.year, @@ -131,7 +124,9 @@ class MonthDateTimePicker extends StatelessWidget { width: monthDateBoxSize / 4, height: monthDateBoxSize / 4, decoration: BoxDecoration( - color: Theme.of(context).indicatorColor, + color: dateTimePickerController + .theme.markedIndicatorColor ?? + Theme.of(context).indicatorColor, borderRadius: BorderRadius.circular( (monthDateBoxSize / 4) * 2), ), diff --git a/lib/src/widgets/month_date_time_picker.dart/month_date_time_picker_sheet.dart b/lib/src/widgets/month_date_time_picker.dart/month_date_time_picker_sheet.dart index af1fb05..5a80632 100644 --- a/lib/src/widgets/month_date_time_picker.dart/month_date_time_picker_sheet.dart +++ b/lib/src/widgets/month_date_time_picker.dart/month_date_time_picker_sheet.dart @@ -30,10 +30,8 @@ class MonthDateTimePickerSheet extends StatelessWidget { DateFormat.yMMMM().format( dateTimePickerController.browsingDate, ), - style: Theme.of(context) - .textTheme - .headlineMedium! - .copyWith(color: Colors.black), + style: dateTimePickerController.theme.baseTheme.textStyle! + .copyWith(fontSize: 25), ), SizedBox( width: MediaQuery.of(context).size.width, diff --git a/lib/src/widgets/week_date_time_picker/week_date_time_picker.dart b/lib/src/widgets/week_date_time_picker/week_date_time_picker.dart index eecff48..9cf8778 100644 --- a/lib/src/widgets/week_date_time_picker/week_date_time_picker.dart +++ b/lib/src/widgets/week_date_time_picker/week_date_time_picker.dart @@ -38,13 +38,6 @@ class WeekDateTimePicker extends StatelessWidget { ? null : () async { TimeOfDay? timeOfDay; - // await dateTimePickerController.getDragController().animateTo( - // 0.26, - // duration: const Duration( - // milliseconds: 350, - // ), - // curve: Curves.ease, - // ); DateTime selectedDate = date.daysOfWeek()[index]; @@ -62,7 +55,8 @@ class WeekDateTimePicker extends StatelessWidget { )) { showDialog( context: context, - builder: (context) => dateTimePickerController.wrongTimeDialog!, + builder: (context) => + dateTimePickerController.wrongTimeDialog!, ); } } @@ -89,7 +83,7 @@ class WeekDateTimePicker extends StatelessWidget { date.daysOfWeek().elementAt(index), ) .toUpperCase()[0], - style: Theme.of(context).textTheme.titleSmall, + style: dateTimePickerController.theme.baseTheme.textStyle, ), const Spacer(), Container( diff --git a/lib/src/widgets/week_date_time_picker/week_date_time_picker_sheet.dart b/lib/src/widgets/week_date_time_picker/week_date_time_picker_sheet.dart index 3e91aa1..d7bf1ce 100644 --- a/lib/src/widgets/week_date_time_picker/week_date_time_picker_sheet.dart +++ b/lib/src/widgets/week_date_time_picker/week_date_time_picker_sheet.dart @@ -45,7 +45,8 @@ class WeekDateTimePickerSheet extends StatelessWidget { if (showHeader) ...[ Text( getDateHeader(), - style: Theme.of(context).textTheme.headlineSmall, + style: dateTimePickerController.theme.baseTheme.textStyle! + .copyWith(fontSize: 9), ), const SizedBox( height: 10,