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: 🐛LiveTimeLine autoscroll added #331 (#331) #369

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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
Loading