diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c00e16..8bd3f30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [0.4.8] - 2024-08-13 +* Issue #82: Top row restructured, so that "Today" button is always centered, even when the date picker icon or the list picker icon is hidden + ## [0.4.7] - 2024-08-12 * New parameter showEventListViewIcon to hide the list view icon diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 88a2a34..042aaa1 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -13,4 +13,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011 -COCOAPODS: 1.13.0 +COCOAPODS: 1.15.2 diff --git a/example/lib/main.dart b/example/lib/main.dart index 929a173..f414513 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -191,7 +191,7 @@ class _CalendarScreenState extends State { datePickerType: DatePickerType.date, dayOfWeekStyle: TextStyle( color: Colors.red, fontWeight: FontWeight.w800, fontSize: 11), - showEventListViewIcon: true, + showEventListViewIcon: false, showEvents: showEvents, ), ), diff --git a/lib/flutter_neat_and_clean_calendar.dart b/lib/flutter_neat_and_clean_calendar.dart index 294f3b6..e61169c 100644 --- a/lib/flutter_neat_and_clean_calendar.dart +++ b/lib/flutter_neat_and_clean_calendar.dart @@ -477,55 +477,51 @@ class _CalendarState extends State { color: widget.topRowIconColor, ), ); + } else { + jumpDateIcon = Container(); } - return Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + return Stack( + alignment: Alignment.center, children: [ - showEventListView ? Container() : leftArrow ?? Container(), - widget.showEventListViewIcon - ? - PlatformIconButton( - onPressed: () { - setState(() { - showEventListView = !showEventListView; - if (widget.onListViewStateChanged != null) { - // If the onListViewStateChanged callback is provided, invoke it. - // This can be used to trigger actions in the parent widget. - widget.onListViewStateChanged!(showEventListView); - } - }); - }, - icon: Icon( - Icons.list, - color: widget.topRowIconColor, - ), - ) - : Container( - padding: EdgeInsets.only(left: 24.0), - ), - showEventListView - ? Flexible( - child: Container(), - ) - : Expanded( - child: Column( - children: [ - // Text 'Today' in the top bar (or what you set as todayButtonText) - todayIcon ?? Container(), - // Month and year in the top bar - Text( - displayMonth, - style: widget.displayMonthTextStyle ?? - TextStyle( - fontSize: 20.0, - ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + showEventListView ? Container() : leftArrow ?? Container(), + widget.showEventListViewIcon + ? PlatformIconButton( + onPressed: () { + setState(() { + showEventListView = !showEventListView; + if (widget.onListViewStateChanged != null) { + widget.onListViewStateChanged!(showEventListView); + } + }); + }, + icon: Icon( + Icons.list, + color: widget.topRowIconColor, ), - ], + ) + : Container(), + Expanded( + child: + Container()), // Platzhalter, damit die Row ausgeglichen ist + showEventListView ? Container() : jumpDateIcon ?? Container(), + showEventListView ? Container() : rightArrow ?? Container(), + ], + ), + // Zentralisiertes Stack-Widget + Column(children: [ + if (todayIcon != null) todayIcon!, + Text( + displayMonth, + style: widget.displayMonthTextStyle ?? + TextStyle( + fontSize: 20.0, ), - ), - showEventListView ? Container() : jumpDateIcon ?? Container(), - showEventListView ? Container() : rightArrow ?? Container(), + ), + ]), ], ); } diff --git a/pubspec.yaml b/pubspec.yaml index 50c2b9b..0e5ff3e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: >- Simple and clean flutter calendar with ability to slide up/down to show weekly/monthly calendar. Fork of https://pub.dev/packages/flutter_clean_calendar -version: 0.4.7 +version: 0.4.8 homepage: https://github.com/rwbr/flutter_neat_and_clean_calendar environment: