fix(mobile): Fixes hero animation on main timeline (#1924)

* fixed hero animation for local assets

* fixes backwards hero animation out of gallery image
This commit is contained in:
martyfuhry
2023-03-03 17:49:40 -05:00
committed by GitHub
parent a5f49b065c
commit dac4020f27
3 changed files with 51 additions and 7 deletions

View File

@@ -67,6 +67,31 @@ class ThumbnailImage extends HookConsumerWidget {
HapticFeedback.heavyImpact();
},
child: Hero(
createRectTween: (begin, end) {
double? top;
// Uses the [BoxFit.contain] algorithm
if (asset.width != null && asset.height != null) {
final assetAR = asset.width! / asset.height!;
final w = MediaQuery.of(context).size.width;
final deviceAR = MediaQuery.of(context).size.aspectRatio;
if (deviceAR < assetAR) {
top = asset.height! * w / asset.width!;
} else {
top = 0;
}
// get the height offset
}
return MaterialRectCenterArcTween(
begin: Rect.fromLTRB(
0,
top ?? 0.0,
MediaQuery.of(context).size.width,
MediaQuery.of(context).size.height,
),
end: end,
);
},
tag: asset.id,
child: Stack(
children: [