diff --git a/lib/src/day_view/day_view.dart b/lib/src/day_view/day_view.dart index f53158ba..0144cdc3 100644 --- a/lib/src/day_view/day_view.dart +++ b/lib/src/day_view/day_view.dart @@ -182,10 +182,10 @@ class DayView extends StatefulWidget { /// Display full day event builder. final FullDayEventBuilder? fullDayEventBuilder; - /// Show half hour lines + /// Show half hour indicator final bool showHalfHours; - /// Show quarter hour lines + /// Show quarter hour indicator final bool showQuarterHours; /// Duration from where default day view will be visible diff --git a/lib/src/week_view/_internal_week_view_page.dart b/lib/src/week_view/_internal_week_view_page.dart index 3f7ec3b4..18ac1b32 100644 --- a/lib/src/week_view/_internal_week_view_page.dart +++ b/lib/src/week_view/_internal_week_view_page.dart @@ -37,6 +37,9 @@ class InternalWeekViewPage extends StatelessWidget { /// Settings for hour indicator lines. final HourIndicatorSettings hourIndicatorSettings; + /// Settings for half hour indicator lines. + final HourIndicatorSettings halfHourIndicatorSettings; + /// Flag to display live line. final bool showLiveLine; @@ -111,6 +114,12 @@ class InternalWeekViewPage extends StatelessWidget { /// Display full day events. final FullDayEventBuilder fullDayEventBuilder; + /// Flag to display half hours + final bool showHalfHours; + + /// Flag to display quarter hours + final bool showQuarterHours; + /// A single page for week view. const InternalWeekViewPage({ Key? key, @@ -123,7 +132,8 @@ class InternalWeekViewPage extends StatelessWidget { required this.eventTileBuilder, required this.controller, required this.timeLineBuilder, - required this.hourIndicatorSettings, + required this.hourIndicatorSettings, + required this.halfHourIndicatorSettings, required this.showLiveLine, required this.liveTimeIndicatorSettings, required this.heightPerMinute, @@ -143,6 +153,8 @@ class InternalWeekViewPage extends StatelessWidget { required this.scrollConfiguration, required this.fullDayEventBuilder, required this.weekDetectorBuilder, + required this.showHalfHours, + required this.showQuarterHours, }) : super(key: key); @override @@ -225,6 +237,36 @@ class InternalWeekViewPage extends StatelessWidget { showVerticalLine: showVerticalLine, ), ), + if (showHalfHours) + CustomPaint( + size: Size(width, height), + painter: HalfHourLinePainter( + lineColor: halfHourIndicatorSettings.color, + lineHeight: halfHourIndicatorSettings.height, + offset: + timeLineWidth + halfHourIndicatorSettings.offset, + minuteHeight: heightPerMinute, + lineStyle: halfHourIndicatorSettings.lineStyle, + dashWidth: halfHourIndicatorSettings.dashWidth, + dashSpaceWidth: + halfHourIndicatorSettings.dashSpaceWidth, + ), + ), + if (showQuarterHours) + CustomPaint( + size: Size(width, height), + painter: QuarterHourLinePainter( + lineColor: halfHourIndicatorSettings.color, + lineHeight: halfHourIndicatorSettings.height, + offset: + timeLineWidth + halfHourIndicatorSettings.offset, + minuteHeight: heightPerMinute, + lineStyle: halfHourIndicatorSettings.lineStyle, + dashWidth: halfHourIndicatorSettings.dashWidth, + dashSpaceWidth: + halfHourIndicatorSettings.dashSpaceWidth, + ), + ), if (showLiveLine && liveTimeIndicatorSettings.height > 0) LiveTimeIndicator( liveTimeIndicatorSettings: liveTimeIndicatorSettings, diff --git a/lib/src/week_view/week_view.dart b/lib/src/week_view/week_view.dart index 8357e98c..e40d34fa 100644 --- a/lib/src/week_view/week_view.dart +++ b/lib/src/week_view/week_view.dart @@ -85,6 +85,9 @@ class WeekView extends StatefulWidget { /// Settings for hour indicator settings. final HourIndicatorSettings? hourIndicatorSettings; + /// Settings for half hour and quarter hour indicator settings. + final HourIndicatorSettings? halfHourIndicatorSettings; + /// Settings for live time indicator settings. final HourIndicatorSettings? liveTimeIndicatorSettings; @@ -175,7 +178,7 @@ class WeekView extends StatefulWidget { final MinuteSlotSize minuteSlotSize; /// Style for WeekView header. - final HeaderStyle headerStyle; + final HeaderStyle headerStyle; /// Option for SafeArea. final SafeAreaOption safeAreaOption; @@ -183,6 +186,12 @@ class WeekView extends StatefulWidget { /// Display full day event builder. final FullDayEventBuilder? fullDayEventBuilder; + ///Show half hour indicator + final bool showHalfHours; + + ///Show quarter hour indicator + final bool showQuarterHours; + /// Main widget for week view. const WeekView({ Key? key, @@ -198,6 +207,7 @@ class WeekView extends StatefulWidget { this.maxDay, this.initialDay, this.hourIndicatorSettings, + this.halfHourIndicatorSettings, this.timeLineBuilder, this.timeLineWidth, this.liveTimeIndicatorSettings, @@ -224,6 +234,8 @@ class WeekView extends StatefulWidget { this.headerStyle = const HeaderStyle(), this.safeAreaOption = const SafeAreaOption(), this.fullDayEventBuilder, + this.showHalfHours = false, + this.showQuarterHours = false, }) : assert((timeLineOffset) >= 0, "timeLineOffset must be greater than or equal to 0"), assert(width == null || width > 0, @@ -258,7 +270,8 @@ class WeekViewState extends State> { late EventArranger _eventArranger; - late HourIndicatorSettings _hourIndicatorSettings; + late HourIndicatorSettings _hourIndicatorSettings; + late HourIndicatorSettings _halfHourIndicatorSettings; late HourIndicatorSettings _liveTimeIndicatorSettings; late PageController _pageController; @@ -418,6 +431,7 @@ class WeekViewState extends State> { eventTileBuilder: _eventTileBuilder, heightPerMinute: widget.heightPerMinute, hourIndicatorSettings: _hourIndicatorSettings, + halfHourIndicatorSettings: _halfHourIndicatorSettings, dates: dates, showLiveLine: widget.showLiveTimeLineInAllDays || _showLiveTimeIndicator(dates), @@ -433,6 +447,8 @@ class WeekViewState extends State> { minuteSlotSize: widget.minuteSlotSize, scrollConfiguration: _scrollConfiguration, fullDayEventBuilder: _fullDayEventBuilder, + showHalfHours: widget.showHalfHours, + showQuarterHours: widget.showQuarterHours, ), ); }, @@ -510,6 +526,13 @@ class WeekViewState extends State> { _weekTitleWidth = (_width - _timeLineWidth - _hourIndicatorSettings.offset) / _totalDaysInWeek; + + _halfHourIndicatorSettings = widget.halfHourIndicatorSettings ?? + HourIndicatorSettings( + height: widget.heightPerMinute, + color: Constants.defaultBorderColor, + offset: 5, + ); } void _calculateHeights() {