Skip to content

Commit

Permalink
feat: halfHourIndicator and quarterHourIndicator on WeekView added
Browse files Browse the repository at this point in the history
  • Loading branch information
prabinlamsal19 committed Sep 29, 2023
1 parent ff3c085 commit 9e3a23d
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/src/day_view/day_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ class DayView<T extends Object?> extends StatefulWidget {
/// Display full day event builder.
final FullDayEventBuilder<T>? 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
Expand Down
44 changes: 43 additions & 1 deletion lib/src/week_view/_internal_week_view_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class InternalWeekViewPage<T extends Object?> 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;

Expand Down Expand Up @@ -111,6 +114,12 @@ class InternalWeekViewPage<T extends Object?> extends StatelessWidget {
/// Display full day events.
final FullDayEventBuilder<T> 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,
Expand All @@ -123,7 +132,8 @@ class InternalWeekViewPage<T extends Object?> 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,
Expand All @@ -143,6 +153,8 @@ class InternalWeekViewPage<T extends Object?> extends StatelessWidget {
required this.scrollConfiguration,
required this.fullDayEventBuilder,
required this.weekDetectorBuilder,
required this.showHalfHours,
required this.showQuarterHours,
}) : super(key: key);

@override
Expand Down Expand Up @@ -225,6 +237,36 @@ class InternalWeekViewPage<T extends Object?> 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,
Expand Down
27 changes: 25 additions & 2 deletions lib/src/week_view/week_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class WeekView<T extends Object?> 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;

Expand Down Expand Up @@ -175,14 +178,20 @@ class WeekView<T extends Object?> extends StatefulWidget {
final MinuteSlotSize minuteSlotSize;

/// Style for WeekView header.
final HeaderStyle headerStyle;
final HeaderStyle headerStyle;

/// Option for SafeArea.
final SafeAreaOption safeAreaOption;

/// Display full day event builder.
final FullDayEventBuilder<T>? fullDayEventBuilder;

///Show half hour indicator
final bool showHalfHours;

///Show quarter hour indicator
final bool showQuarterHours;

/// Main widget for week view.
const WeekView({
Key? key,
Expand All @@ -198,6 +207,7 @@ class WeekView<T extends Object?> extends StatefulWidget {
this.maxDay,
this.initialDay,
this.hourIndicatorSettings,
this.halfHourIndicatorSettings,
this.timeLineBuilder,
this.timeLineWidth,
this.liveTimeIndicatorSettings,
Expand All @@ -224,6 +234,8 @@ class WeekView<T extends Object?> 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,
Expand Down Expand Up @@ -258,7 +270,8 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {

late EventArranger<T> _eventArranger;

late HourIndicatorSettings _hourIndicatorSettings;
late HourIndicatorSettings _hourIndicatorSettings;
late HourIndicatorSettings _halfHourIndicatorSettings;
late HourIndicatorSettings _liveTimeIndicatorSettings;

late PageController _pageController;
Expand Down Expand Up @@ -418,6 +431,7 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
eventTileBuilder: _eventTileBuilder,
heightPerMinute: widget.heightPerMinute,
hourIndicatorSettings: _hourIndicatorSettings,
halfHourIndicatorSettings: _halfHourIndicatorSettings,
dates: dates,
showLiveLine: widget.showLiveTimeLineInAllDays ||
_showLiveTimeIndicator(dates),
Expand All @@ -433,6 +447,8 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
minuteSlotSize: widget.minuteSlotSize,
scrollConfiguration: _scrollConfiguration,
fullDayEventBuilder: _fullDayEventBuilder,
showHalfHours: widget.showHalfHours,
showQuarterHours: widget.showQuarterHours,
),
);
},
Expand Down Expand Up @@ -510,6 +526,13 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
_weekTitleWidth =
(_width - _timeLineWidth - _hourIndicatorSettings.offset) /
_totalDaysInWeek;

_halfHourIndicatorSettings = widget.halfHourIndicatorSettings ??
HourIndicatorSettings(
height: widget.heightPerMinute,
color: Constants.defaultBorderColor,
offset: 5,
);
}

void _calculateHeights() {
Expand Down

0 comments on commit 9e3a23d

Please sign in to comment.