Reimplemented _Times disabled state and implemented in scroll/page controller animations.

This commit is contained in:
Alex Garneau
2025-03-27 10:11:28 -06:00
parent 91af2b386d
commit e109b8ee64
4 changed files with 12 additions and 8 deletions

View File

@ -42,7 +42,8 @@ class AppStyle {
late final _Text text = _Text(scale);
/// Animation Durations
final _Times times = _Times();
late final _Times times = _Times(disableAnimations);
late final _CustomTime customTime = _CustomTime(disableAnimations);
/// Shared sizes
late final _Sizes sizes = _Sizes();
@ -135,10 +136,13 @@ class _Text {
@immutable
class _Times {
final Duration fast = Duration(milliseconds: 300);
final Duration med = Duration(milliseconds: 600);
final Duration slow = Duration(milliseconds: 900);
final Duration pageTransition = Duration(milliseconds: 200);
_Times(this.disabled);
final bool disabled;
late final Duration fast = Duration(milliseconds: disabled ? 1 : 300);
late final Duration med = Duration(milliseconds: disabled ? 1 : 600);
late final Duration slow = Duration(milliseconds: disabled ? 1 : 900);
late final Duration extraSlow = Duration(milliseconds: disabled ? 1 : 1300);
late final Duration pageTransition = Duration(milliseconds: disabled ? 1 : 200);
}
@immutable

View File

@ -53,7 +53,7 @@ class _FullscreenUrlImgViewerState extends State<FullscreenUrlImgViewer> {
void _animateToPage(int page) {
if (page >= 0 || page < widget.urls.length) {
_controller.animateToPage(page, duration: 300.ms, curve: Curves.easeOut);
_controller.animateToPage(page, duration: $styles.times.fast, curve: Curves.easeOut);
}
}

View File

@ -60,7 +60,7 @@ class _IntroScreenState extends State<IntroScreen> {
final int current = _pageController.page!.round();
if (_isOnLastPage && dir > 0) return;
if (_isOnFirstPage && dir < 0) return;
_pageController.animateToPage(current + dir, duration: 250.ms, curve: Curves.easeIn);
_pageController.animateToPage(current + dir, duration: $styles.times.fast, curve: Curves.easeIn);
}
@override

View File

@ -25,7 +25,7 @@ class _ScrollingViewportController extends ChangeNotifier {
final data = wondersLogic.getData(w);
final pos = calculateScrollPosFromYear(data.startYr);
scroller.jumpTo(pos - 200);
scroller.animateTo(pos, duration: 1.35.seconds, curve: Curves.easeOutCubic);
scroller.animateTo(pos, duration: $styles.times.extraSlow, curve: Curves.easeOutCubic);
scroller.addListener(_updateCurrentYear);
}
});