diff --git a/.metadata b/.metadata deleted file mode 100644 index e7011f6..0000000 --- a/.metadata +++ /dev/null @@ -1,10 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: f1875d570e39de09040c8f79aa13cc56baab8db1 - channel: stable - -project_type: package diff --git a/CHANGELOG.md b/CHANGELOG.md index 3eb0f80..59f7f6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 4.1.0 + +- Fixed a bug where there would be an extra line for the week after the current month in the month_date_time_picker +- Added more customization options for the container around the date_time_picker.dart + ## 4.0.1 - Added an extra widget builder to add more customizability, for example to add 'today' and 'close' buttons. diff --git a/example/.gitignore b/example/.gitignore index a8e938c..8104aef 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -45,3 +45,6 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release + + +pubspec.lock \ No newline at end of file diff --git a/example/pubspec.lock b/example/pubspec.lock deleted file mode 100644 index c39c586..0000000 --- a/example/pubspec.lock +++ /dev/null @@ -1,209 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - async: - dependency: transitive - description: - name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" - source: hosted - version: "2.11.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - characters: - dependency: transitive - description: - name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.dev" - source: hosted - version: "1.3.0" - clock: - dependency: transitive - description: - name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 - url: "https://pub.dev" - source: hosted - version: "1.17.2" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be - url: "https://pub.dev" - source: hosted - version: "1.0.5" - fake_async: - dependency: transitive - description: - name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" - source: hosted - version: "1.3.1" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_date_time_picker: - dependency: "direct main" - description: - path: ".." - relative: true - source: path - version: "4.0.0" - flutter_lints: - dependency: "direct dev" - description: - name: flutter_lints - sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4" - url: "https://pub.dev" - source: hosted - version: "2.0.2" - flutter_localizations: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - intl: - dependency: "direct main" - description: - name: intl - sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" - url: "https://pub.dev" - source: hosted - version: "0.18.1" - lints: - dependency: transitive - description: - name: lints - sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - matcher: - dependency: transitive - description: - name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" - url: "https://pub.dev" - source: hosted - version: "0.12.16" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" - url: "https://pub.dev" - source: hosted - version: "0.5.0" - meta: - dependency: transitive - description: - name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" - url: "https://pub.dev" - source: hosted - version: "1.9.1" - path: - dependency: transitive - description: - name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" - url: "https://pub.dev" - source: hosted - version: "1.8.3" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" - url: "https://pub.dev" - source: hosted - version: "1.10.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 - url: "https://pub.dev" - source: hosted - version: "1.11.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - string_scanner: - dependency: transitive - description: - name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" - url: "https://pub.dev" - source: hosted - version: "0.6.0" - vector_math: - dependency: transitive - description: - name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" - source: hosted - version: "2.1.4" - web: - dependency: transitive - description: - name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 - url: "https://pub.dev" - source: hosted - version: "0.1.4-beta" -sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" - flutter: ">=2.0.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 9ab7d5f..68d581b 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: path: ../ flutter_localizations: sdk: flutter - intl: ^0.18.0 # Add this line + intl: any dev_dependencies: flutter_test: diff --git a/lib/src/models/date_time_picker_theme.dart b/lib/src/models/date_time_picker_theme.dart index 1e234d7..b919aeb 100644 --- a/lib/src/models/date_time_picker_theme.dart +++ b/lib/src/models/date_time_picker_theme.dart @@ -28,6 +28,9 @@ class DateTimePickerTheme { this.monthViewSize = 0.6, this.weekMonthTriggerSize = 0.3, this.shapeDecoration, + this.border, + this.boxShadows, + this.borderRadius, this.baseTheme = const DateBoxTheme( backgroundColor: Colors.white, textStyle: TextStyle(color: Colors.black)), @@ -121,4 +124,13 @@ class DateTimePickerTheme { /// The padding surrounding the calendar final EdgeInsetsGeometry calenderPadding; + + /// Border for the container where the date picker is placed in + final Border? border; + + /// BorderRadius for the container where the date picker is placed in + final BorderRadiusGeometry? borderRadius; + + /// BoxShadow for the container where the date picker is placed in + final List? boxShadows; } diff --git a/lib/src/widgets/date_time_picker/date_time_picker.dart b/lib/src/widgets/date_time_picker/date_time_picker.dart index 40f286b..40b8a5f 100644 --- a/lib/src/widgets/date_time_picker/date_time_picker.dart +++ b/lib/src/widgets/date_time_picker/date_time_picker.dart @@ -116,13 +116,16 @@ class _DateTimePickerState extends State { decoration: (widget.theme.shapeDecoration == null) ? BoxDecoration( color: widget.theme.backgroundColor, - borderRadius: const BorderRadius.all(Radius.circular(16)), - boxShadow: [ - BoxShadow( - blurRadius: 5, - color: Colors.black.withOpacity(0.25), - ), - ], + borderRadius: widget.theme.borderRadius ?? + const BorderRadius.all(Radius.circular(16)), + border: widget.theme.border, + boxShadow: widget.theme.boxShadows ?? + [ + BoxShadow( + blurRadius: 5, + color: Colors.black.withOpacity(0.25), + ), + ], ) : ShapeDecoration( shape: widget.theme.shapeDecoration!.shape, diff --git a/lib/src/widgets/overlay_date_time_picker/date_picker.dart b/lib/src/widgets/overlay_date_time_picker/date_picker.dart index c2b2188..add7b0a 100644 --- a/lib/src/widgets/overlay_date_time_picker/date_picker.dart +++ b/lib/src/widgets/overlay_date_time_picker/date_picker.dart @@ -45,8 +45,8 @@ class DatePicker extends StatelessWidget { addedIndex = DateTime.daysPerWeek; } - int length = DateTime(date.year, date.month).daysInMonth() + daysToSkip; - int daysToAdd = DateTime.daysPerWeek - length % DateTime.daysPerWeek; + int length = DateTime(date.year, date.month).daysInMonth() + daysToSkip % 7; + int daysToAdd = (DateTime.daysPerWeek - length) % DateTime.daysPerWeek; return Column( children: [ if (showWeekDays) ...[ @@ -66,14 +66,11 @@ class DatePicker extends StatelessWidget { child: Padding( padding: const EdgeInsets.all(2.0), child: Text( - // The first day in November 2022 is monday - // We use it to properly show monday as the first day and sunday as the last one - date, - style: weekdayTextStyle - // .copyWith( - // fontStyle: FontStyle.italic, - // fontWeight: FontWeight.w200), - ), + // The first day in November 2022 is monday + // We use it to properly show monday as the first day and sunday as the last one + date, + style: weekdayTextStyle, + ), ), ), ); diff --git a/lib/src/widgets/overlay_date_time_picker/overlay.dart b/lib/src/widgets/overlay_date_time_picker/overlay.dart index 394fcae..3c7c3b8 100644 --- a/lib/src/widgets/overlay_date_time_picker/overlay.dart +++ b/lib/src/widgets/overlay_date_time_picker/overlay.dart @@ -96,38 +96,35 @@ class _OverlayDateTimeContentState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - (widget.onPreviousPageButtonChild != null) - ? widget.onPreviousPageButtonChild!( - (widget.dateTimeConstraint.inMonthRange(previousDate)) - ? _goToPreviousPage - : null, - ) - : IconButton( - onPressed: - (widget.dateTimeConstraint.inMonthRange(previousDate)) - ? _goToPreviousPage - : null, - icon: prevIcon, - iconSize: widget.theme.paginationSize, - ), + widget.onPreviousPageButtonChild?.call( + (widget.dateTimeConstraint.inMonthRange(previousDate)) + ? _goToPreviousPage + : null, + ) ?? + IconButton( + onPressed: + (widget.dateTimeConstraint.inMonthRange(previousDate)) + ? _goToPreviousPage + : null, + icon: prevIcon, + iconSize: widget.theme.paginationSize, + ), Text( monthText, style: widget.theme.barTheme.textStyle, ), - (widget.onNextPageButtonChild != null) - ? widget.onNextPageButtonChild!( - (widget.dateTimeConstraint.inMonthRange(nextDate)) - ? _goToNextPage - : null, - ) - : IconButton( - onPressed: - (widget.dateTimeConstraint.inMonthRange(nextDate)) - ? _goToNextPage - : null, - icon: nextIcon, - iconSize: widget.theme.paginationSize, - ), + widget.onNextPageButtonChild?.call( + (widget.dateTimeConstraint.inMonthRange(nextDate)) + ? _goToNextPage + : null, + ) ?? + IconButton( + onPressed: (widget.dateTimeConstraint.inMonthRange(nextDate)) + ? _goToNextPage + : null, + icon: nextIcon, + iconSize: widget.theme.paginationSize, + ), ], ), Container( @@ -185,7 +182,7 @@ class _OverlayDateTimeContentState extends State { ], ), ), - if (widget.extraWidgetBuilder != null) widget.extraWidgetBuilder!, + widget.extraWidgetBuilder ?? const SizedBox.shrink(), ], ); } diff --git a/pubspec.yaml b/pubspec.yaml index b49fe14..b1cfd1b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_date_time_picker description: A Flutter package for date and time picker. -version: 4.0.1 +version: 4.1.0 environment: sdk: ">=3.0.0 <4.0.0"