Skip to content

Commit fd0be21

Browse files
feat: Fixes issue #498 ✨ add DividerSettings for customizable dividers in WeekView and MultiDayView
1 parent 3758343 commit fd0be21

File tree

6 files changed

+73
-6
lines changed

6 files changed

+73
-6
lines changed

doc/documentation.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ Default hour indicator settings.
658658
* To customise timeline use `timeLineBuilder`.
659659
* To change Hour lines color use `HourIndicatorSettings`.
660660
* To style hours, half hours & quarter hours use `HourIndicatorSettings`. Default color used is `surfaceContainerHighest`
661+
* To customise divider between weekdays and full-day events use `dividerSettings`.
661662

662663
```dart
663664
hourIndicatorSettings: HourIndicatorSettings(
@@ -669,6 +670,16 @@ Default hour indicator settings.
669670
color: Colors.redAccent,
670671
lineStyle: LineStyle.dashed,
671672
),
673+
dividerSettings: DividerSettings(
674+
thickness: 2,
675+
height: 2,
676+
color: Colors.blueAccent,
677+
),
678+
```
679+
680+
Hide divider in week view.
681+
```dart
682+
dividerSettings: DividerSettings.none(),
672683
```
673684

674685
### Month view

lib/src/modals.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,32 @@ class HourIndicatorSettings {
3333
);
3434
}
3535

