diff --git a/README.md b/README.md index df79af43..d91d8c98 100644 --- a/README.md +++ b/README.md @@ -174,6 +174,7 @@ DayView( eventArranger: SideEventArranger(), // To define how simultaneous events will be arranged. onEventTap: (events, date) => print(events), onDateLongPress: (date) => print(date), + startHour: 5 // To set the first hour displayed (ex: 05:00) hourLinePainter: (lineColor, lineHeight, offset, minuteHeight, showVerticalLine, verticalLineOffset) { return //Your custom painter. } @@ -203,6 +204,7 @@ WeekView( onEventTap: (events, date) => print(events), onDateLongPress: (date) => print(date), startDay: WeekDays.sunday, // To change the first day of the week. + startHour: 5 // To set the first hour displayed (ex: 05:00) showVerticalLines: false, // Show the vertical line between days. hourLinePainter: (lineColor, lineHeight, offset, minuteHeight, showVerticalLine, verticalLineOffset) { return //Your custom painter. diff --git a/lib/src/components/_internal_components.dart b/lib/src/components/_internal_components.dart index 1de3e334..a79111d9 100644 --- a/lib/src/components/_internal_components.dart +++ b/lib/src/components/_internal_components.dart @@ -127,6 +127,9 @@ class TimeLine extends StatefulWidget { /// Flag to display half hours. final bool showHalfHours; + /// First hour displayed in the layout + final int startHour; + /// Flag to display quarter hours. final bool showQuarterHours; @@ -146,6 +149,7 @@ class TimeLine extends StatefulWidget { required this.height, required this.timeLineOffset, required this.timeLineBuilder, + required this.startHour, this.showHalfHours = false, this.showQuarterHours = false, required this.liveTimeIndicatorSettings, @@ -195,22 +199,23 @@ class _TimeLineState extends State { ), child: Stack( children: [ - for (int i = 1; i < Constants.hoursADay; i++) + for (int i = widget.startHour + 1; i < Constants.hoursADay; i++) _timelinePositioned( - topPosition: widget.hourHeight * i - widget.timeLineOffset, + topPosition: widget.hourHeight * (i - widget.startHour) - + widget.timeLineOffset, bottomPosition: widget.height - - (widget.hourHeight * (i + 1)) + + (widget.hourHeight * (i - widget.startHour + 1)) + widget.timeLineOffset, hour: i, ), if (widget.showHalfHours) - for (int i = 0; i < Constants.hoursADay; i++) + for (int i = widget.startHour; i < Constants.hoursADay; i++) _timelinePositioned( - topPosition: widget.hourHeight * i - + topPosition: widget.hourHeight * (i - widget.startHour) - widget.timeLineOffset + widget._halfHourHeight, bottomPosition: widget.height - - (widget.hourHeight * (i + 1)) + + (widget.hourHeight * (i - widget.startHour + 1)) + widget.timeLineOffset, hour: i, minutes: 30, @@ -304,6 +309,9 @@ class EventGenerator extends StatelessWidget { /// Defines date for which events will be displayed in given display area. final DateTime date; + /// First hour displayed in the layout + final int startHour; + /// Called when user taps on event tile. final CellTapCallback? onTileTap; @@ -317,6 +325,7 @@ class EventGenerator extends StatelessWidget { required this.events, required this.heightPerMinute, required this.eventArranger, + required this.startHour, required this.eventTileBuilder, required this.date, required this.onTileTap, @@ -328,11 +337,11 @@ class EventGenerator extends StatelessWidget { /// of events and [eventTileBuilder] to display events. List _generateEvents(BuildContext context) { final events = eventArranger.arrange( - events: this.events, - height: height, - width: width, - heightPerMinute: heightPerMinute, - ); + events: this.events, + height: height, + width: width, + heightPerMinute: heightPerMinute, + startHour: startHour); return List.generate(events.length, (index) { return Positioned( @@ -429,6 +438,9 @@ class PressDetector extends StatelessWidget { /// where events are not available. final MinuteSlotSize minuteSlotSize; + /// First hour displayed in the layout + final int startHour; + /// A widget that display event tiles in day/week view. const PressDetector({ Key? key, @@ -439,12 +451,14 @@ class PressDetector extends StatelessWidget { required this.onDateLongPress, required this.onDateTap, required this.minuteSlotSize, + required this.startHour, }) : super(key: key); @override Widget build(BuildContext context) { final heightPerSlot = minuteSlotSize.minutes * heightPerMinute; - final slots = (Constants.hoursADay * 60) ~/ minuteSlotSize.minutes; + final slots = + ((Constants.hoursADay - startHour) * 60) ~/ minuteSlotSize.minutes; return Container( height: height, diff --git a/lib/src/day_view/_internal_day_view_page.dart b/lib/src/day_view/_internal_day_view_page.dart index fd2b91bb..07abdb08 100644 --- a/lib/src/day_view/_internal_day_view_page.dart +++ b/lib/src/day_view/_internal_day_view_page.dart @@ -104,6 +104,9 @@ class InternalDayViewPage extends StatelessWidget { /// Settings for half hour indicator lines. final HourIndicatorSettings halfHourIndicatorSettings; + /// First hour displayed in the layout + final int startHour; + /// Settings for half hour indicator lines. final HourIndicatorSettings quarterHourIndicatorSettings; @@ -143,6 +146,7 @@ class InternalDayViewPage extends StatelessWidget { required this.showHalfHours, required this.showQuarterHours, required this.halfHourIndicatorSettings, + required this.startHour, required this.quarterHourIndicatorSettings, required this.emulateVerticalOffsetBy, }) : super(key: key); @@ -168,18 +172,18 @@ class InternalDayViewPage extends StatelessWidget { children: [ CustomPaint( size: Size(width, height), - painter: hourLinePainter( - hourIndicatorSettings.color, - hourIndicatorSettings.height, - timeLineWidth + hourIndicatorSettings.offset, - heightPerMinute, - showVerticalLine, - verticalLineOffset, - hourIndicatorSettings.lineStyle, - hourIndicatorSettings.dashWidth, - hourIndicatorSettings.dashSpaceWidth, - emulateVerticalOffsetBy, - ), + painter: HourLinePainter( + lineColor: hourIndicatorSettings.color, + lineHeight: hourIndicatorSettings.height, + offset: timeLineWidth + hourIndicatorSettings.offset, + minuteHeight: heightPerMinute, + verticalLineOffset: verticalLineOffset, + showVerticalLine: showVerticalLine, + lineStyle: hourIndicatorSettings.lineStyle, + dashWidth: hourIndicatorSettings.dashWidth, + dashSpaceWidth: hourIndicatorSettings.dashSpaceWidth, + emulateVerticalOffsetBy: emulateVerticalOffsetBy, + startHour: startHour), ), if (showHalfHours) CustomPaint( @@ -194,6 +198,7 @@ class InternalDayViewPage extends StatelessWidget { dashWidth: halfHourIndicatorSettings.dashWidth, dashSpaceWidth: halfHourIndicatorSettings.dashSpaceWidth, + startHour: startHour, ), ), if (showQuarterHours) @@ -232,6 +237,7 @@ class InternalDayViewPage extends StatelessWidget { heightPerMinute: heightPerMinute, eventTileBuilder: eventTileBuilder, scrollNotifier: scrollNotifier, + startHour: startHour, width: width - timeLineWidth - hourIndicatorSettings.offset - @@ -245,6 +251,7 @@ class InternalDayViewPage extends StatelessWidget { timeLineOffset: timeLineOffset, timeLineWidth: timeLineWidth, showHalfHours: showHalfHours, + startHour: startHour, showQuarterHours: showQuarterHours, key: ValueKey(heightPerMinute), liveTimeIndicatorSettings: liveTimeIndicatorSettings, diff --git a/lib/src/day_view/day_view.dart b/lib/src/day_view/day_view.dart index d8c457f5..98006562 100644 --- a/lib/src/day_view/day_view.dart +++ b/lib/src/day_view/day_view.dart @@ -197,6 +197,9 @@ class DayView extends StatefulWidget { /// Display full day event builder. final FullDayEventBuilder? fullDayEventBuilder; + /// First hour displayed in the layout, goes from 0 to 24 + final int? startHour; + /// Show half hour indicator final bool showHalfHours; @@ -254,6 +257,7 @@ class DayView extends StatefulWidget { this.showHalfHours = false, this.showQuarterHours = false, this.halfHourIndicatorSettings, + this.startHour, this.quarterHourIndicatorSettings, this.startDuration = const Duration(hours: 0), this.onHeaderTitleTap, @@ -289,6 +293,7 @@ class DayViewState extends State> { late DateTime _minDate; late int _totalDays; late int _currentIndex; + late int _startHour; late EventArranger _eventArranger; @@ -325,6 +330,9 @@ class DayViewState extends State> { void initState() { super.initState(); + _startHour = widget.startHour ?? 0; + if (_startHour > 24) _startHour = 0; + _reloadCallback = _reload; _setDateRange(); @@ -462,6 +470,7 @@ class DayViewState extends State> { showQuarterHours: widget.showQuarterHours, halfHourIndicatorSettings: _halfHourIndicatorSettings, + startHour: _startHour, quarterHourIndicatorSettings: _quarterHourIndicatorSettings, emulateVerticalOffsetBy: @@ -547,7 +556,7 @@ class DayViewState extends State> { void _calculateHeights() { _hourHeight = widget.heightPerMinute * 60; - _height = _hourHeight * Constants.hoursADay; + _height = _hourHeight * (Constants.hoursADay - _startHour); } void _assignBuilders() { @@ -710,29 +719,29 @@ class DayViewState extends State> { FullDayEventView(events: events, date: date); HourLinePainter _defaultHourLinePainter( - Color lineColor, - double lineHeight, - double offset, - double minuteHeight, - bool showVerticalLine, - double verticalLineOffset, - LineStyle lineStyle, - double dashWidth, - double dashSpaceWidth, - double emulateVerticalOffsetBy, - ) { + Color lineColor, + double lineHeight, + double offset, + double minuteHeight, + bool showVerticalLine, + double verticalLineOffset, + LineStyle lineStyle, + double dashWidth, + double dashSpaceWidth, + double emulateVerticalOffsetBy, + int startHour) { return HourLinePainter( - lineColor: lineColor, - lineHeight: lineHeight, - offset: offset, - minuteHeight: minuteHeight, - verticalLineOffset: verticalLineOffset, - showVerticalLine: showVerticalLine, - lineStyle: lineStyle, - dashWidth: dashWidth, - dashSpaceWidth: dashSpaceWidth, - emulateVerticalOffsetBy: emulateVerticalOffsetBy, - ); + lineColor: lineColor, + lineHeight: lineHeight, + offset: offset, + minuteHeight: minuteHeight, + verticalLineOffset: verticalLineOffset, + showVerticalLine: showVerticalLine, + lineStyle: lineStyle, + dashWidth: dashWidth, + dashSpaceWidth: dashSpaceWidth, + emulateVerticalOffsetBy: emulateVerticalOffsetBy, + startHour: startHour); } /// Called when user change page using any gesture or inbuilt functions. diff --git a/lib/src/event_arrangers/event_arrangers.dart b/lib/src/event_arrangers/event_arrangers.dart index 001d304a..96f2c853 100644 --- a/lib/src/event_arrangers/event_arrangers.dart +++ b/lib/src/event_arrangers/event_arrangers.dart @@ -36,6 +36,7 @@ abstract class EventArranger { required double height, required double width, required double heightPerMinute, + required int startHour, }); } diff --git a/lib/src/event_arrangers/merge_event_arranger.dart b/lib/src/event_arrangers/merge_event_arranger.dart index 0b8a7a6f..71b68962 100644 --- a/lib/src/event_arrangers/merge_event_arranger.dart +++ b/lib/src/event_arrangers/merge_event_arranger.dart @@ -31,12 +31,14 @@ class MergeEventArranger extends EventArranger { required double height, required double width, required double heightPerMinute, + required int startHour, }) { // TODO: Right now all the events that are passed in this function must be // sorted in ascending order of the start time. // final arrangedEvents = >[]; + //Checking if startTime and endTime are correct for (final event in events) { // Checks if an event has valid start and end time. if (event.startTime == null || @@ -62,10 +64,13 @@ class MergeEventArranger extends EventArranger { final startTime = event.startTime!; final endTime = event.endTime!; - final eventStart = startTime.getTotalMinutes; - final eventEnd = endTime.getTotalMinutes == 0 - ? Constants.minutesADay - : endTime.getTotalMinutes; + // startTime.getTotalMinutes returns the number of minutes from 00h00 to the beginning of the event + // But the first hour to be displayed (startHour) could be 06h00, so we have to substract + // The number of minutes from 00h00 to startHour which is equal to startHour * 60 + final eventStart = startTime.getTotalMinutes - (startHour * 60); + final eventEnd = endTime.getTotalMinutes - (startHour * 60) == 0 + ? Constants.minutesADay - (startHour * 60) + : endTime.getTotalMinutes - (startHour * 60); final arrangeEventLen = arrangedEvents.length; diff --git a/lib/src/event_arrangers/side_event_arranger.dart b/lib/src/event_arrangers/side_event_arranger.dart index d23e2e83..d6355927 100644 --- a/lib/src/event_arrangers/side_event_arranger.dart +++ b/lib/src/event_arrangers/side_event_arranger.dart @@ -29,6 +29,7 @@ class SideEventArranger extends EventArranger { required double height, required double width, required double heightPerMinute, + required int startHour, }) { final mergedEvents = MergeEventArranger( includeEdges: includeEdges, @@ -37,6 +38,7 @@ class SideEventArranger extends EventArranger { height: height, width: width, heightPerMinute: heightPerMinute, + startHour: startHour, ); final arrangedEvents = >[]; @@ -100,15 +102,24 @@ class SideEventArranger extends EventArranger { final startTime = sideEvent.event.startTime!; final endTime = sideEvent.event.endTime!; + + // startTime.getTotalMinutes returns the number of minutes from 00h00 to the beginning hour of the event + // But the first hour to be displayed (startHour) could be 06h00, so we have to substract + // The number of minutes from 00h00 to startHour which is equal to startHour * 60 + final bottom = height - - (endTime.getTotalMinutes == 0 - ? Constants.minutesADay - : endTime.getTotalMinutes) * + (endTime.getTotalMinutes - (startHour * 60) == 0 + ? Constants.minutesADay - (startHour * 60) + : endTime.getTotalMinutes - (startHour * 60)) * heightPerMinute; + + final top = + (startTime.getTotalMinutes - (startHour * 60)) * heightPerMinute; + arrangedEvents.add(OrganizedCalendarEventData( left: slotWidth * (sideEvent.column - 1), right: slotWidth * (column - sideEvent.column), - top: startTime.getTotalMinutes * heightPerMinute, + top: top, bottom: bottom, startDuration: startTime, endDuration: endTime, diff --git a/lib/src/modals.dart b/lib/src/modals.dart index 73039972..5fc80acb 100644 --- a/lib/src/modals.dart +++ b/lib/src/modals.dart @@ -15,16 +15,18 @@ class HourIndicatorSettings { final LineStyle lineStyle; final double dashWidth; final double dashSpaceWidth; + final int startHour; /// Settings for hour lines - const HourIndicatorSettings({ - this.height = 1.0, - this.offset = 0.0, - this.color = Colors.grey, - this.lineStyle = LineStyle.solid, - this.dashWidth = 4, - this.dashSpaceWidth = 4, - }) : assert(height >= 0, "Height must be greater than or equal to 0."); + const HourIndicatorSettings( + {this.height = 1.0, + this.offset = 0.0, + this.color = Colors.grey, + this.lineStyle = LineStyle.solid, + this.dashWidth = 4, + this.dashSpaceWidth = 4, + this.startHour = 0}) + : assert(height >= 0, "Height must be greater than or equal to 0."); factory HourIndicatorSettings.none() => HourIndicatorSettings( color: Colors.transparent, diff --git a/lib/src/painters.dart b/lib/src/painters.dart index 9659d9c7..60439c2c 100644 --- a/lib/src/painters.dart +++ b/lib/src/painters.dart @@ -38,6 +38,9 @@ class HourLinePainter extends CustomPainter { /// Line dash space width when using the [LineStyle.dashed] style final double dashSpaceWidth; + /// First hour displayed in the layout + final int startHour; + /// Emulates offset of vertical line from hour line starts. final double emulateVerticalOffsetBy; @@ -48,6 +51,7 @@ class HourLinePainter extends CustomPainter { required this.minuteHeight, required this.offset, required this.showVerticalLine, + required this.startHour, required this.emulateVerticalOffsetBy, this.verticalLineOffset = 10, this.lineStyle = LineStyle.solid, @@ -62,8 +66,8 @@ class HourLinePainter extends CustomPainter { ..color = lineColor ..strokeWidth = lineHeight; - for (var i = 1; i < Constants.hoursADay; i++) { - final dy = i * minuteHeight * 60; + for (var i = startHour + 1; i < Constants.hoursADay; i++) { + final dy = (i - startHour) * minuteHeight * 60; if (lineStyle == LineStyle.dashed) { var startX = dx; while (startX < size.width) { @@ -122,6 +126,9 @@ class HalfHourLinePainter extends CustomPainter { /// Line dash space width when using the [LineStyle.dashed] style final double dashSpaceWidth; + /// First hour displayed in the layout + final int startHour; + /// Paint half hour lines HalfHourLinePainter({ required this.lineColor, @@ -129,6 +136,7 @@ class HalfHourLinePainter extends CustomPainter { required this.offset, required this.minuteHeight, required this.lineStyle, + required this.startHour, this.dashWidth = 4, this.dashSpaceWidth = 4, }); @@ -139,8 +147,8 @@ class HalfHourLinePainter extends CustomPainter { ..color = lineColor ..strokeWidth = lineHeight; - for (var i = 0; i < Constants.hoursADay; i++) { - final dy = i * minuteHeight * 60 + (minuteHeight * 30); + for (var i = startHour; i < Constants.hoursADay; i++) { + final dy = (i - startHour) * minuteHeight * 60 + (minuteHeight * 30); if (lineStyle == LineStyle.dashed) { var startX = offset; while (startX < size.width) { diff --git a/lib/src/typedefs.dart b/lib/src/typedefs.dart index f517c492..99d12541 100644 --- a/lib/src/typedefs.dart +++ b/lib/src/typedefs.dart @@ -73,16 +73,16 @@ typedef EventFilter = List> Function( DateTime date, List> events); typedef CustomHourLinePainter = CustomPainter Function( - Color lineColor, - double lineHeight, - double offset, - double minuteHeight, - bool showVerticalLine, - double verticalLineOffset, - LineStyle lineStyle, - double dashWidth, - double dashSpaceWidth, - double emulateVerticalOffsetBy, -); + Color lineColor, + double lineHeight, + double offset, + double minuteHeight, + bool showVerticalLine, + double verticalLineOffset, + LineStyle lineStyle, + double dashWidth, + double dashSpaceWidth, + double emulateVerticalOffsetBy, + int startHour); typedef TestPredicate = bool Function(T element); diff --git a/lib/src/week_view/_internal_week_view_page.dart b/lib/src/week_view/_internal_week_view_page.dart index f85a972a..cbdac1a1 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; + /// First hour displayed in the layout + final int startHour; + /// If true this will show week day at bottom position. final bool showWeekDayAtBottom; @@ -165,6 +168,7 @@ class InternalWeekViewPage extends StatelessWidget { required this.weekDays, required this.minuteSlotSize, required this.scrollConfiguration, + required this.startHour, required this.fullDayEventBuilder, required this.weekDetectorBuilder, required this.showWeekDayAtBottom, @@ -245,34 +249,31 @@ class InternalWeekViewPage extends StatelessWidget { child: Stack( children: [ CustomPaint( - size: Size(width, height), - painter: hourLinePainter( - hourIndicatorSettings.color, - hourIndicatorSettings.height, - timeLineWidth + hourIndicatorSettings.offset, - heightPerMinute, - showVerticalLine, - verticalLineOffset, - hourIndicatorSettings.lineStyle, - hourIndicatorSettings.dashWidth, - hourIndicatorSettings.dashSpaceWidth, - emulateVerticalOffsetBy, - ), - ), + size: Size(width, height), + painter: HourLinePainter( + lineColor: hourIndicatorSettings.color, + lineHeight: hourIndicatorSettings.height, + offset: + timeLineWidth + hourIndicatorSettings.offset, + minuteHeight: heightPerMinute, + verticalLineOffset: verticalLineOffset, + showVerticalLine: showVerticalLine, + startHour: startHour, + emulateVerticalOffsetBy: emulateVerticalOffsetBy)), 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, - ), + lineColor: halfHourIndicatorSettings.color, + lineHeight: halfHourIndicatorSettings.height, + offset: timeLineWidth + + halfHourIndicatorSettings.offset, + minuteHeight: heightPerMinute, + lineStyle: halfHourIndicatorSettings.lineStyle, + dashWidth: halfHourIndicatorSettings.dashWidth, + dashSpaceWidth: + halfHourIndicatorSettings.dashSpaceWidth, + startHour: halfHourIndicatorSettings.startHour), ), if (showQuarterHours) CustomPaint( @@ -328,6 +329,7 @@ class InternalWeekViewPage extends StatelessWidget { eventArranger: eventArranger, eventTileBuilder: eventTileBuilder, scrollNotifier: scrollConfiguration, + startHour: startHour, events: controller.getEventsOnDay( filteredDates[index], includeFullDayEvents: false, @@ -348,6 +350,7 @@ class InternalWeekViewPage extends StatelessWidget { height: height, timeLineOffset: timeLineOffset, timeLineBuilder: timeLineBuilder, + startHour: startHour, showHalfHours: showHalfHours, showQuarterHours: showQuarterHours, liveTimeIndicatorSettings: liveTimeIndicatorSettings, diff --git a/lib/src/week_view/week_view.dart b/lib/src/week_view/week_view.dart index 664a68b2..2147774b 100644 --- a/lib/src/week_view/week_view.dart +++ b/lib/src/week_view/week_view.dart @@ -198,6 +198,9 @@ class WeekView extends StatefulWidget { /// Display full day event builder. final FullDayEventBuilder? fullDayEventBuilder; + /// First hour displayed in the layout, goes from 0 to 24 + final int? startHour; + ///Show half hour indicator final bool showHalfHours; @@ -258,6 +261,7 @@ class WeekView extends StatefulWidget { this.headerStyle = const HeaderStyle(), this.safeAreaOption = const SafeAreaOption(), this.fullDayEventBuilder, + this.startHour, this.onHeaderTitleTap, this.showHalfHours = false, this.showQuarterHours = false, @@ -329,12 +333,18 @@ class WeekViewState extends State> { late List _weekDays; + late int _startHour; + final _scrollConfiguration = EventScrollConfiguration(); @override void initState() { super.initState(); + _startHour = widget.startHour ?? 0; + //Security to avoid any height bug + if (_startHour > 24) _startHour = 0; + _reloadCallback = _reload; _setWeekDays(); @@ -486,6 +496,7 @@ class WeekViewState extends State> { minuteSlotSize: widget.minuteSlotSize, scrollConfiguration: _scrollConfiguration, fullDayEventBuilder: _fullDayEventBuilder, + startHour: _startHour, showHalfHours: widget.showHalfHours, showQuarterHours: widget.showQuarterHours, emulateVerticalOffsetBy: @@ -589,7 +600,7 @@ class WeekViewState extends State> { void _calculateHeights() { _hourHeight = widget.heightPerMinute * 60; - _height = _hourHeight * Constants.hoursADay; + _height = _hourHeight * (Constants.hoursADay - _startHour); } void _assignBuilders() { @@ -667,7 +678,8 @@ class WeekViewState extends State> { required MinuteSlotSize minuteSlotSize, }) { final heightPerSlot = minuteSlotSize.minutes * heightPerMinute; - final slots = (Constants.hoursADay * 60) ~/ minuteSlotSize.minutes; + final slots = + ((Constants.hoursADay - _startHour) * 60) ~/ minuteSlotSize.minutes; return Container( height: height, @@ -821,29 +833,29 @@ class WeekViewState extends State> { } HourLinePainter _defaultHourLinePainter( - Color lineColor, - double lineHeight, - double offset, - double minuteHeight, - bool showVerticalLine, - double verticalLineOffset, - LineStyle lineStyle, - double dashWidth, - double dashSpaceWidth, - double emulateVerticalOffsetBy, - ) { + Color lineColor, + double lineHeight, + double offset, + double minuteHeight, + bool showVerticalLine, + double verticalLineOffset, + LineStyle lineStyle, + double dashWidth, + double dashSpaceWidth, + double emulateVerticalOffsetBy, + int startHour) { return HourLinePainter( - lineColor: lineColor, - lineHeight: lineHeight, - offset: offset, - minuteHeight: minuteHeight, - verticalLineOffset: verticalLineOffset, - showVerticalLine: showVerticalLine, - lineStyle: lineStyle, - dashWidth: dashWidth, - dashSpaceWidth: dashSpaceWidth, - emulateVerticalOffsetBy: emulateVerticalOffsetBy, - ); + lineColor: lineColor, + lineHeight: lineHeight, + offset: offset, + minuteHeight: minuteHeight, + verticalLineOffset: verticalLineOffset, + showVerticalLine: showVerticalLine, + lineStyle: lineStyle, + dashWidth: dashWidth, + dashSpaceWidth: dashSpaceWidth, + emulateVerticalOffsetBy: emulateVerticalOffsetBy, + startHour: startHour); } /// Called when user change page using any gesture or inbuilt functions. diff --git a/test/event_arranger_test/merge_event_arranger_test.dart b/test/event_arranger_test/merge_event_arranger_test.dart index 33a32de4..1e32e186 100644 --- a/test/event_arranger_test/merge_event_arranger_test.dart +++ b/test/event_arranger_test/merge_event_arranger_test.dart @@ -4,6 +4,7 @@ import 'package:flutter_test/flutter_test.dart'; const height = 1440.0; const width = 500.0; const heightPerMinute = 1.0; +const startHour = 0; void main() { final now = DateTime.now().withoutTime; @@ -54,11 +55,11 @@ void main() { ]; final mergedEvents = MergeEventArranger().arrange( - events: events, - height: height, - width: width, - heightPerMinute: heightPerMinute, - ); + events: events, + height: height, + width: width, + heightPerMinute: heightPerMinute, + startHour: startHour); expect(mergedEvents.length, events.length); }); @@ -83,11 +84,11 @@ void main() { ]; final mergedEvents = MergeEventArranger().arrange( - events: events, - height: height, - width: width, - heightPerMinute: heightPerMinute, - ); + events: events, + height: height, + width: width, + heightPerMinute: heightPerMinute, + startHour: startHour); expect(mergedEvents.length, 1); }); @@ -112,11 +113,11 @@ void main() { ]; final mergedEvents = MergeEventArranger().arrange( - events: events, - height: height, - width: width, - heightPerMinute: heightPerMinute, - ); + events: events, + height: height, + width: width, + heightPerMinute: heightPerMinute, + startHour: startHour); expect(mergedEvents.length, 1); }); @@ -141,11 +142,11 @@ void main() { ]; final mergedEvents = MergeEventArranger().arrange( - events: events, - height: height, - width: width, - heightPerMinute: heightPerMinute, - ); + events: events, + height: height, + width: width, + heightPerMinute: heightPerMinute, + startHour: startHour); expect(mergedEvents.length, 1); }); @@ -170,11 +171,11 @@ void main() { ]; final mergedEvents = MergeEventArranger().arrange( - events: events, - height: height, - width: width, - heightPerMinute: heightPerMinute, - ); + events: events, + height: height, + width: width, + heightPerMinute: heightPerMinute, + startHour: startHour); expect(mergedEvents.length, 1); }); @@ -199,11 +200,11 @@ void main() { ]; final mergedEvents = MergeEventArranger().arrange( - events: events, - height: height, - width: width, - heightPerMinute: heightPerMinute, - ); + events: events, + height: height, + width: width, + heightPerMinute: heightPerMinute, + startHour: startHour); expect(mergedEvents.length, 1); }); @@ -260,11 +261,11 @@ void main() { ]; final mergedEvents = MergeEventArranger().arrange( - events: events, - height: height, - width: width, - heightPerMinute: heightPerMinute, - ); + events: events, + height: height, + width: width, + heightPerMinute: heightPerMinute, + startHour: startHour); expect(mergedEvents.length, 4); }); @@ -321,14 +322,14 @@ void main() { ]; final mergedEvents = MergeEventArranger().arrange( - events: events - ..sort((e1, e2) => - (e1.startTime?.getTotalMinutes ?? 0) - - (e2.startTime?.getTotalMinutes ?? 0)), - height: height, - width: width, - heightPerMinute: heightPerMinute, - ); + events: events + ..sort((e1, e2) => + (e1.startTime?.getTotalMinutes ?? 0) - + (e2.startTime?.getTotalMinutes ?? 0)), + height: height, + width: width, + heightPerMinute: heightPerMinute, + startHour: startHour); expect(mergedEvents.length, 1); }); @@ -355,14 +356,14 @@ void main() { ]; final mergedEvents = MergeEventArranger(includeEdges: false).arrange( - events: events - ..sort((e1, e2) => - (e1.startTime?.getTotalMinutes ?? 0) - - (e2.startTime?.getTotalMinutes ?? 0)), - height: height, - width: width, - heightPerMinute: heightPerMinute, - ); + events: events + ..sort((e1, e2) => + (e1.startTime?.getTotalMinutes ?? 0) - + (e2.startTime?.getTotalMinutes ?? 0)), + height: height, + width: width, + heightPerMinute: heightPerMinute, + startHour: startHour); expect(mergedEvents.length, 2); }); @@ -388,14 +389,14 @@ void main() { ]; final mergedEvents = MergeEventArranger(includeEdges: false).arrange( - events: events - ..sort((e1, e2) => - (e1.startTime?.getTotalMinutes ?? 0) - - (e2.startTime?.getTotalMinutes ?? 0)), - height: height, - width: width, - heightPerMinute: heightPerMinute, - ); + events: events + ..sort((e1, e2) => + (e1.startTime?.getTotalMinutes ?? 0) - + (e2.startTime?.getTotalMinutes ?? 0)), + height: height, + width: width, + heightPerMinute: heightPerMinute, + startHour: startHour); expect(mergedEvents.length, 2); }); @@ -422,14 +423,14 @@ void main() { ]; final mergedEvents = MergeEventArranger(includeEdges: true).arrange( - events: events - ..sort((e1, e2) => - (e1.startTime?.getTotalMinutes ?? 0) - - (e2.startTime?.getTotalMinutes ?? 0)), - height: height, - width: width, - heightPerMinute: heightPerMinute, - ); + events: events + ..sort((e1, e2) => + (e1.startTime?.getTotalMinutes ?? 0) - + (e2.startTime?.getTotalMinutes ?? 0)), + height: height, + width: width, + heightPerMinute: heightPerMinute, + startHour: startHour); expect(mergedEvents.length, 1); }); @@ -455,14 +456,14 @@ void main() { ]; final mergedEvents = MergeEventArranger(includeEdges: true).arrange( - events: events - ..sort((e1, e2) => - (e1.startTime?.getTotalMinutes ?? 0) - - (e2.startTime?.getTotalMinutes ?? 0)), - height: height, - width: width, - heightPerMinute: heightPerMinute, - ); + events: events + ..sort((e1, e2) => + (e1.startTime?.getTotalMinutes ?? 0) - + (e2.startTime?.getTotalMinutes ?? 0)), + height: height, + width: width, + heightPerMinute: heightPerMinute, + startHour: startHour); expect(mergedEvents.length, 1); });