Skip to content

Commit

Permalink
fix: 🐛LiveTimeLine autoscroll added SimformSolutionsPvtLtd#331 (Simfo…
Browse files Browse the repository at this point in the history
  • Loading branch information
ravilsimform committed May 17, 2024
1 parent ed7288e commit e8f5600
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/src/day_view/day_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {
child: LayoutBuilder(builder: (context, constraint) {
_width = widget.width ?? constraint.maxWidth;
_updateViewDimensions();
if (widget.showLiveTimeLineInAllDays) {
animateToLiveTimeLineIndicator();
}
return SizedBox(
width: _width,
child: Column(
Expand Down Expand Up @@ -554,6 +557,23 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {
"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);
Expand Down Expand Up @@ -887,6 +907,7 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {
// above 24 hrs then we take it max as 24 hours only
final offset = offSetForSingleMinute *
(startDurationInMinutes > 3600 ? 3600 : startDurationInMinutes);

animateTo(
offset.toDouble(),
duration: duration,
Expand Down

0 comments on commit e8f5600

Please sign in to comment.