From 85403809ec670545a2c2e11eca0daa5857daaadd Mon Sep 17 00:00:00 2001 From: Jaimin Rana Date: Tue, 7 Nov 2023 19:04:21 +0530 Subject: [PATCH] feat: Added Support for changing the week day position(top/bottom) in weekView #283. --- CHANGELOG.md | 3 +++ lib/src/components/event_scroll_notifier.dart | 3 +++ lib/src/components/month_view_components.dart | 1 + lib/src/components/week_view_components.dart | 1 + lib/src/constants.dart | 1 + lib/src/event_arrangers/event_arrangers.dart | 1 + lib/src/week_view/_internal_week_view_page.dart | 6 ++++++ lib/src/week_view/week_view.dart | 5 +++++ 8 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index da983e09..77d5943e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ feature added the quarterHourIndicator for the DayView & halfHourIndicator and quarterHourIndicator for WeekView - [#270](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/270) +- Added + feature added Support for changing the week day position(top/bottom) in weekView + - [#283](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/283) # [1.0.4 - 9 Aug 2023](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/1.0.4) diff --git a/lib/src/components/event_scroll_notifier.dart b/lib/src/components/event_scroll_notifier.dart index a141f606..f20dc547 100644 --- a/lib/src/components/event_scroll_notifier.dart +++ b/lib/src/components/event_scroll_notifier.dart @@ -15,8 +15,11 @@ class EventScrollConfiguration extends ValueNotifier { EventScrollConfiguration() : super(false); bool get shouldScroll => _shouldScroll; + CalendarEventData? get event => _event; + Duration? get duration => _duration; + Curve? get curve => _curve; // This function will be completed once [completeScroll] is called. diff --git a/lib/src/components/month_view_components.dart b/lib/src/components/month_view_components.dart index af17d548..3bcc7327 100644 --- a/lib/src/components/month_view_components.dart +++ b/lib/src/components/month_view_components.dart @@ -219,6 +219,7 @@ class MonthPageHeader extends CalendarPageHeader { dateStringBuilder ?? MonthPageHeader._monthStringBuilder, headerStyle: headerStyle, ); + static String _monthStringBuilder(DateTime date, {DateTime? secondaryDate}) => "${date.month} - ${date.year}"; } diff --git a/lib/src/components/week_view_components.dart b/lib/src/components/week_view_components.dart index 41f924fc..69f88203 100644 --- a/lib/src/components/week_view_components.dart +++ b/lib/src/components/week_view_components.dart @@ -37,6 +37,7 @@ class WeekPageHeader extends CalendarPageHeader { headerStringBuilder ?? WeekPageHeader._weekStringBuilder, headerStyle: headerStyle, ); + static String _weekStringBuilder(DateTime date, {DateTime? secondaryDate}) => "${date.day} / ${date.month} / ${date.year} to " "${secondaryDate != null ? "${secondaryDate.day} / " diff --git a/lib/src/constants.dart b/lib/src/constants.dart index 5b87890e..158379c8 100644 --- a/lib/src/constants.dart +++ b/lib/src/constants.dart @@ -22,6 +22,7 @@ class Constants { static const Color white = Color(0xffffffff); static const Color offWhite = Color(0xfff0f0f0); static const Color headerBackground = Color(0xFFDCF0FF); + static Color get randomColor { return Color.fromRGBO(_random.nextInt(_maxColor), _random.nextInt(_maxColor), _random.nextInt(_maxColor), 1); diff --git a/lib/src/event_arrangers/event_arrangers.dart b/lib/src/event_arrangers/event_arrangers.dart index c73e52ee..a1bf7b65 100644 --- a/lib/src/event_arrangers/event_arrangers.dart +++ b/lib/src/event_arrangers/event_arrangers.dart @@ -11,6 +11,7 @@ import '../constants.dart'; import '../extensions.dart'; part 'merge_event_arranger.dart'; + part 'side_event_arranger.dart'; abstract class EventArranger { diff --git a/lib/src/week_view/_internal_week_view_page.dart b/lib/src/week_view/_internal_week_view_page.dart index b8bfd1c0..1cd2466e 100644 --- a/lib/src/week_view/_internal_week_view_page.dart +++ b/lib/src/week_view/_internal_week_view_page.dart @@ -120,6 +120,9 @@ class InternalWeekViewPage extends StatelessWidget { /// Display full day events. final FullDayEventBuilder fullDayEventBuilder; + /// If true this will show week day at bottom position. + final bool showWeekDayAtBottom; + /// Flag to display half hours final bool showHalfHours; @@ -164,6 +167,7 @@ class InternalWeekViewPage extends StatelessWidget { required this.scrollConfiguration, required this.fullDayEventBuilder, required this.weekDetectorBuilder, + required this.showWeekDayAtBottom, required this.showHalfHours, required this.showQuarterHours, required this.emulateVerticalOffsetBy}) @@ -176,6 +180,8 @@ class InternalWeekViewPage extends StatelessWidget { height: height + weekTitleHeight, width: width, child: Column( + verticalDirection: + showWeekDayAtBottom ? VerticalDirection.up : VerticalDirection.down, crossAxisAlignment: CrossAxisAlignment.end, children: [ SizedBox( diff --git a/lib/src/week_view/week_view.dart b/lib/src/week_view/week_view.dart index 0536d70a..f8054eb9 100644 --- a/lib/src/week_view/week_view.dart +++ b/lib/src/week_view/week_view.dart @@ -210,6 +210,9 @@ class WeekView extends StatefulWidget { /// Callback for the Header title final HeaderTitleCallback? onHeaderTitleTap; + /// If true this will show week day at bottom position. + final bool showWeekDayAtBottom; + /// Main widget for week view. const WeekView({ Key? key, @@ -259,6 +262,7 @@ class WeekView extends StatefulWidget { this.showHalfHours = false, this.showQuarterHours = false, this.emulateVerticalOffsetBy = 0, + this.showWeekDayAtBottom = false, }) : assert(!(onHeaderTitleTap != null && weekPageHeaderBuilder != null), "can't use [onHeaderTitleTap] & [weekPageHeaderBuilder] simultaneously"), assert((timeLineOffset) >= 0, @@ -486,6 +490,7 @@ class WeekViewState extends State> { showQuarterHours: widget.showQuarterHours, emulateVerticalOffsetBy: widget.emulateVerticalOffsetBy, + showWeekDayAtBottom: widget.showWeekDayAtBottom, ), ); },