Skip to content

Commit

Permalink
feat(calendar): Perfectly centered "Today" button #82
Browse files Browse the repository at this point in the history
Closes #82: Top row restructured, so that "Today" button is always centered, even when the date picker icon or the list picker icon is hidden
  • Loading branch information
agfeo-rw committed Aug 13, 2024
1 parent 2a5dcb8 commit 25a6cdf
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 47 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011

COCOAPODS: 1.13.0
COCOAPODS: 1.15.2
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class _CalendarScreenState extends State<CalendarScreen> {
datePickerType: DatePickerType.date,
dayOfWeekStyle: TextStyle(
color: Colors.red, fontWeight: FontWeight.w800, fontSize: 11),
showEventListViewIcon: true,
showEventListViewIcon: false,
showEvents: showEvents,
),
),
Expand Down
84 changes: 40 additions & 44 deletions lib/flutter_neat_and_clean_calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -477,55 +477,51 @@ class _CalendarState extends State<Calendar> {
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: <Widget>[
// 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(),
),
]),
],
);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 25a6cdf

Please sign in to comment.