|
|
|
|
|
|
} |
|
|
|
|
|
|
|
class HeroUtils { |
|
|
|
/*public static Rect _globalBoundingBoxFor(BuildContext context) { |
|
|
|
RenderBox box = (RenderBox) context.findRenderObject(); |
|
|
|
D.assert(box != null && box.hasSize); |
|
|
|
return MatrixUtils.transformRect( box.getTransformTo(null), Offset.zero & box.size); |
|
|
|
}*/ |
|
|
|
public static Rect _boundingBoxFor(BuildContext context, BuildContext ancestorContext = null) { |
|
|
|
RenderBox box = context.findRenderObject() as RenderBox; |
|
|
|
D.assert(box != null && box.hasSize); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public readonly object tag; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public readonly HeroFlightShuttleBuilder flightShuttleBuilder; |
|
|
|
public readonly HeroPlaceholderBuilder placeholderBuilder; |
|
|
|
|
|
|
|
|
|
|
BuildContext context, |
|
|
|
bool isUserGestureTransition, |
|
|
|
NavigatorState navigator) { |
|
|
|
|
|
|
|
|
|
|
|
Dictionary<object, _HeroState> result = new Dictionary<object, _HeroState> { }; |
|
|
|
|
|
|
|
void inviteHero(StatefulElement hero, object tag) { |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
class _HeroState : State<Hero> { |
|
|
|
|
|
|
|
GlobalKey _key = GlobalKey.key(); |
|
|
|
Size _placeholderSize; |
|
|
|
bool _shouldIncludeChild = true; |
|
|
|
|
|
|
_HeroState toHero = null, |
|
|
|
CreateRectTween createRectTween = null, |
|
|
|
HeroFlightShuttleBuilder shuttleBuilder = null, |
|
|
|
bool isUserGestureTransition = false, |
|
|
|
bool isDiverted = false |
|
|
|
bool? isUserGestureTransition = null, |
|
|
|
bool? isDiverted = null |
|
|
|
) { |
|
|
|
D.assert(fromHero.widget.tag.Equals(toHero.widget.tag)); |
|
|
|
this.type = type; |
|
|
|
|
|
|
this.toHero = toHero; |
|
|
|
this.createRectTween = createRectTween; |
|
|
|
this.shuttleBuilder = shuttleBuilder; |
|
|
|
this.isUserGestureTransition = isUserGestureTransition; |
|
|
|
this.isDiverted = isDiverted; |
|
|
|
this.isUserGestureTransition = isUserGestureTransition ?? false; |
|
|
|
this.isDiverted = isDiverted ?? false; |
|
|
|
} |
|
|
|
|
|
|
|
public readonly HeroFlightDirection type; |
|
|
|
|
|
|
get { |
|
|
|
return new CurvedAnimation( |
|
|
|
parent: (type == HeroFlightDirection.push) ? toRoute.animation : fromRoute.animation, |
|
|
|
curve: Curves.fastOutSlowIn |
|
|
|
, reverseCurve: isDiverted ? null : Curves.fastOutSlowIn.flipped |
|
|
|
curve: Curves.fastOutSlowIn, |
|
|
|
reverseCurve: isDiverted ? null : Curves.fastOutSlowIn.flipped |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
public void _handleAnimationUpdate(AnimationStatus status) { |
|
|
|
if (status == AnimationStatus.completed || status == AnimationStatus.dismissed) { |
|
|
|
_proxyAnimation.parent = null; |
|
|
|
|
|
|
|
D.assert(overlayEntry != null); |
|
|
|
overlayEntry.remove(); |
|
|
|
overlayEntry = null; |
|
|
|
|
|
|
HeroFlightDirection type = initialManifest.type; |
|
|
|
switch (type) { |
|
|
|
case HeroFlightDirection.pop: |
|
|
|
return initial.value == 1.0f && initialManifest.isUserGestureTransition |
|
|
|
return initial.value == 1.0f && |
|
|
|
initialManifest.isUserGestureTransition |
|
|
|
? initial.status == AnimationStatus.completed |
|
|
|
: initial.status == AnimationStatus.reverse; |
|
|
|
case HeroFlightDirection.push: |
|
|
|
|
|
|
RouteSettings from = manifest.fromRoute.settings; |
|
|
|
RouteSettings to = manifest.toRoute.settings; |
|
|
|
object tag = manifest.tag; |
|
|
|
return $"HeroFlight(for: {tag}, from: {from}, to: {to} ${_proxyAnimation.parent})"; |
|
|
|
return $"HeroFlight(for: {tag}, from: {from}, to: {to} {_proxyAnimation.parent})"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
if (toHeroes.ContainsKey(tag)) { |
|
|
|
HeroFlightShuttleBuilder fromShuttleBuilder = fromHeroes[tag].widget.flightShuttleBuilder; |
|
|
|
HeroFlightShuttleBuilder toShuttleBuilder = toHeroes[tag].widget.flightShuttleBuilder; |
|
|
|
//bool isDiverted = _flights[tag] != null;
|
|
|
|
bool isDiverted = _flights.ContainsKey(tag); |
|
|
|
_HeroFlightManifest manifest = new _HeroFlightManifest( |
|
|
|
type: flightType, |
|
|
|