Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weā€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: šŸ›live time indicator position on timeline is not correct when stā€¦ #349

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions lib/src/components/_internal_components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@ class LiveTimeIndicator extends StatefulWidget {
/// Defines height occupied by one minute.
final double heightPerMinute;

/// First hour displayed in the layout, goes from 0 to 24
final int startHour;

/// Widget to display tile line according to current time.
const LiveTimeIndicator(
{Key? key,
required this.width,
required this.height,
required this.timeLineWidth,
required this.liveTimeIndicatorSettings,
required this.heightPerMinute})
: super(key: key);
const LiveTimeIndicator({
Key? key,
required this.width,
required this.height,
required this.timeLineWidth,
required this.liveTimeIndicatorSettings,
required this.heightPerMinute,
required this.startHour,
}) : super(key: key);

@override
_LiveTimeIndicatorState createState() => _LiveTimeIndicatorState();
Expand Down Expand Up @@ -85,14 +89,19 @@ class _LiveTimeIndicatorState extends State<LiveTimeIndicator> {
final timeString = widget.liveTimeIndicatorSettings.timeStringBuilder
?.call(DateTime.now()) ??
'$currentHour:$currentMinute $currentPeriod';

/// remove startHour minute from [_currentTime.getTotalMinutes]
/// to set dy offset of live time indicator
final startMinutes = widget.startHour * 60;
return CustomPaint(
size: Size(widget.width, widget.liveTimeIndicatorSettings.height),
painter: CurrentTimeLinePainter(
color: widget.liveTimeIndicatorSettings.color,
height: widget.liveTimeIndicatorSettings.height,
offset: Offset(
widget.timeLineWidth + widget.liveTimeIndicatorSettings.offset,
_currentTime.getTotalMinutes * widget.heightPerMinute,
(_currentTime.getTotalMinutes - startMinutes) *
widget.heightPerMinute,
),
timeString: timeString,
showBullet: widget.liveTimeIndicatorSettings.showBullet,
Expand Down
1 change: 1 addition & 0 deletions lib/src/day_view/_internal_day_view_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ class InternalDayViewPage<T extends Object?> extends StatelessWidget {
height: height,
heightPerMinute: heightPerMinute,
timeLineWidth: timeLineWidth,
startHour: startHour,
),
),
],
Expand Down
1 change: 1 addition & 0 deletions lib/src/week_view/_internal_week_view_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ class InternalWeekViewPage<T extends Object?> extends StatelessWidget {
height: height,
heightPerMinute: heightPerMinute,
timeLineWidth: timeLineWidth,
startHour: startHour,
),
],
),
Expand Down
Loading