Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixes issue #426: 🐛 Fix header style icons visibility on min & max dates #429

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- Fixes `startHour` and `endHour` not updating when rebuilding in week view. [#410](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/410)
- Fixes issue of header icon `color` property in `IconDataConfig`.
- Adds support for single day & full day recurring events. [#378](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/378)
- Fixes `HeaderStyle` icons visibility on min & max dates reached. [#429](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/429)
- Fixes inconsistent padding issue of right icon in the `HeaderStyle`.

# [1.3.0 - 12 Nov 2024](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/1.3.0)

Expand Down
85 changes: 54 additions & 31 deletions lib/src/components/headers/calendar_page_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ class CalendarPageHeader extends StatelessWidget {
/// This will be ignored if right icon is provided in [headerStyle].
final VoidCallback? onNextDay;

/// Hide & show right icon
final bool showNextIcon;

/// When user taps on left arrow.
///
/// This will be ignored if left icon is provided in [headerStyle].
final VoidCallback? onPreviousDay;

/// Hide & show left icon
final bool showPreviousIcon;

/// When user taps on title.
///
/// This will be ignored if [titleBuilder] is provided.
Expand Down Expand Up @@ -78,8 +84,10 @@ class CalendarPageHeader extends StatelessWidget {
this.dateStringBuilder,
this.titleBuilder,
this.onNextDay,
this.showNextIcon = true,
this.onTitleTapped,
this.onPreviousDay,
this.showPreviousIcon = true,
this.secondaryDate,
@Deprecated("Use HeaderStyle.decoration to provide background")
this.backgroundColor = Constants.headerBackground,
Expand All @@ -104,22 +112,29 @@ class CalendarPageHeader extends StatelessWidget {
mainAxisAlignment: headerStyle.mainAxisAlignment,
children: [
if (headerStyle.leftIconVisible && headerStyle.leftIconConfig != null)
headerStyle.leftIconConfig!.icon?.call(context) ??
IconButton(
onPressed: onPreviousDay,
splashColor: Colors.transparent,
focusColor: Colors.transparent,
hoverColor: Colors.transparent,
highlightColor: Colors.transparent,
padding: headerStyle.leftIconPadding ??
headerStyle.leftIconConfig!.padding,
icon: headerStyle.leftIcon ??
Icon(
Icons.chevron_left,
size: headerStyle.leftIconConfig!.size,
color: iconColor ?? headerStyle.leftIconConfig!.color,
),
),
AbsorbPointer(
absorbing: !showPreviousIcon,
child: Opacity(
opacity: showPreviousIcon ? 1 : 0,
child: headerStyle.leftIconConfig!.icon?.call(context) ??
IconButton(
onPressed: onPreviousDay,
splashColor: Colors.transparent,
focusColor: Colors.transparent,
hoverColor: Colors.transparent,
highlightColor: Colors.transparent,
padding: headerStyle.leftIconPadding ??
headerStyle.leftIconConfig!.padding,
icon: headerStyle.leftIcon ??
Icon(
Icons.chevron_left,
size: headerStyle.leftIconConfig!.size,
color:
iconColor ?? headerStyle.leftIconConfig!.color,
),
),
),
),
Expanded(
child: titleBuilder != null
? DefaultTextStyle.merge(
Expand All @@ -142,21 +157,29 @@ class CalendarPageHeader extends StatelessWidget {
),
if (headerStyle.rightIconVisible &&
headerStyle.rightIconConfig != null)
headerStyle.rightIconConfig!.icon?.call(context) ??
IconButton(
onPressed: onNextDay,
splashColor: Colors.transparent,
focusColor: Colors.transparent,
hoverColor: Colors.transparent,
highlightColor: Colors.transparent,
padding: headerStyle.rightIconPadding,
icon: headerStyle.rightIcon ??
Icon(
Icons.chevron_right,
size: headerStyle.rightIconConfig?.size,
color: iconColor ?? headerStyle.rightIconConfig?.color,
),
),
AbsorbPointer(
absorbing: !showNextIcon,
child: Opacity(
opacity: showNextIcon ? 1 : 0,
child: headerStyle.rightIconConfig!.icon?.call(context) ??
IconButton(
onPressed: onNextDay,
splashColor: Colors.transparent,
focusColor: Colors.transparent,
hoverColor: Colors.transparent,
highlightColor: Colors.transparent,
padding: headerStyle.rightIconPadding ??
headerStyle.rightIconConfig!.padding,
icon: headerStyle.rightIcon ??
Icon(
Icons.chevron_right,
size: headerStyle.rightIconConfig?.size,
color:
iconColor ?? headerStyle.rightIconConfig?.color,
),
),
),
),
],
),
);
Expand Down
5 changes: 5 additions & 0 deletions lib/src/components/headers/day_page_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ class DayPageHeader extends CalendarPageHeader {
const DayPageHeader({
Key? key,
VoidCallback? onNextDay,
bool showNextIcon = true,
AsyncCallback? onTitleTapped,
VoidCallback? onPreviousDay,
bool showPreviousIcon = true,
StringProvider? dateStringBuilder,
required DateTime date,
@Deprecated("Use HeaderStyle to provide icon color") Color? iconColor,
Expand All @@ -31,7 +33,10 @@ class DayPageHeader extends CalendarPageHeader {
backgroundColor: backgroundColor,
iconColor: iconColor,
onNextDay: onNextDay,

showNextIcon: showNextIcon,
onPreviousDay: onPreviousDay,
showPreviousIcon: showPreviousIcon,
onTitleTapped: onTitleTapped,
dateStringBuilder:
dateStringBuilder ?? DayPageHeader._dayStringBuilder,
Expand Down
4 changes: 4 additions & 0 deletions lib/src/components/headers/month_page_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ class MonthPageHeader extends CalendarPageHeader {
const MonthPageHeader({
Key? key,
VoidCallback? onNextMonth,
bool showNextIcon = true,
AsyncCallback? onTitleTapped,
VoidCallback? onPreviousMonth,
bool showPreviousIcon = true,
@Deprecated("Use HeaderStyle to provide icon color") Color? iconColor,
@Deprecated("Use HeaderStyle to provide background color")
Color backgroundColor = Constants.headerBackground,
Expand All @@ -27,7 +29,9 @@ class MonthPageHeader extends CalendarPageHeader {
key: key,
date: date,
onNextDay: onNextMonth,
showNextIcon: showNextIcon,
onPreviousDay: onPreviousMonth,
showPreviousIcon: showPreviousIcon,
onTitleTapped: onTitleTapped,
// ignore_for_file: deprecated_member_use_from_same_package
backgroundColor: backgroundColor,
Expand Down
4 changes: 4 additions & 0 deletions lib/src/components/headers/week_page_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ class WeekPageHeader extends CalendarPageHeader {
const WeekPageHeader({
Key? key,
VoidCallback? onNextDay,
bool showNextIcon = true,
AsyncCallback? onTitleTapped,
VoidCallback? onPreviousDay,
bool showPreviousIcon = true,
required DateTime startDate,
required DateTime endDate,
@Deprecated("Use HeaderStyle to provide icon color") Color? iconColor,
Expand All @@ -29,7 +31,9 @@ class WeekPageHeader extends CalendarPageHeader {
date: startDate,
secondaryDate: endDate,
onNextDay: onNextDay,
showNextIcon: showNextIcon,
onPreviousDay: onPreviousDay,
showPreviousIcon: showPreviousIcon,
onTitleTapped: onTitleTapped,
// ignore_for_file: deprecated_member_use_from_same_package
iconColor: iconColor,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/day_view/day_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,9 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {
date: _currentDate,
dateStringBuilder: widget.dateStringBuilder,
onNextDay: nextPage,
showNextIcon: date != _maxDate,
onPreviousDay: previousPage,
showPreviousIcon: date != _minDate,
onTitleTapped: () async {
if (widget.onHeaderTitleTap != null) {
widget.onHeaderTitleTap!(date);
Expand Down
2 changes: 2 additions & 0 deletions lib/src/month_view/month_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,8 @@ class MonthViewState<T extends Object?> extends State<MonthView<T>> {
/// Default month view header builder
Widget _defaultHeaderBuilder(DateTime date) {
return MonthPageHeader(
showPreviousIcon: date != _minDate,
showNextIcon: date != _maxDate,
onTitleTapped: () async {
if (widget.onHeaderTitleTap != null) {
widget.onHeaderTitleTap!(date);
Expand Down
2 changes: 2 additions & 0 deletions lib/src/week_view/week_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,9 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
startDate: _currentStartDate,
endDate: _currentEndDate,
onNextDay: nextPage,
showNextIcon: endDate != _maxDate,
onPreviousDay: previousPage,
showPreviousIcon: startDate != _minDate,
onTitleTapped: () async {
if (widget.onHeaderTitleTap != null) {
widget.onHeaderTitleTap!(startDate);
Expand Down
Loading