mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-29 23:38:50 +02:00
fix(ui): honor disabled hero animations
This commit is contained in:
+10
-8
@@ -192,16 +192,18 @@ class SpotiFLACApp extends ConsumerWidget {
|
||||
// dialogs stay centered on large/foldable devices.
|
||||
builder: (context, child) {
|
||||
final mediaQuery = MediaQuery.of(context);
|
||||
final appContent = _OrientationFade(
|
||||
child: child ?? const SizedBox.shrink(),
|
||||
);
|
||||
return MediaQuery(
|
||||
data: mediaQuery.copyWith(displayFeatures: const []),
|
||||
// Global Hero kill switch: heroes below a disabled HeroMode
|
||||
// never register, so no flights run on any navigator.
|
||||
child: HeroMode(
|
||||
enabled: heroAnimationsEnabled,
|
||||
child: _OrientationFade(
|
||||
child: child ?? const SizedBox.shrink(),
|
||||
),
|
||||
),
|
||||
// HeroMode only affects heroes below a *route* subtree. At this
|
||||
// level it sits above the router's Navigator, so the controller
|
||||
// never encounters it while collecting heroes. Removing the
|
||||
// inherited controller disables flights on the root Navigator.
|
||||
child: heroAnimationsEnabled
|
||||
? appContent
|
||||
: HeroControllerScope.none(child: appContent),
|
||||
);
|
||||
},
|
||||
routerConfig: router,
|
||||
|
||||
@@ -506,6 +506,9 @@ class _MainShellState extends ConsumerState<MainShell>
|
||||
final showStore = ref.watch(
|
||||
settingsProvider.select((s) => s.showExtensionStore),
|
||||
);
|
||||
final heroAnimationsEnabled = ref.watch(
|
||||
settingsProvider.select((s) => s.heroAnimationsEnabled),
|
||||
);
|
||||
ShellNavigationService.syncState(
|
||||
currentTabIndex: _currentIndex,
|
||||
showRepoTab: showStore,
|
||||
@@ -519,12 +522,14 @@ class _MainShellState extends ConsumerState<MainShell>
|
||||
key: const ValueKey('tab-home'),
|
||||
navigatorKey: _homeTabNavigatorKey,
|
||||
observers: [_homePreviewStopObserver],
|
||||
heroAnimationsEnabled: heroAnimationsEnabled,
|
||||
child: const HomeTab(),
|
||||
),
|
||||
_TabNavigator(
|
||||
key: const ValueKey('tab-library'),
|
||||
navigatorKey: _libraryTabNavigatorKey,
|
||||
observers: [_libraryPreviewStopObserver],
|
||||
heroAnimationsEnabled: heroAnimationsEnabled,
|
||||
child: _LibraryTabRoot(parentPageController: _pageController),
|
||||
),
|
||||
if (showStore)
|
||||
@@ -532,6 +537,7 @@ class _MainShellState extends ConsumerState<MainShell>
|
||||
key: const ValueKey('tab-repo'),
|
||||
navigatorKey: _repoTabNavigatorKey,
|
||||
observers: [_repoPreviewStopObserver],
|
||||
heroAnimationsEnabled: heroAnimationsEnabled,
|
||||
child: const RepoTab(),
|
||||
),
|
||||
const SettingsTab(),
|
||||
@@ -750,12 +756,14 @@ class _TabNavigator extends StatefulWidget {
|
||||
final GlobalKey<NavigatorState> navigatorKey;
|
||||
final Widget child;
|
||||
final List<NavigatorObserver> observers;
|
||||
final bool heroAnimationsEnabled;
|
||||
|
||||
const _TabNavigator({
|
||||
super.key,
|
||||
required this.navigatorKey,
|
||||
required this.child,
|
||||
this.observers = const [],
|
||||
required this.heroAnimationsEnabled,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -778,7 +786,10 @@ class _TabNavigatorState extends State<_TabNavigator> {
|
||||
Widget build(BuildContext context) {
|
||||
return Navigator(
|
||||
key: widget.navigatorKey,
|
||||
observers: [_heroController, ...widget.observers],
|
||||
observers: [
|
||||
if (widget.heroAnimationsEnabled) _heroController,
|
||||
...widget.observers,
|
||||
],
|
||||
onGenerateInitialRoutes: (_, _) => [
|
||||
MaterialPageRoute<void>(builder: (_) => widget.child),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user