void _startHeroTransition( PageRoute from, PageRoute to, Animation <float> animation, HeroFlightDirection flightType, bool isUserGestureTransition ) { if (this.navigator == null || from.subtreeContext == null || to.subtreeContext == null) { to.offstage = false; // in case we set this in _maybeStartHeroTransition return; } Rect navigatorRect = HeroUtils._globalBoundingBoxFor(this.navigator.context); Dictionary <object, _HeroState> fromHeroes = Hero._allHeroesFor(from.subtreeContext, isUserGestureTransition, this.navigator); Dictionary <object, _HeroState> toHeroes = Hero._allHeroesFor(to.subtreeContext, isUserGestureTransition, this.navigator); to.offstage = false; foreach (object tag in fromHeroes.Keys) { if (toHeroes.ContainsKey(tag)) { HeroFlightShuttleBuilder fromShuttleBuilder = fromHeroes[tag].widget.flightShuttleBuilder; HeroFlightShuttleBuilder toShuttleBuilder = toHeroes[tag].widget.flightShuttleBuilder; _HeroFlightManifest manifest = new _HeroFlightManifest( type: flightType, overlay: this.navigator.overlay, navigatorRect: navigatorRect, fromRoute: from, toRoute: to, fromHero: fromHeroes[tag], toHero: toHeroes[tag], createRectTween: this.createRectTween, shuttleBuilder: toShuttleBuilder ?? fromShuttleBuilder ?? _defaultHeroFlightShuttleBuilder, isUserGestureTransition: isUserGestureTransition ); if (this._flights.TryGetValue(tag, out var result)) { result.divert(manifest); } else { this._flights[tag] = new _HeroFlight(this._handleFlightEnded); this._flights[tag].start(manifest); } } else if (this._flights.TryGetValue(tag, out var result)) { result.abort(); } } }
public _HeroFlightManifest( HeroFlightDirection type, OverlayState overlay, Rect navigatorRect, PageRoute fromRoute, PageRoute toRoute, _HeroState fromHero, _HeroState toHero, CreateRectTween createRectTween, HeroFlightShuttleBuilder shuttleBuilder, bool isUserGestureTransition ) { D.assert(fromHero.widget.tag == toHero.widget.tag); this.type = type; this.overlay = overlay; this.navigatorRect = navigatorRect; this.fromRoute = fromRoute; this.toRoute = toRoute; this.fromHero = fromHero; this.toHero = toHero; this.createRectTween = createRectTween; this.shuttleBuilder = shuttleBuilder; this.isUserGestureTransition = isUserGestureTransition; }
public _HeroFlightManifest( HeroFlightDirection type = default, OverlayState overlay = null, Rect navigatorRect = null, PageRoute fromRoute = null, PageRoute toRoute = null, _HeroState fromHero = null, _HeroState toHero = null, CreateRectTween createRectTween = null, HeroFlightShuttleBuilder shuttleBuilder = null, bool?isUserGestureTransition = null, bool?isDiverted = null ) { D.assert(fromHero.widget.tag.Equals(toHero.widget.tag)); this.type = type; this.overlay = overlay; this.navigatorRect = navigatorRect; this.fromRoute = fromRoute; this.toRoute = toRoute; this.fromHero = fromHero; this.toHero = toHero; this.createRectTween = createRectTween; this.shuttleBuilder = shuttleBuilder; this.isUserGestureTransition = isUserGestureTransition ?? false; this.isDiverted = isDiverted ?? false; }
void _maybeStartHeroTransition( Route fromRoute, Route toRoute, HeroFlightDirection flightType, bool isUserGestureTransition ) { if (toRoute != fromRoute && toRoute is PageRoute && fromRoute is PageRoute) { PageRoute from = (PageRoute)fromRoute; PageRoute to = (PageRoute)toRoute; Animation <float> animation = (flightType == HeroFlightDirection.push) ? to.animation : from.animation; switch (flightType) { case HeroFlightDirection.pop: if (animation.value == 0.0f) { return; } break; case HeroFlightDirection.push: if (animation.value == 1.0f) { return; } break; } if (isUserGestureTransition && flightType == HeroFlightDirection.pop && to.maintainState) { this._startHeroTransition(from, to, animation, flightType, isUserGestureTransition); } else { to.offstage = to.animation.value == 0.0f; WidgetsBinding.instance.addPostFrameCallback((TimeSpan value) => { this._startHeroTransition(from, to, animation, flightType, isUserGestureTransition); }); } } }
public void start(_HeroFlightManifest initialManifest) { D.assert(!_aborted); D.assert(() => { Animation <float> initial = initialManifest.animation; D.assert(initial != null); HeroFlightDirection type = initialManifest.type; switch (type) { case HeroFlightDirection.pop: return(initial.value == 1.0f && initialManifest.isUserGestureTransition ? initial.status == AnimationStatus.completed : initial.status == AnimationStatus.reverse); case HeroFlightDirection.push: return(initial.value == 0.0f && initial.status == AnimationStatus.forward); } throw new Exception("Unknown type: " + type); }); manifest = initialManifest; if (manifest.type == HeroFlightDirection.pop) { _proxyAnimation.parent = new ReverseAnimation(manifest.animation); } else { _proxyAnimation.parent = manifest.animation; } manifest.fromHero.startFlight(shouldIncludedChildInPlaceholder: manifest.type == HeroFlightDirection.push); manifest.toHero.startFlight(); heroRectTween = _doCreateRectTween( HeroUtils._boundingBoxFor(manifest.fromHero.context, manifest.fromRoute.subtreeContext), HeroUtils._boundingBoxFor(manifest.toHero.context, manifest.toRoute.subtreeContext) ); overlayEntry = new OverlayEntry(builder: _buildOverlay); manifest.overlay.insert(overlayEntry); }
public void start(_HeroFlightManifest initialManifest) { D.assert(!this._aborted); D.assert(() => { Animation <float> initial = initialManifest.animation; D.assert(initial != null); HeroFlightDirection type = initialManifest.type; switch (type) { case HeroFlightDirection.pop: return(initial.value == 1.0f && initialManifest.isUserGestureTransition ? initial.status == AnimationStatus.completed : initial.status == AnimationStatus.reverse); case HeroFlightDirection.push: return(initial.value == 0.0f && initial.status == AnimationStatus.forward); } throw new Exception("Unknown type: " + type); }); this.manifest = initialManifest; if (this.manifest.type == HeroFlightDirection.pop) { this._proxyAnimation.parent = new ReverseAnimation(this.manifest.animation); } else { this._proxyAnimation.parent = this.manifest.animation; } this.manifest.fromHero.startFlight(); this.manifest.toHero.startFlight(); this.heroRectTween = this._doCreateRectTween( HeroUtils._globalBoundingBoxFor(this.manifest.fromHero.context), HeroUtils._globalBoundingBoxFor(this.manifest.toHero.context) ); this.overlayEntry = new OverlayEntry(builder: this._buildOverlay); this.manifest.overlay.insert(this.overlayEntry); }