diff --git a/lib/src/components/common_components.dart b/lib/src/components/common_components.dart index 227fc001..43297722 100644 --- a/lib/src/components/common_components.dart +++ b/lib/src/components/common_components.dart @@ -7,10 +7,10 @@ import 'package:flutter/material.dart'; import '../calendar_event_data.dart'; import '../constants.dart'; +import '../enumerations.dart'; import '../extensions.dart'; import '../style/header_style.dart'; import '../typedefs.dart'; -import '../enumerations.dart'; import 'components.dart'; class CalendarPageHeader extends StatelessWidget { @@ -172,6 +172,11 @@ class DefaultPressDetector extends StatelessWidget { child: SizedBox( width: width, height: heightPerSlot, + child: kDebugMode + ? ColoredBox( + color: Colors.red.withOpacity(0.2), + ) + : SizedBox.shrink(), ), ), ), diff --git a/lib/src/day_view/_internal_day_view_page.dart b/lib/src/day_view/_internal_day_view_page.dart index 5e9ef816..302d94f6 100644 --- a/lib/src/day_view/_internal_day_view_page.dart +++ b/lib/src/day_view/_internal_day_view_page.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../components/_internal_components.dart'; @@ -241,24 +242,23 @@ class _InternalDayViewPageState // Shows line for one hour. CustomPaint( size: Size(widget.width, widget.height), - painter: HourLinePainter( - lineColor: widget.hourIndicatorSettings.color, - lineHeight: widget.hourIndicatorSettings.height, - offset: widget.timeLineWidth + + painter: widget.hourLinePainter( + widget.hourIndicatorSettings.color, + widget.hourIndicatorSettings.height, + widget.timeLineWidth + widget.hourIndicatorSettings.offset, - minuteHeight: widget.heightPerMinute, - verticalLineOffset: widget.verticalLineOffset, - showVerticalLine: widget.showVerticalLine, - lineStyle: widget.hourIndicatorSettings.lineStyle, - dashWidth: widget.hourIndicatorSettings.dashWidth, - dashSpaceWidth: - widget.hourIndicatorSettings.dashSpaceWidth, - emulateVerticalOffsetBy: widget.emulateVerticalOffsetBy, - startHour: widget.startHour, - endHour: widget.endHour, - padding: widget.pagePadding, - showEndHour: widget.showEndHours, - showStartHour: widget.showStartHours, + widget.heightPerMinute, + widget.showVerticalLine, + widget.verticalLineOffset, + widget.hourIndicatorSettings.lineStyle, + widget.hourIndicatorSettings.dashWidth, + widget.hourIndicatorSettings.dashSpaceWidth, + widget.emulateVerticalOffsetBy, + widget.startHour, + widget.endHour, + widget.showStartHours, + widget.showEndHours, + widget.pagePadding, ), ), // Shows lines for Half hours @@ -306,12 +306,15 @@ class _InternalDayViewPageState //#endregion // Enables gesture in empty areas. - widget.dayDetectorBuilder( - width: widget.width, - height: widget.height, - heightPerMinute: widget.heightPerMinute, - date: widget.date, - minuteSlotSize: widget.minuteSlotSize, + Padding( + padding: widget.pagePadding, + child: widget.dayDetectorBuilder( + width: widget.width, + height: widget.height, + heightPerMinute: widget.heightPerMinute, + date: widget.date, + minuteSlotSize: widget.minuteSlotSize, + ), ), Align( alignment: Alignment.centerRight, diff --git a/lib/src/painters.dart b/lib/src/painters.dart index fd2d33b4..935d92dc 100644 --- a/lib/src/painters.dart +++ b/lib/src/painters.dart @@ -72,6 +72,7 @@ class HourLinePainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { + final startOffset = padding.top; final dx = offset + emulateVerticalOffsetBy; final paint = Paint() ..color = lineColor @@ -81,7 +82,8 @@ class HourLinePainter extends CustomPainter { final end = endHour + (showEndHour ? 1 : 0); for (var i = start; i < end; i++) { - final dy = (i - startHour) * minuteHeight * 60; + final dy = startOffset + ((i - startHour) * minuteHeight * 60); + if (lineStyle == LineStyle.dashed) { var startX = dx; while (startX < size.width) { @@ -171,12 +173,16 @@ class HalfHourLinePainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { + final startOffset = padding.top; + final paint = Paint() ..color = lineColor ..strokeWidth = lineHeight; for (var i = startHour; i < endHour; i++) { - final dy = (i - startHour) * minuteHeight * 60 + (minuteHeight * 30); + final dy = (i - startHour) * minuteHeight * 60 + + (minuteHeight * 30) + + startOffset; if (lineStyle == LineStyle.dashed) { var startX = offset; while (startX < size.width) { @@ -243,13 +249,15 @@ class QuarterHourLinePainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { + final startOffset = padding.top; + final paint = Paint() ..color = lineColor ..strokeWidth = lineHeight; for (var i = 0; i < Constants.hoursADay; i++) { - final dy1 = i * minuteHeight * 60 + (minuteHeight * 15); - final dy2 = i * minuteHeight * 60 + (minuteHeight * 45); + final dy1 = i * minuteHeight * 60 + (minuteHeight * 15) + startOffset; + final dy2 = i * minuteHeight * 60 + (minuteHeight * 45) + startOffset; if (lineStyle == LineStyle.dashed) { var startX = offset; diff --git a/lib/src/week_view/_internal_week_view_page.dart b/lib/src/week_view/_internal_week_view_page.dart index aa143b32..719370fe 100644 --- a/lib/src/week_view/_internal_week_view_page.dart +++ b/lib/src/week_view/_internal_week_view_page.dart @@ -354,21 +354,23 @@ class _InternalWeekViewPageState children: [ CustomPaint( size: Size(widget.width, widget.height), - painter: HourLinePainter( - lineColor: widget.hourIndicatorSettings.color, - lineHeight: widget.hourIndicatorSettings.height, - offset: widget.timeLineWidth + + painter: widget.hourLinePainter( + widget.hourIndicatorSettings.color, + widget.hourIndicatorSettings.height, + widget.timeLineWidth + widget.hourIndicatorSettings.offset, - minuteHeight: widget.heightPerMinute, - verticalLineOffset: widget.verticalLineOffset, - showVerticalLine: widget.showVerticalLine, - startHour: widget.startHour, - emulateVerticalOffsetBy: - widget.emulateVerticalOffsetBy, - endHour: widget.endHour, - padding: widget.pagePadding, - showEndHour: widget.showEndHours, - showStartHour: widget.showStartHours, + widget.heightPerMinute, + widget.showVerticalLine, + widget.verticalLineOffset, + widget.hourIndicatorSettings.lineStyle, + widget.hourIndicatorSettings.dashWidth, + widget.hourIndicatorSettings.dashSpaceWidth, + widget.emulateVerticalOffsetBy, + widget.startHour, + widget.endHour, + widget.showStartHours, + widget.showEndHours, + widget.pagePadding, ), ), if (widget.showHalfHours) @@ -442,12 +444,16 @@ class _InternalWeekViewPageState width: widget.weekTitleWidth, child: Stack( children: [ - widget.weekDetectorBuilder( - width: widget.weekTitleWidth, - height: widget.height, - heightPerMinute: widget.heightPerMinute, - date: widget.dates[index], - minuteSlotSize: widget.minuteSlotSize, + Padding( + padding: widget.pagePadding, + child: widget.weekDetectorBuilder( + width: widget.weekTitleWidth, + height: widget.height, + heightPerMinute: + widget.heightPerMinute, + date: widget.dates[index], + minuteSlotSize: widget.minuteSlotSize, + ), ), EventGenerator( height: widget.height,