From 269dd054dbe55898b68c0eacf431867a9899517a Mon Sep 17 00:00:00 2001 From: Shubham Jitiya Date: Thu, 2 Jan 2025 12:28:16 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=94=A8=20Fixes=20analytics=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + example/lib/extension.dart | 10 ++++++---- example/lib/widgets/month_view_widget.dart | 1 - lib/src/components/month_view_components.dart | 6 +----- lib/src/extensions.dart | 12 ++++++++---- lib/src/month_view/month_view.dart | 3 +++ 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7380ce13..d479993b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Events are now hidden for days not in the current month when hideDaysNotInMonth = true - Fixes right icon always shows default icon in `CalendarPageHeader` when providing custom icon. [#432](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/432) - Adds `hideDaysNotInMonth` argument in `cellBuilder` in readme. [#433](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/433) +- Fixes `titleColor` of date for `hideDaysNotInMonth: false`. # [1.3.0 - 12 Nov 2024](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/1.3.0) diff --git a/example/lib/extension.dart b/example/lib/extension.dart index 03596819..f70df402 100644 --- a/example/lib/extension.dart +++ b/example/lib/extension.dart @@ -113,10 +113,12 @@ extension DateUtils on DateTime { } extension ColorExtension on Color { - Color get accentColor => - (blue / 2 >= 255 / 2 || red / 2 >= 255 / 2 || green / 2 >= 255 / 2) - ? AppColors.black - : AppColors.white; + /// TODO(Shubham): Update this getter as it uses `computeLuminance()` + /// which is computationally expensive + Color get accentColor { + final brightness = ThemeData.estimateBrightnessForColor(this); + return brightness == Brightness.light ? AppColors.black : AppColors.white; + } } extension StringExt on String { diff --git a/example/lib/widgets/month_view_widget.dart b/example/lib/widgets/month_view_widget.dart index b3d2a7f4..8c1fa67c 100644 --- a/example/lib/widgets/month_view_widget.dart +++ b/example/lib/widgets/month_view_widget.dart @@ -21,7 +21,6 @@ class MonthViewWidget extends StatelessWidget { showWeekends: false, startDay: WeekDays.friday, useAvailableVerticalSpace: true, - hideDaysNotInMonth: true, onEventTap: (event, date) { Navigator.of(context).push( MaterialPageRoute( diff --git a/lib/src/components/month_view_components.dart b/lib/src/components/month_view_components.dart index c09d6e12..a7cd5c5f 100644 --- a/lib/src/components/month_view_components.dart +++ b/lib/src/components/month_view_components.dart @@ -142,11 +142,7 @@ class FilledCell extends StatelessWidget { child: Text( dateStringBuilder?.call(date) ?? "${date.day}", style: TextStyle( - color: shouldHighlight - ? highlightedTitleColor - : isInMonth - ? titleColor - : titleColor.withOpacity(0.4), + color: shouldHighlight ? highlightedTitleColor : titleColor, fontSize: 12, ), ), diff --git a/lib/src/extensions.dart b/lib/src/extensions.dart index 6a07c690..7e6165d7 100644 --- a/lib/src/extensions.dart +++ b/lib/src/extensions.dart @@ -163,10 +163,14 @@ extension DateTimeExtensions on DateTime { } extension ColorExtension on Color { - Color get accent => - (blue / 2 >= 255 / 2 || red / 2 >= 255 / 2 || green / 2 >= 255 / 2) - ? Colors.black - : Colors.white; + /// TODO(Shubham): Update this getter as it uses `computeLuminance()` + /// which is computationally expensive + Color get accent { + final brightness = ThemeData.estimateBrightnessForColor(this); + return brightness == Brightness.light + ? Color(0xff626262) + : Color(0xfff0f0f0); + } } extension MaterialColorExtension on MaterialColor { diff --git a/lib/src/month_view/month_view.dart b/lib/src/month_view/month_view.dart index b4fbc428..1aa4232f 100644 --- a/lib/src/month_view/month_view.dart +++ b/lib/src/month_view/month_view.dart @@ -584,6 +584,9 @@ class MonthViewState extends State> { dateStringBuilder: widget.dateStringBuilder, onTileDoubleTap: widget.onEventDoubleTap, hideDaysNotInMonth: hideDaysNotInMonth, + titleColor: isInMonth + ? Theme.of(context).colorScheme.onPrimaryContainer + : Theme.of(context).colorScheme.onSurfaceVariant.withAlpha(150), ); }