|
|
|
|
|
|
D.assert(context != null); |
|
|
|
D.assert(navigator != null); |
|
|
|
Dictionary<object, _HeroState> result = new Dictionary<object, _HeroState> { }; |
|
|
|
|
|
|
|
/*void addHero(StatefulElement hero, object tag) { |
|
|
|
D.assert(() => { |
|
|
|
if (result.ContainsKey(tag)) { |
|
|
|
throw new UIWidgetsError( |
|
|
|
"There are multiple heroes that share the same tag within a subtree.\n" + |
|
|
|
"Within each subtree for which heroes are to be animated (typically a PageRoute subtree), " + |
|
|
|
"each Hero must have a unique non-null tag.\n" + |
|
|
|
$"In this case, multiple heroes had the following tag: {tag}\n" + |
|
|
|
"Here is the subtree for one of the offending heroes:\n" + |
|
|
|
$"{hero.toStringDeep(prefixLineOne: "# ")}" |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
}); |
|
|
|
_HeroState heroState = (_HeroState) hero.state; |
|
|
|
result[tag] = heroState; |
|
|
|
}*/ |
|
|
|
|
|
|
|
void inviteHero(StatefulElement hero, object tag) { |
|
|
|
D.assert(()=> { |
|
|
|
if (result.ContainsKey(tag)) { |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void visitor(Element element) { |
|
|
|
/*if (element.widget is Hero) { |
|
|
|
StatefulElement hero = (StatefulElement) element; |
|
|
|
Hero heroWidget = (Hero) element.widget; |
|
|
|
if (!isUserGestureTransition || heroWidget.transitionOnUserGestures) { |
|
|
|
object tag = heroWidget.tag; |
|
|
|
D.assert(tag != null); |
|
|
|
if (Navigator.of(hero) == navigator) { |
|
|
|
addHero(hero, tag); |
|
|
|
} |
|
|
|
else { |
|
|
|
ModalRoute heroRoute = ModalRoute.of(hero); |
|
|
|
if (heroRoute != null && heroRoute is PageRoute && heroRoute.isCurrent) { |
|
|
|
addHero(hero, tag); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}*/ |
|
|
|
Widget widget = element.widget; |
|
|
|
if (widget is Hero) { |
|
|
|
StatefulElement hero = element as StatefulElement; |
|
|
|
|
|
|
GlobalKey _key = GlobalKey.key(); |
|
|
|
Size _placeholderSize; |
|
|
|
bool _shouldIncludeChild = true; |
|
|
|
//public void startFlight() {
|
|
|
|
|
|
|
|
public void startFlight( bool shouldIncludedChildInPlaceholder = false ) { |
|
|
|
_shouldIncludeChild = shouldIncludedChildInPlaceholder; |
|
|
|
D.assert(mounted); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//public void endFlight() {
|
|
|
|
|
|
|
|
public void ensurePlaceholderIsHidden() { |
|
|
|
if (mounted) { |
|
|
|
setState(() => { _placeholderSize = null; }); |
|
|
|
|
|
|
} |
|
|
|
public override Widget build(BuildContext context) { |
|
|
|
D.assert( |
|
|
|
//context.ancestorWidgetOfExactType(typeof(Hero)) == null,
|
|
|
|
//if (_placeholderSize != null) {
|
|
|
|
// if (widget.placeholderBuilder == null) {
|
|
|
|
|
|
|
|
bool showPlaceholder = _placeholderSize != null; |
|
|
|
|
|
|
|
if (showPlaceholder && widget.placeholderBuilder != null) { |
|
|
|
|
|
|
width: _placeholderSize.width, |
|
|
|
height: _placeholderSize.height |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
return new SizedBox( |
|
|
|
width: _placeholderSize?.width, |
|
|
|
height: _placeholderSize?.height, |
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
/*else { |
|
|
|
return widget.placeholderBuilder(context, widget.child); |
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
/*return new KeyedSubtree( |
|
|
|
key: _key, |
|
|
|
child: widget.child |
|
|
|
);*/ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
this.createRectTween = createRectTween; |
|
|
|
this.shuttleBuilder = shuttleBuilder; |
|
|
|
this.isUserGestureTransition = isUserGestureTransition; |
|
|
|
this.isDiverted = isDiverted; |
|
|
|
} |
|
|
|
|
|
|
|
public readonly HeroFlightDirection type; |
|
|
|
|
|
|
animation: _proxyAnimation, |
|
|
|
child: shuttle, |
|
|
|
builder: (BuildContext _, Widget child) => { |
|
|
|
//RenderBox toHeroBox = (RenderBox) manifest.toHero.context?.findRenderObject();
|
|
|
|
RenderBox toHeroBox = manifest.toHero.context?.findRenderObject() as RenderBox; |
|
|
|
if (_aborted || toHeroBox == null || !toHeroBox.attached) { |
|
|
|
if (_heroOpacity.isCompleted) { |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else if (toHeroBox.hasSize) { |
|
|
|
//RenderBox finalRouteBox = (RenderBox) manifest.toRoute.subtreeContext?.findRenderObject();
|
|
|
|
RenderBox finalRouteBox = manifest.toRoute.subtreeContext?.findRenderObject() as RenderBox; |
|
|
|
Offset toHeroOrigin = toHeroBox.localToGlobal(Offset.zero, ancestor: finalRouteBox); |
|
|
|
if (toHeroOrigin != heroRectTween.end.topLeft) { |
|
|
|
|
|
|
overlayEntry = null; |
|
|
|
manifest.fromHero.endFlight(keepPlaceholder: status == AnimationStatus.completed); |
|
|
|
manifest.toHero.endFlight(keepPlaceholder: status == AnimationStatus.dismissed); |
|
|
|
|
|
|
|
//manifest.fromHero.endFlight();
|
|
|
|
//manifest.toHero.endFlight();
|
|
|
|
onFlightEnded(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
_proxyAnimation.parent = manifest.animation; |
|
|
|
} |
|
|
|
manifest.fromHero.startFlight(shouldIncludedChildInPlaceholder: manifest.type == HeroFlightDirection.push); |
|
|
|
//manifest.fromHero.startFlight();
|
|
|
|
|
|
|
|
|
|
|
|
//HeroUtils._globalBoundingBoxFor(manifest.fromHero.context),
|
|
|
|
//HeroUtils._globalBoundingBoxFor(manifest.toHero.context)
|
|
|
|
HeroUtils._boundingBoxFor(manifest.fromHero.context, manifest.fromRoute.subtreeContext), |
|
|
|
HeroUtils._boundingBoxFor(manifest.toHero.context, manifest.toRoute.subtreeContext) |
|
|
|
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
if (manifest.fromHero != newManifest.toHero) { |
|
|
|
//manifest.fromHero.endFlight();
|
|
|
|
//heroRectTween = _doCreateRectTween(heroRectTween.end, HeroUtils._globalBoundingBoxFor(newManifest.toHero.context));
|
|
|
|
heroRectTween = _doCreateRectTween( |
|
|
|
heroRectTween.end, |
|
|
|
HeroUtils._boundingBoxFor(newManifest.toHero.context, newManifest.toRoute.subtreeContext) |
|
|
|
|
|
|
else { |
|
|
|
D.assert(manifest.fromHero != newManifest.fromHero); |
|
|
|
D.assert(manifest.toHero != newManifest.toHero); |
|
|
|
|
|
|
|
//heroRectTween = _doCreateRectTween(heroRectTween.evaluate(_proxyAnimation), HeroUtils._globalBoundingBoxFor(newManifest.toHero.context));
|
|
|
|
|
|
|
|
heroRectTween = _doCreateRectTween( |
|
|
|
heroRectTween.evaluate(_proxyAnimation), |
|
|
|
HeroUtils._boundingBoxFor(newManifest.toHero.context, newManifest.toRoute.subtreeContext) |
|
|
|
|
|
|
|
|
|
|
// Let the heroes in each of the routes rebuild with their placeholders.
|
|
|
|
newManifest.fromHero.startFlight(shouldIncludedChildInPlaceholder: newManifest.type == HeroFlightDirection.push); |
|
|
|
|
|
|
|
|
|
|
|
//manifest.fromHero.endFlight();
|
|
|
|
//manifest.toHero.endFlight();
|
|
|
|
|
|
|
|
//newManifest.fromHero.startFlight();
|
|
|
|
newManifest.toHero.startFlight(); |
|
|
|
|
|
|
|
overlayEntry.markNeedsBuild(); |
|
|
|