36+
/// Settings for divider between FullDay events and weekdays header
37+
class DividerSettings {
38+
/// Thickness of the divider line
39+
final double thickness;
40+
41+
/// Height of the divider
42+
final double height;
43+
44+
/// Color of the divider line
45+
final Color color;
46+
47+
/// Settings for divider between FullDay events and weekdays header
48+
const DividerSettings({
49+
this.thickness = 1.0,
50+
this.height = 1.0,
51+
this.color = Colors.grey,
52+
}) : assert(thickness >= 0, "Thickness must be greater than or equal to 0."),
53+
assert(height >= 0, "Height must be greater than or equal to 0.");
54+
55+
factory DividerSettings.none() => DividerSettings(
56+
color: Colors.transparent,
57+
thickness: 0.0,
58+
height: 0.0,
59+
);
60+
}
61+
3662
/// Settings for live time line
3763
class LiveTimeIndicatorSettings {
3864
/// Color of time indicator.

lib/src/multi_day_view/_internal_multi_day_view_page.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ class InternalMultiDayViewPage<T extends Object?> extends StatefulWidget {
4848
/// Settings for quarter hour indicator lines.
4949
final HourIndicatorSettings quarterHourIndicatorSettings;
5050

51+
/// Settings for divider between weekdays and full-day events.
52+
final DividerSettings dividerSettings;
53+
5154
/// Flag to display live line.
5255
final bool showLiveLine;
5356

@@ -186,6 +189,7 @@ class InternalMultiDayViewPage<T extends Object?> extends StatefulWidget {
186189
required this.hourLinePainter,
187190
required this.halfHourIndicatorSettings,
188191
required this.quarterHourIndicatorSettings,
192+
required this.dividerSettings,
189193
required this.showLiveLine,
190194
required this.liveTimeIndicatorSettings,
191195
required this.heightPerMinute,
@@ -297,9 +301,9 @@ class _InternalMultiDayViewPageState<T extends Object?>
297301
),
298302
if (widget.showMutliDayBottomLine)
299303
Divider(
300-
thickness: 1,
301-
height: 1,
302-
color: themeColor.borderColor,
304+
thickness: widget.dividerSettings.thickness,
305+
height: widget.dividerSettings.height,
306+
color: widget.dividerSettings.color,
303307
),
304308
SizedBox(
305309
width: widget.width,

lib/src/multi_day_view/multi_day_view.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ class MultiDayView<T extends Object?> extends StatefulWidget {
9393
/// Settings for quarter hour indicator settings.
9494
final HourIndicatorSettings? quarterHourIndicatorSettings;
9595

96+
/// Settings for divider between weekdays and full-day events.
97+
final DividerSettings? dividerSettings;
98+
9699
/// Settings for live time indicator settings.
97100
final LiveTimeIndicatorSettings? liveTimeIndicatorSettings;
98101

@@ -266,6 +269,7 @@ class MultiDayView<T extends Object?> extends StatefulWidget {
266269
this.hourLinePainter,
267270
this.halfHourIndicatorSettings,
268271
this.quarterHourIndicatorSettings,
272+
this.dividerSettings,
269273
this.timeLineBuilder,
270274
this.timeLineWidth,
271275
this.liveTimeIndicatorSettings,
@@ -361,6 +365,7 @@ class MultiDayViewState<T extends Object?> extends State<MultiDayView<T>> {
361365
late HourIndicatorSettings _halfHourIndicatorSettings;
362366
late LiveTimeIndicatorSettings _liveTimeIndicatorSettings;
363367
late HourIndicatorSettings _quarterHourIndicatorSettings;
368+
late DividerSettings _dividerSettings;
364369

365370
late PageController _pageController;
366371

@@ -559,6 +564,7 @@ class MultiDayViewState<T extends Object?> extends State<MultiDayView<T>> {
559564
_halfHourIndicatorSettings,
560565
quarterHourIndicatorSettings:
561566
_quarterHourIndicatorSettings,
567+
dividerSettings: _dividerSettings,
562568
dates: dates,
563569
showLiveLine: widget.showLiveTimeLineInAllDays ||
564570
_showLiveTimeIndicator(dates),
@@ -682,6 +688,11 @@ class MultiDayViewState<T extends Object?> extends State<MultiDayView<T>> {
682688

683689
assert(_quarterHourIndicatorSettings.height < _hourHeight,
684690
"quarterHourIndicator height must be less than minuteHeight * 60");
691+
692+
_dividerSettings = widget.dividerSettings ??
693+
DividerSettings(
694+
color: context.multiDayViewTheme.borderColor,
695+
);
685696
}
686697

687698
void _calculateHeights() {

lib/src/week_view/_internal_week_view_page.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class InternalWeekViewPage<T extends Object?> extends StatefulWidget {
4242
/// Settings for quarter hour indicator lines.
4343
final HourIndicatorSettings quarterHourIndicatorSettings;
4444

45+
/// Settings for divider between FullDay events and weekdays header.
46+
final DividerSettings dividerSettings;
47+
4548
/// Flag to display live line.
4649
final bool showLiveLine;
4750

@@ -183,6 +186,7 @@ class InternalWeekViewPage<T extends Object?> extends StatefulWidget {
183186
required this.hourLinePainter,
184187
required this.halfHourIndicatorSettings,
185188
required this.quarterHourIndicatorSettings,
189+
required this.dividerSettings,
186190
required this.showLiveLine,
187191
required this.liveTimeIndicatorSettings,
188192
required this.heightPerMinute,
@@ -296,9 +300,9 @@ class _InternalWeekViewPageState<T extends Object?>
296300
),
297301
),
298302
Divider(
299-
thickness: 1,
300-
height: 1,
301-
color: themeColor.borderColor,
303+
thickness: widget.dividerSettings.thickness,
304+
height: widget.dividerSettings.height,
305+
color: widget.dividerSettings.color,
302306
),
303307
SizedBox(
304308
width: widget.width,

lib/src/week_view/week_view.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ class WeekView<T extends Object?> extends StatefulWidget {
9393
/// Settings for quarter hour indicator settings.
9494
final HourIndicatorSettings? quarterHourIndicatorSettings;
9595

96+
/// Settings for divider between FullDay events and weekdays header.
97+
final DividerSettings? dividerSettings;
98+
9699
/// Settings for live time indicator settings.
97100
final LiveTimeIndicatorSettings? liveTimeIndicatorSettings;
98101

@@ -263,6 +266,7 @@ class WeekView<T extends Object?> extends StatefulWidget {
263266
this.hourLinePainter,
264267
this.halfHourIndicatorSettings,
265268
this.quarterHourIndicatorSettings,
269+
this.dividerSettings,
266270
this.timeLineBuilder,
267271
this.timeLineWidth,
268272
this.liveTimeIndicatorSettings,
@@ -357,6 +361,7 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
357361
late HourIndicatorSettings _halfHourIndicatorSettings;
358362
late LiveTimeIndicatorSettings _liveTimeIndicatorSettings;
359363
late HourIndicatorSettings _quarterHourIndicatorSettings;
364+
late DividerSettings _dividerSettings;
360365

361366
late PageController _pageController;
362367

@@ -548,6 +553,7 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
548553
halfHourIndicatorSettings: _halfHourIndicatorSettings,
549554
quarterHourIndicatorSettings:
550555
_quarterHourIndicatorSettings,
556+
dividerSettings: _dividerSettings,
551557
dates: dates,
552558
showLiveLine: widget.showLiveTimeLineInAllDays ||
553559
_showLiveTimeIndicator(dates),
@@ -669,6 +675,11 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
669675

670676
assert(_quarterHourIndicatorSettings.height < _hourHeight,
671677
"quarterHourIndicator height must be less than minuteHeight * 60");
678+
679+
_dividerSettings = widget.dividerSettings ??
680+
DividerSettings(
681+
color: context.multiDayViewTheme.borderColor,
682+
);
672683
}
673684

674685
void _calculateHeights() {

0 commit comments

Comments
 (0)