fix: no hero animation after tab change (#20285)

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong 2025-07-26 19:29:26 +05:30 committed by GitHub
parent d0576697c3
commit e85655d34c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 6 deletions

View file

@ -34,11 +34,13 @@ import 'package:platform/platform.dart';
class AssetViewerPage extends StatelessWidget {
final int initialIndex;
final TimelineService timelineService;
final int? heroOffset;
const AssetViewerPage({
super.key,
required this.initialIndex,
required this.timelineService,
this.heroOffset,
});
@override
@ -47,7 +49,7 @@ class AssetViewerPage extends StatelessWidget {
// since the Timeline and AssetViewer are on different routes / Widget subtrees.
return ProviderScope(
overrides: [timelineServiceProvider.overrideWithValue(timelineService)],
child: AssetViewer(initialIndex: initialIndex),
child: AssetViewer(initialIndex: initialIndex, heroOffset: heroOffset),
);
}
}
@ -55,11 +57,13 @@ class AssetViewerPage extends StatelessWidget {
class AssetViewer extends ConsumerStatefulWidget {
final int initialIndex;
final Platform? platform;
final int? heroOffset;
const AssetViewer({
super.key,
required this.initialIndex,
this.platform,
this.heroOffset,
});
@override
@ -108,7 +112,7 @@ class _AssetViewerState extends ConsumerState<AssetViewer> {
_onAssetChanged(widget.initialIndex);
});
reloadSubscription = EventStream.shared.listen(_onEvent);
heroOffset = TabsRouterScope.of(context)?.controller.activeIndex ?? 0;
heroOffset = widget.heroOffset ?? TabsRouterScope.of(context)?.controller.activeIndex ?? 0;
}
@override