From e8f560036ebbdee006a2494760a57c2a30580583 Mon Sep 17 00:00:00 2001 From: Ravi Date: Fri, 17 May 2024 17:09:12 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9BLiveTimeLine=20autoscroll=20?= =?UTF-8?q?added=20#331=20(#331)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/day_view/day_view.dart | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/src/day_view/day_view.dart b/lib/src/day_view/day_view.dart index 98006562..82f7641b 100644 --- a/lib/src/day_view/day_view.dart +++ b/lib/src/day_view/day_view.dart @@ -414,6 +414,9 @@ class DayViewState extends State> { child: LayoutBuilder(builder: (context, constraint) { _width = widget.width ?? constraint.maxWidth; _updateViewDimensions(); + if (widget.showLiveTimeLineInAllDays) { + animateToLiveTimeLineIndicator(); + } return SizedBox( width: _width, child: Column( @@ -554,6 +557,23 @@ class DayViewState extends State> { "quarterHourIndicator height must be less than minuteHeight * 60"); } + void animateToLiveTimeLineIndicator() { + final offSetForSingleMinute = _height / 24 / 60; + final currentTime = TimeOfDay.now(); + final currentDuration = + Duration(hours: currentTime.hour, minutes: currentTime.minute) + .inMinutes; + var offset = offSetForSingleMinute * + (currentDuration > 3600 ? 3600 : currentDuration); + Future.delayed(Duration(milliseconds: 500), () { + animateTo( + offset.toDouble() - (MediaQuery.of(context).size.height / 2), + duration: Duration(milliseconds: 600), + curve: Curves.easeInOut, + ); + }); + } + void _calculateHeights() { _hourHeight = widget.heightPerMinute * 60; _height = _hourHeight * (Constants.hoursADay - _startHour); @@ -887,6 +907,7 @@ class DayViewState extends State> { // above 24 hrs then we take it max as 24 hours only final offset = offSetForSingleMinute * (startDurationInMinutes > 3600 ? 3600 : startDurationInMinutes); + animateTo( offset.toDouble(), duration: duration,