浏览代码

fix old version

overlay.cs routes.cs navigator.cs pages.cs  heroes.cs
/siyaoH-1.17-PlatformMessage
Shiyun Wen 4 年前
当前提交
560258df
共有 6 个文件被更改,包括 296 次插入430 次删除
  1. 32
      com.unity.uiwidgets/Runtime/widgets/heroes.cs
  2. 230
      com.unity.uiwidgets/Runtime/widgets/navigator.cs
  3. 247
      com.unity.uiwidgets/Runtime/widgets/overlay.cs
  4. 36
      com.unity.uiwidgets/Runtime/widgets/pages.cs
  5. 4
      com.unity.uiwidgets/Runtime/widgets/route_notification_messages.cs
  6. 177
      com.unity.uiwidgets/Runtime/widgets/routes.cs

32
com.unity.uiwidgets/Runtime/widgets/heroes.cs


public readonly HeroFlightShuttleBuilder flightShuttleBuilder;
public readonly HeroPlaceholderBuilder placeholderBuilder;
//public readonly TransitionBuilder placeholderBuilder;
internal static Dictionary<object, _HeroState>
_allHeroesFor(BuildContext context, bool isUserGestureTransition, NavigatorState navigator) {
internal static Dictionary<object, _HeroState> _allHeroesFor(
BuildContext context,
bool isUserGestureTransition,
NavigatorState navigator) {
D.assert(context != null);
D.assert(navigator != null);
Dictionary<object, _HeroState> result = new Dictionary<object, _HeroState> { };

if (!isUserGestureTransition || heroWidget.transitionOnUserGestures) {
result[tag] = heroState;
} else {
// If transition is not allowed, we need to make sure hero is not hidden.
// A hero can be hidden previously due to hero transition.
heroState.ensurePlaceholderIsHidden();
}
}

}
public override string ToString() {
return $"_HeroFlightManifest($type tag: $tag from route: {fromRoute.settings} " +
return $"_HeroFlightManifest({type} tag: {tag} from route: {fromRoute.settings} " +
public _HeroFlight(_OnFlightEnded onFlightEnded) {
public _HeroFlight(_OnFlightEnded onFlightEnded ) {
this.onFlightEnded = onFlightEnded;
_proxyAnimation = new ProxyAnimation();
_proxyAnimation.addStatusListener(_handleAnimationUpdate);

Widget _buildOverlay(BuildContext context) {
D.assert(manifest != null);
shuttle = shuttle ?? manifest.shuttleBuilder(
context, manifest.animation, manifest.type, manifest.fromHero.context,
manifest.toHero.context
);
context,
manifest.animation,
manifest.type,
manifest.fromHero.context,
manifest.toHero.context);
D.assert(shuttle != null);
return new AnimatedBuilder(

public void divert(_HeroFlightManifest newManifest) {
D.assert(manifest.tag == newManifest.tag);
if (manifest.type == HeroFlightDirection.push && newManifest.type == HeroFlightDirection.pop) {
D.assert(newManifest.animation.status == AnimationStatus.reverse);
D.assert(manifest.fromHero == newManifest.toHero);

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})";
}
}

D.assert(route != null);
_maybeStartHeroTransition(route, previousRoute, HeroFlightDirection.pop, true);
}
void didStopUserGesture() {
public override void didStopUserGesture() {
if (navigator.userGestureInProgress)
return;

List<_HeroFlight> invalidFlights = _flights.Values
.Where(isInvalidFlight)
.ToList();
// Treat these invalidated flights as dismissed. Calling _handleAnimationUpdate
// will also remove the flight from _flights.
foreach ( _HeroFlight flight in invalidFlights) {
foreach ( _HeroFlight flight in invalidFlights) {
flight._handleAnimationUpdate(AnimationStatus.dismissed);
}
}

230
com.unity.uiwidgets/Runtime/widgets/navigator.cs


using System;
using System.Collections;
using Unity.UIWidgets.external.simplejson;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.rendering;

routeEntry = historyEntry;
break;
}
}
return routeEntry?.isPresent == true;
}
return routeEntry?.isPresent == true;
}
}
}

}
public class RouteSettings {
public RouteSettings(string name = null, bool isInitialRoute = false, object arguments = null) {
public RouteSettings(
string name = null,
object arguments = null) {
this.isInitialRoute = isInitialRoute;
RouteSettings copyWith(string name = null, bool? isInitialRoute = null, object arguments = null) {
RouteSettings copyWith(
string name = null,
object arguments = null) {
isInitialRoute ?? this.isInitialRoute,
public readonly bool isInitialRoute;
public readonly string name;

}
}
public abstract class Page<T> : RouteSettings {
public abstract class Page : RouteSettings {
public Page(
Key key = null,
string name = null,

public LocalKey key;
public bool canUpdate(Page<object> other) {
public bool canUpdate(Page other) {
public abstract Route<T> createRoute(BuildContext context);
//public abstract Route createRoute(BuildContext context);
public override string ToString() {
return $"{GetType()}(\"{name}\",{key},{arguments})";

/*public class Page<T> : Page {
readonly Page _page;
public abstract class Page<T> : Page {
public Page(
Key key = null,
string name = null,

}
public bool canUpdate(Page<object> other) {
return other.GetType() == GetType() &&
other.key == key;
}
public Route<T> createRoute(BuildContext context) {
//return new Route<T>(context);
}
}*/
public abstract Route<T> createRoute(BuildContext context);
}
public class CustomBuilderPage<T> : Page<T> {
public CustomBuilderPage(

object arguments = null
) : base(key: key, name: name, arguments: arguments) {
D.assert(key != null);
D.assert(routeBuilder != null);
this.routeBuilder = routeBuilder;
}

}
public IEnumerable<RouteTransitionRecord> _transition(
List<RouteTransitionRecord> newPageRouteHistory,
Dictionary<RouteTransitionRecord, RouteTransitionRecord> locationToExitingPageRoute,
Dictionary<RouteTransitionRecord, List<RouteTransitionRecord>> pageRouteToPagelessRoutes
List<RouteTransitionRecord> newPageRouteHistory = null,
Dictionary<RouteTransitionRecord, RouteTransitionRecord> locationToExitingPageRoute = null,
Dictionary<RouteTransitionRecord, List<RouteTransitionRecord>> pageRouteToPagelessRoutes = null
) {
IEnumerable<RouteTransitionRecord> results = resolve(
newPageRouteHistory: newPageRouteHistory,

foreach(RouteTransitionRecord item in locationToExitingPageRoute.Values) {
exitingPageRoutes.Add(item);
}
// Firstly, verifies all exiting routes have been marked.
foreach (RouteTransitionRecord exitingPageRoute in exitingPageRoutes) {
D.assert(!exitingPageRoute._debugWaitingForExitDecision);
if (pageRouteToPagelessRoutes.ContainsKey(exitingPageRoute)) {

List<RouteTransitionRecord> newPageRouteHistory = null,
Dictionary<RouteTransitionRecord, RouteTransitionRecord> locationToExitingPageRoute = null,
Dictionary<RouteTransitionRecord, List<RouteTransitionRecord>> pageRouteToPagelessRoutes = null) {
void handleExitingRoute(RouteTransitionRecord location, bool isLast) {
RouteTransitionRecord exitingPageRoute = locationToExitingPageRoute[location];
if (exitingPageRoute == null)

public static readonly string defaultRouteName = "/";
/// <summary>
/// Future<T> pushNamed<T extends object>(
public static Future<T> pushNamed<T>(BuildContext context, string routeName, object arguments = null) {
return of(context).pushNamed<T>(routeName, arguments: arguments);

TO result , object arguments = null) {
TO result = default , object arguments = null) {
TO result ,
TO result = default,
object arguments = null) {
return of(context).popAndPushNamed<T,TO>(routeName, result: result, arguments: arguments);
}

return of(context).push<T>(route);
}
public static Future<T> pushReplacement<T,TO>(BuildContext context, Route<T> newRoute, TO result ) {
public static Future<T> pushReplacement<T,TO>(BuildContext context, Route<T> newRoute, TO result = default ) {
return of(context).pushReplacement<T,TO>(newRoute, result);
}

}
public static void replace<T>(BuildContext context, Route oldRoute, Route<T> newRoute ) {
public static void replace<T>(BuildContext context, Route oldRoute = null, Route<T> newRoute = null) {
public static void replaceRouteBelow<T>(BuildContext context, Route anchorRoute, Route<T> newRoute ) {
public static void replaceRouteBelow<T>(BuildContext context, Route anchorRoute = null, Route<T> newRoute = null ) {
of(context).replaceRouteBelow<T>(anchorRoute: anchorRoute, newRoute: newRoute);
}

public static void removeRouteBelow(BuildContext context, Route anchorRoute) {
of(context).removeRouteBelow(anchorRoute);
}
/*public static void replace(BuildContext context, Route oldRoute = null, Route newRoute = null) {
D.assert(oldRoute != null);
D.assert(newRoute != null);
of(context).replace(oldRoute: oldRoute, newRoute: newRoute);
}
public static void replaceRouteBelow(BuildContext context, Route anchorRoute = null, Route newRoute = null) {
D.assert(anchorRoute != null);
D.assert(newRoute != null);
of(context).replaceRouteBelow(anchorRoute: anchorRoute, newRoute: newRoute);
}
public static bool canPop(BuildContext context) {
NavigatorState navigator = of(context, nullOk: true);
return navigator != null && navigator.canPop();
}
public static Future<bool> maybePop(BuildContext context, object result = null) {
return of(context).maybePop(result);
}
public static bool pop(BuildContext context, object result = null) {
return of(context).pop(result);
}
public static void popUntil(BuildContext context, RoutePredicate predicate) {
of(context).popUntil(predicate);
}
public static void removeRoute(BuildContext context, Route route) {
of(context).removeRoute(route);
}
static void removeRouteBelow(BuildContext context, Route anchorRoute) {
of(context).removeRouteBelow(anchorRoute);
}*/
public static NavigatorState of(
BuildContext context,
bool rootNavigator = false,

_RouteLifecycle initialState
) {
D.assert(route != null);
D.assert(initialState != null);
D.assert(
initialState == _RouteLifecycle.staging ||
initialState == _RouteLifecycle.add ||

}
public Route route;
public _RouteLifecycle currentState;
public Route lastAnnouncedPreviousRoute; // last argument to Route.didChangePrevious
public Route lastAnnouncedPoppedNextRoute; // last argument to Route.didPopNext

get { return route.settings is Page<object>; }
get { return route.settings is Page; }
public bool canUpdateFrom(Page<object> page) {
public bool canUpdateFrom(Page page) {
Page<object> routePage = route.settings as Page<object>;
Page routePage = route.settings as Page;
return page.canUpdate(routePage);
}

lastAnnouncedPoppedNextRoute = poppedRoute;
}
public void handlePop(NavigatorState navigator, Route previousPresent) {
public void handlePop(NavigatorState navigator , Route previousPresent = null) {
D.assert(navigator != null);
D.assert(navigator._debugLocked);
D.assert(route._navigator == navigator);

}
public void handleRemoval(NavigatorState navigator, Route previousPresent) {
public void handleRemoval(NavigatorState navigator, Route previousPresent = null) {
D.assert(navigator != null);
D.assert(navigator._debugLocked);
D.assert(route._navigator == navigator);

public bool doingPop = false;
public void didAdd(NavigatorState navigator, bool isNewFirst, Route previous, Route previousPresent) {
public void didAdd(
NavigatorState navigator = null,
bool isNewFirst = false,
Route previous = null,
Route previousPresent = null) {
route.didAdd();
currentState = _RouteLifecycle.idle;
if (isNewFirst) {

bool _reportRemovalToObserver = true;
// Route is removed without being completed.
public void remove(bool isReplaced = false) {
D.assert(
!hasPage || _debugWaitingForExitDecision, () =>

currentState = _RouteLifecycle.remove;
}
// Route completes with `result` and is removed.
public void complete<T>(T result, bool isReplaced = false) {
D.assert(
!hasPage || _debugWaitingForExitDecision, () =>

public void dispose() {
D.assert(currentState.GetHashCode() < _RouteLifecycle.disposed.GetHashCode());
((Route)route).dispose();
//route._navigator = null;
currentState = _RouteLifecycle.disposed;
}

"This route cannot be marked for pop. Either a decision has already been " +
"made or it does not require an explicit decision on how to transition out."
);
pop<object>(result);
pop(result);
_debugWaitingForExitDecision = false;
}

"been made or it does not require an explicit decision on how to transition " +
"out."
);
complete<object>(result);
complete(result);
_debugWaitingForExitDecision = false;
}

string initialRoute = widget.initialRoute;
if (widget.pages.isNotEmpty()) {
foreach (Page<object> page in widget.pages) {
foreach (Page<object> page in widget.pages) {
_history.Add(
new _RouteEntry(
page.createRoute(context),

}
if (initialRoute != null) {
foreach (Route route in
(widget.onGenerateInitialRoutes(this, widget.initialRoute
?? Navigator.defaultRouteName))) {
_history.Add(
new _RouteEntry(
route,
initialState: _RouteLifecycle.add
)
);
}
_history.AddRange(
widget.onGenerateInitialRoutes(
this,
widget.initialRoute ?? Navigator.defaultRouteName
).Select((Route route) =>
new _RouteEntry(
route,
initialState: _RouteLifecycle.add
)
)
);
D.assert(!_debugLocked);
D.assert(() => {
_debugLocked = true;

}
public new void didUpdateWidget(Navigator oldWidget) {
// oldWidget = (Navigator) oldWidget;
public override void didUpdateWidget(StatefulWidget oldWidget) {
oldWidget = (Navigator) oldWidget;
base.didUpdateWidget(oldWidget);
D.assert(
widget.pages.isEmpty() || widget.onPopPage != null, () =>

void _debugCheckDuplicatedPageKeys() {
D.assert(() => {
List<Key> keyReservation = new List<Key>();
foreach (Page<object> page in widget.pages) {
foreach (Page page in widget.pages) {
if (page.key != null) {
D.assert(!keyReservation.Contains(page.key));
keyReservation.Add(page.key);

});
foreach (NavigatorObserver observer in widget.observers)
observer._navigator = null;
focusScopeNode.dispose();/// focus manager dispose
focusScopeNode.dispose();
// don"t unlock, so that the object becomes unusable
D.assert(_debugLocked);
}

if (newPagesBottom > newPagesTop)
break;
Page<object> newPage = widget.pages[newPagesBottom];
Page newPage = widget.pages[newPagesBottom];
if (!oldEntry.canUpdateFrom(newPage))
break;
previousOldPageRouteEntry = oldEntry;

continue;
}
Page<object> newPage = widget.pages[newPagesTop];
Page newPage = widget.pages[newPagesTop];
if (!oldEntry.canUpdateFrom(newPage))
break;
pagelessRoutesToSkip = 0;

continue;
D.assert(oldEntry.hasPage);
Page<object> page = oldEntry.route.settings as Page<object>;
Page page = oldEntry.route.settings as Page;
if (page.key == null)
continue;

continue;
}
Page<object> potentialPageToRemove = potentialEntryToRemove.route.settings as Page<object>;
Page potentialPageToRemove = potentialEntryToRemove.route.settings as Page;
if (
potentialPageToRemove.key == null ||

}
previousOldPageRouteEntry = oldEntry;
Page<object> newPage = widget.pages[newPagesBottom];
Page newPage = widget.pages[newPagesBottom];
D.assert(oldEntry.canUpdateFrom(newPage));
oldEntry.route._updateSettings(newPage);
newHistory.Add(oldEntry);

}
results = widget.transitionDelegate._transition(
newPageRouteHistory:newHistoryRecord,
// List<RouteTransitionRecord> : newHistory = List<_RouteEntry>
locationToExitingPageRoute: locationToExitingPageRoute,
pageRouteToPagelessRoutes: pageRouteToPagelessRoutesRecord
).Cast<_RouteEntry>();

// Adds the leading pageless routes if there is any.
if (pageRouteToPagelessRoutes.ContainsKey(null)) {
foreach (var pageRoute in pageRouteToPagelessRoutes[null]) {
_history.Add(pageRoute);
}
//_history.addAll(pageRouteToPagelessRoutes[null]);
_history.AddRange(pageRouteToPagelessRoutes[null]);
//_history.addAll(pageRouteToPagelessRoutes[result]);
foreach (var pageRoute in pageRouteToPagelessRoutes[result]) {
_history.Add(pageRoute);
}
_history.AddRange(pageRouteToPagelessRoutes[result]);
}
}

_flushRouteAnnouncement();
/* _RouteEntry lastEntry = null;//_history.lastWhere(_RouteEntry.isPresentPredicate, orElse: () => null);
_RouteEntry lastEntry = null;//_history.lastWhere(_RouteEntry.isPresentPredicate, orElse: () => null);
foreach (var historyEntry in _history) {
if (_RouteEntry.isPresentPredicate(historyEntry)) {
lastEntry = historyEntry;

if (routeName != _lastAnnouncedRouteName) {
//RouteNotificationMessages.maybeNotifyRouteChange(routeName, _lastAnnouncedRouteName);
//RouteNotificationMessages.maybeNotifyRouteChange(routeName, _lastAnnouncedRouteName);
}*/
}
// Lastly, removes the overlay entries of all marked entries and disposes
// them.

public Future<T> pushReplacementNamed<T, TO>(
string routeName,
TO result,
TO result = default,
object arguments = null
) {
return pushReplacement<T, TO>(_routeNamed<T>(routeName, arguments: arguments), result: result);

string routeName,
TO result,
TO result = default,
object arguments = null
) {
pop<TO>(result);

_afterNavigation(route);
return route.popped.to<T>();
}
/*if (!kReleaseMode) {
if (!foundation_.kReleaseMode) {
if (route is TransitionRoute<T>) {
TransitionRoute<T> transitionRoute = (TransitionRoute<T>)route;
description = transitionRoute.debugLabel;
if (route is TransitionRoute ){
//TransitionRoute transitionRoute = route;
description = ((TransitionRoute)route).debugLabel;
description = "$route";
description = $"{route}";
}
routeJsonable["description"] = description;

"name": settings.name
{"name", settings.name}
if (settings.arguments != null) {
/*if (settings.arguments != null) {
toEncodable: (object object) => "$object"
);
}
toEncodable: (object _object) => $"{_object}"
);
}*/
developer.postEvent("Flutter.Navigation", < string, object >{
"route": routeJsonable
// todo
developer.developer_.postEvent("Flutter.Navigation", new Hashtable{
{"route", routeJsonable}
}*/
}
public Future<T> pushReplacement<T, TO>(Route<T> newRoute, TO result) {
D.assert(!_debugLocked);

_debugLocked = true;
return true;
});
//D.assert(_history.where(_RouteEntry.isRoutePredicate(route)).length == 1);
// D.assert(_history.Where(_RouteEntry.isRoutePredicate(route)).Count() == 1);
List<_RouteEntry> routeEntries = new List<_RouteEntry>();
foreach (var historyEntry in _history) {
if (_RouteEntry.isRoutePredicate(route)(historyEntry)) {

247
com.unity.uiwidgets/Runtime/widgets/overlay.cs


internal OverlayState _overlay;
internal readonly GlobalKey<_OverlayEntryWidgetState> _key = new LabeledGlobalKey<_OverlayEntryWidgetState>();
internal readonly GlobalKey<_OverlayEntryWidgetState> _key = GlobalKey<_OverlayEntryWidgetState>.key();//new LabeledGlobalKey<_OverlayEntryWidgetState>();
public void remove() {
D.assert(_overlay != null);

class _OverlayEntryWidget : StatefulWidget {
internal _OverlayEntryWidget(Key key, OverlayEntry entry, bool tickerEnabled = true) : base(key: key) {
internal _OverlayEntryWidget(
Key key,
OverlayEntry entry,
bool tickerEnabled = true) : base(key: key) {
D.assert(key != null);
D.assert(entry != null);
this.entry = entry;

class _OverlayEntryWidgetState : State<_OverlayEntryWidget> {
public override Widget build(BuildContext context) {
return widget.entry.builder(context);
return new TickerMode(
enabled: widget.tickerEnabled,
child: widget.entry.builder(context)
);
}
internal void _markNeedsBuild() {

}
public class Overlay : StatefulWidget {
public Overlay(Key key = null, List<OverlayEntry> initialEntries = null) : base(key) {
public Overlay(
Key key = null,
List<OverlayEntry> initialEntries = null) : base(key) {
D.assert(initialEntries != null);
this.initialEntries = initialEntries;
}

public static OverlayState of(BuildContext context, Widget debugRequiredFor = null) {
OverlayState result = (OverlayState) context.ancestorStateOfType(new TypeMatcher<OverlayState>());
public static OverlayState of(
BuildContext context,
bool rootOverlay = false,
Widget debugRequiredFor = null) {
OverlayState result = rootOverlay
? context.findRootAncestorStateOfType<OverlayState>()
: context.findAncestorStateOfType<OverlayState>();
D.assert(() => {
if (debugRequiredFor != null && result == null) {
var additional = context.widget != debugRequiredFor

$"{debugRequiredFor.GetType()} widgets require an Overlay widget ancestor for correct operation.\n" +
"The most common way to add an Overlay to an application is to include a MaterialApp or Navigator widget in the runApp() call.\n" +
"The specific widget that failed to find an overlay was:\n" +
$" {debugRequiredFor}" +
//$" {debugRequiredFor}" +
$"{additional}"
);
}

{
List<OverlayEntry> newEntriesList =
newEntries is List<OverlayEntry> ? (newEntries as List<OverlayEntry>) : newEntries.ToList();
/*D.assert(above == null || below == null, () => "Only one of `above` and `below` may be specified.");
D.assert(above == null || (above._overlay == this && _entries.Contains(above)),
() => "The provided entry for `above` is not present in the Overlay.");
D.assert(below == null || (below._overlay == this && _entries.Contains(below)),
() => "The provided entry for `below` is not present in the Overlay.");
D.assert(newEntriesList.All(entry => !_entries.Contains(entry)),
() => "One or more of the specified entries are already present in the Overlay.");
D.assert(newEntriesList.All(entry => entry._overlay == null),
() => "One or more of the specified entries are already present in another Overlay.");*/
D.assert(
above == null || below == null,
()=>"Only one of `above` and `below` may be specified."

foreach (OverlayEntry entry in newEntriesList) {
old.Remove(entry);
}
_entries.InsertRange(_insertionIndex(below, above), old);
});
}

return new _Theatre(
skipCount: children.Count - onstageCount,
children: children.ToList()
// onstage: new Stack(
// fit: StackFit.expand,
// children: onstageChildren
// ),
// offstage: offstageChildren
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<List<OverlayEntry>>("entries", _entries));
internal _Theatre(Key key = null,
internal _Theatre(
Key key = null,
D.assert(skipCount != null);
D.assert(skipCount >= 0);
D.assert(children != null);
D.assert(children.Count() >= skipCount);

renderObject.skipCount = skipCount;
renderObject.textDirection = Directionality.of(context);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new IntProperty("skipCount", skipCount));
}
}
class _TheatreElement : MultiChildRenderObjectElement {

}
}
}
// Element _onstage;
// static readonly object _onstageSlot = new object();
//
// List<Element> _offstage;
// readonly HashSet<Element> _forgottenOffstageChildren = new HashSet<Element>();
//
// protected override void insertChildRenderObject(RenderObject child, object slot) {
// D.assert(this.renderObject.debugValidateChild(child));
// if (slot == _onstageSlot) {
// D.assert(child is RenderStack);
// this.renderObject.child = (RenderStack) child;
// }
// else {
// D.assert(slot == null || slot is Element);
// this.renderObject.insert((RenderBox) child, after: (RenderBox) ((Element) slot)?.renderObject);
// }
// }
//
// protected override void moveChildRenderObject(RenderObject child, object slot) {
// if (slot == _onstageSlot) {
// this.renderObject.remove((RenderBox) child);
// D.assert(child is RenderStack);
// this.renderObject.child = (RenderStack) child;
// }
// else {
// D.assert(slot == null || slot is Element);
// if (this.renderObject.child == child) {
// this.renderObject.child = null;
// this.renderObject.insert((RenderBox) child, after: (RenderBox) ((Element) slot)?.renderObject);
// }
// else {
// this.renderObject.move((RenderBox) child, after: (RenderBox) ((Element) slot)?.renderObject);
// }
// }
// }
//
// protected override void removeChildRenderObject(RenderObject child) {
// if (this.renderObject.child == child) {
// this.renderObject.child = null;
// }
// else {
// this.renderObject.remove((RenderBox) child);
// }
// }
//
// public override void visitChildren(ElementVisitor visitor) {
// if (this._onstage != null) {
// visitor(this._onstage);
// }
//
// foreach (var child in this._offstage) {
// if (!this._forgottenOffstageChildren.Contains(child)) {
// visitor(child);
// }
// }
// }
//
// // public override void debugVisitOnstageChildren(ElementVisitor visitor) {
// // if (this._onstage != null) {
// // visitor(this._onstage);
// // }
// // }
//
//
// protected override void forgetChild(Element child) {
// if (child == this._onstage) {
// this._onstage = null;
// }
// else {
// D.assert(this._offstage.Contains(child));
// D.assert(!this._forgottenOffstageChildren.Contains(child));
// this._forgottenOffstageChildren.Add(child);
// }
// }
//
// public override void mount(Element parent, object newSlot) {
// base.mount(parent, newSlot);
// this._onstage = this.updateChild(this._onstage, this.widget.onstage, _onstageSlot);
// this._offstage = new List<Element>(this.widget.offstage.Count);
// Element previousChild = null;
// for (int i = 0; i < this._offstage.Count; i += 1) {
// var newChild = this.inflateWidget(this.widget.offstage[i], previousChild);
// this._offstage[i] = newChild;
// previousChild = newChild;
// }
// }
//
// public override void update(Widget newWidget) {
// base.update(newWidget);
// D.assert(Equals(this.widget, newWidget));
// this._onstage = this.updateChild(this._onstage, this.widget.onstage, _onstageSlot);
// this._offstage = this.updateChildren(this._offstage, this.widget.offstage,
// forgottenChildren: this._forgottenOffstageChildren);
// this._forgottenOffstageChildren.Clear();
// }
// }
class _RenderTheatre :
ContainerRenderObjectMixinRenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack<
RenderBox, StackParentData> {

int skipCount = 0
) {
D.assert(skipCount != null);
D.assert(textDirection != null);
_textDirection = textDirection;
_skipCount = skipCount;
addAll(children);

public override void setupParentData(RenderObject child) {
if (!(child.parentData is StackParentData)) {
child.parentData = new StackParentData();
}
}
Alignment _resolvedAlignment;

//_resolvedAlignment = AlignmentDirectional.topStart.resolve(textDirection);
// TODO: AlignmentDirectional
Alignment al = Alignment.topLeft;
switch (textDirection) {

RenderBox _firstOnstageChild {
get {
if (skipCount == childCount) {
if (skipCount == base.childCount) {
return null;
}

}
}
public override void setupParentData(RenderObject child) {
if (!(child.parentData is StackParentData)) {
child.parentData = new StackParentData();
}
RenderBox _lastOnstageChild {
get { return skipCount == childCount ? null : lastChild; }
}
int _onstageChildCount {
get { return childCount - skipCount; }
public override void redepthChildren() {
if (child != null) {

}
public override List<DiagnosticsNode> debugDescribeChildren() {
var children = new List<DiagnosticsNode>();
List<DiagnosticsNode> offstageChildren = new List<DiagnosticsNode>();
List<DiagnosticsNode> onstageChildren = new List<DiagnosticsNode>();
if (this.child != null) {
children.Add(child.toDiagnosticsNode(name: "onstage"));
}
if (firstChild != null) {
var child = firstChild;
int count = 1;
bool onstage = false;
RenderBox child = firstChild;
RenderBox firstOnstageChild = _firstOnstageChild;
while (child != null) {
if (child == firstOnstageChild) {
onstage = true;
count = 1;
}
int count = 1;
while (true) {
children.Add(
if (onstage) {
onstageChildren.Add(
child.toDiagnosticsNode(
name: $"onstage {count}"
)
);
} else {
offstageChildren.Add(
if (child == lastChild) {
break;
}
}
var childParentData = (StackParentData) child.parentData;
child = childParentData.nextSibling;
count += 1;
StackParentData childParentData = child.parentData as StackParentData;
child = childParentData.nextSibling;
count += 1;
}
if (offstageChildren.isNotEmpty()) {
foreach (var stagechild in offstageChildren) {
onstageChildren.Add(stagechild);
children.Add(
DiagnosticsNode.message(
"no offstage children",
style: DiagnosticsTreeStyle.offstage
)
);
onstageChildren.Add(DiagnosticsNode.message(
"no offstage children",
style: DiagnosticsTreeStyle.offstage
));
return children;
}
return onstageChildren;
RenderBox _lastOnstageChild {
get { return skipCount == childCount ? null : lastChild; }
int _onstageChildCount {
get { return childCount - skipCount; }
}
protected internal override float computeMinIntrinsicWidth(float height) {
return RenderStack.getIntrinsicDimension(_firstOnstageChild,

for (int i = 0; i < _onstageChildCount; i++) {
D.assert(child != null);
StackParentData childParentData = child.parentData as StackParentData;
if (childParentData.offset.dx != 0 || childParentData.offset.dy != 0) {
i = i;
}
bool isHit = result.addWithPaintOffset(
offset: childParentData.offset,
position: position,

36
com.unity.uiwidgets/Runtime/widgets/pages.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.widgets {
public class PagesUtils {
public static Widget _defaultTransitionsBuilder(BuildContext context, Animation<float>
animation, Animation<float> secondaryAnimation, Widget child) {
return child;
}
}
public PageRoute(RouteSettings settings, bool fullscreenDialog = false) : base(settings) {
public PageRoute(
RouteSettings settings = null,
bool fullscreenDialog = false) : base(settings) {
this.fullscreenDialog = fullscreenDialog;
}

return previousRoute is PageRoute;
}
public override AnimationController createAnimationController() {
var controller = base.createAnimationController();
if (settings.isInitialRoute) {
controller.setValue(1.0f);
}
return controller;
}
}
public class PageRouteBuilder : PageRoute {

bool opaque = true,
bool barrierDismissible = false,
Color barrierColor = null,
bool maintainState = true
) : base(settings) {
string barrierLabel = null,
bool maintainState = true,
bool fullscreenDialog = false
) : base(settings,fullscreenDialog) {
D.assert(transitionsBuilder != null);
this.transitionsBuilder = transitionsBuilder ?? _defaultTransitionsBuilder;
this.transitionsBuilder = transitionsBuilder ?? PagesUtils._defaultTransitionsBuilder;
this.barrierLabel = barrierLabel;
this.maintainState = maintainState;
this.barrierDismissible = barrierDismissible;
}

public override bool opaque { get; }
public override string barrierLabel { get; }
Widget _defaultTransitionsBuilder(BuildContext context, Animation<float>
animation, Animation<float> secondaryAnimation, Widget child) {
return child;
}
public override Widget buildPage(BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation) {

4
com.unity.uiwidgets/Runtime/widgets/route_notification_messages.cs


} else {
// No op.
}
}*/
}
/*public static void _notifyRouteChange(string routeName, string previousRouteName) {
public static void _notifyRouteChange(string routeName, string previousRouteName) {
SystemChannels.navigation.invokeMethod<void>(
'routeUpdated',
<string, dynamic>{

177
com.unity.uiwidgets/Runtime/widgets/routes.cs


namespace Unity.UIWidgets.widgets {
public abstract class OverlayRoute : Route {
readonly List<OverlayEntry> _overlayEntries = new List<OverlayEntry>();
public readonly List<OverlayEntry> _overlayEntries = new List<OverlayEntry>();
public OverlayRoute(
RouteSettings settings = null

get { return true; }
}
public abstract ICollection<OverlayEntry> createOverlayEntries();
public abstract IEnumerable<OverlayEntry> createOverlayEntries();
protected internal override void install(){//(OverlayEntry insertionPoint) {
protected internal override void install(){
navigator.overlay?.insertAll(_overlayEntries);
base.install();
}
protected internal override bool didPop(object result) {

navigator.finalizeRoute(this);
}
/*foreach (var entry in _overlayEntries) {
entry.remove();
}*/
public abstract class OverlayRoute<T> : OverlayRoute {
public readonly List<OverlayEntry> _overlayEntries = new List<OverlayEntry>();
public OverlayRoute(
RouteSettings settings = null
) : base(settings : settings) {
}
protected internal new bool didPop(T result) {
var returnValue = base.didPop(result);
D.assert(returnValue);
if (finishedWhenPopped) {
navigator.finalizeRoute(this);
}
return returnValue;
}
}
) : base(settings) {
) : base(settings) {
}
public Future completed {

D.assert(duration >= TimeSpan.Zero && duration != null);
return new AnimationController(
duration: duration,
//reverseDuration: reverseDuration, /// todo
reverseDuration: reverseDuration,
debugLabel: debugLabel,
vsync: navigator
);

D.assert(_controller != null,
() => $"{GetType()}.didPush called before calling install() or after calling dispose().");
D.assert(!_transitionCompleter.isCompleted, () => $"Cannot reuse a {GetType()} after disposing it.");
//_animation.addStatusListener(_handleStatusChanged);
//return _controller.forward();
_didPushOrReplace();
base.didPush();
return _controller.forward();

if (oldRoute is TransitionRoute) {
_controller.setValue(((TransitionRoute)oldRoute)._controller.value);
}
_animation.addStatusListener(_handleStatusChanged);
_didPushOrReplace();
base.didReplace(oldRoute);
}
public void _didPushOrReplace() {

void _updateSecondaryAnimation(Route nextRoute) {
VoidCallback previousTrainHoppingListenerRemover = _trainHoppingListenerRemover;
_trainHoppingListenerRemover = null;
if (nextRoute is TransitionRoute && canTransitionTo((TransitionRoute) nextRoute) &&
((TransitionRoute) nextRoute).canTransitionFrom(this)) {
if (nextRoute is TransitionRoute && canTransitionTo((TransitionRoute)nextRoute) &&
((TransitionRoute) nextRoute).canTransitionFrom((TransitionRoute)this)) {
currentTrain.value == nextTrain.value ||
nextTrain.status == AnimationStatus.completed ||
nextTrain.status == AnimationStatus.dismissed
) {
_setSecondaryAnimation(nextTrain, ((TransitionRoute)nextRoute).completed);
currentTrain.value == nextTrain.value ||
nextTrain.status == AnimationStatus.completed ||
nextTrain.status == AnimationStatus.dismissed
) {
_setSecondaryAnimation(nextTrain, ((TransitionRoute)nextRoute).completed);
TrainHoppingAnimation newAnimation = null;
void _jumpOnAnimationEnd(AnimationStatus status) {
switch (status) {
case AnimationStatus.completed:
case AnimationStatus.dismissed:
_setSecondaryAnimation(nextTrain, ((TransitionRoute)nextRoute).completed);
if (_trainHoppingListenerRemover != null) {
_trainHoppingListenerRemover();
_trainHoppingListenerRemover = null;
TrainHoppingAnimation newAnimation = null;
void _jumpOnAnimationEnd(AnimationStatus status) {
switch (status) {
case AnimationStatus.completed:
case AnimationStatus.dismissed:
_setSecondaryAnimation(nextTrain, ((TransitionRoute)nextRoute).completed);
if (_trainHoppingListenerRemover != null) {
_trainHoppingListenerRemover();
_trainHoppingListenerRemover = null;
}
break;
case AnimationStatus.forward:
case AnimationStatus.reverse:
break;
}
}
_trainHoppingListenerRemover = ()=> {
nextTrain.removeStatusListener(_jumpOnAnimationEnd);
newAnimation?.dispose();
};
nextTrain.addStatusListener(_jumpOnAnimationEnd);
newAnimation = new TrainHoppingAnimation(
currentTrain,
nextTrain,
onSwitchedTrain: ()=> {
D.assert(_secondaryAnimation.parent == newAnimation);
D.assert(newAnimation.currentTrain == ((TransitionRoute)nextRoute)._animation);
_setSecondaryAnimation(newAnimation.currentTrain, ((TransitionRoute)nextRoute).completed);
if (_trainHoppingListenerRemover != null) {
_trainHoppingListenerRemover();
_trainHoppingListenerRemover = null;
}
break;
case AnimationStatus.forward:
case AnimationStatus.reverse:
break;
}
}
_trainHoppingListenerRemover = ()=> {
nextTrain.removeStatusListener(_jumpOnAnimationEnd);
newAnimation?.dispose();
};
nextTrain.addStatusListener(_jumpOnAnimationEnd);
newAnimation = new TrainHoppingAnimation(
currentTrain,
nextTrain,
onSwitchedTrain: ()=> {
D.assert(_secondaryAnimation.parent == newAnimation);
D.assert(newAnimation.currentTrain == ((TransitionRoute)nextRoute)._animation);
_setSecondaryAnimation(newAnimation.currentTrain, ((TransitionRoute)nextRoute).completed);
if (_trainHoppingListenerRemover != null) {
_trainHoppingListenerRemover();
_trainHoppingListenerRemover = null;
}
}
);
_setSecondaryAnimation(newAnimation, ((TransitionRoute)nextRoute).completed);
}

}
}
public class LocalHistoryEntry {
public LocalHistoryEntry(VoidCallback onRemove = null) {
this.onRemove = onRemove;

if (_localHistory.isEmpty()) {
//changedInternalState();
if (SchedulerBinding.instance.schedulerPhase == SchedulerPhase.persistentCallbacks) {
SchedulerBinding.instance.addPostFrameCallback((TimeSpan timestamp) =>{
changedInternalState();
});

if (willHandlePopInternally) {
return Future.value(RoutePopDisposition.pop).to<RoutePopDisposition>();
}
return base.willPop();
}

Listenable _listenable;
public readonly FocusScopeNode focusScopeNode = new FocusScopeNode();//debugLabel: "$_ModalScopeState Focus Scope");
public readonly FocusScopeNode focusScopeNode = new FocusScopeNode(debugLabel: $"{typeof(_ModalScopeState)} Focus Scope");
var animations = new List<Listenable> { };
var animations = new List<Listenable>();
if (widget.route.animation != null) {
animations.Add(widget.route.animation);
}

child: new PageStorage(
bucket: widget.route._storageBucket,
child: new FocusScope(
node: widget.route.focusScopeNode,
node: focusScopeNode,
child: new RepaintBoundary(
child: new AnimatedBuilder(
animation: _listenable, // immutable

animation: widget.route.navigator?.userGestureInProgressNotifier ?? new ValueNotifier<bool>(false),
builder: (BuildContext context1, Widget child1) =>{
bool ignoreEvents = _shouldIgnoreFocusRequest;
//focusScopeNode.canRequestFocus = !ignoreEvents; // todo
focusScopeNode.canRequestFocus = !ignoreEvents; // todo
return new IgnorePointer(
ignoring: ignoreEvents,
child: child1

)
/*new IgnorePointer(
ignoring: widget.route.animation?.status ==
AnimationStatus.reverse,
child: child
)*/
child: _page
child: _page = _page ??= new RepaintBoundary(
key: widget.route._subtreeKey, // immutable
child: new Builder(
builder: (BuildContext context2) =>{
return widget.route.buildPage(
context2,
widget.route.animation,
widget.route.secondaryAnimation
);
}
)
)
)
)
)

public static Color _kTransparent = new Color(0x00000000);
public static ModalRoute of(BuildContext context) {
//_ModalScopeStatus widget = (_ModalScopeStatus) context.inheritFromWidgetOfExactType(typeof(_ModalScopeStatus));
//return (ModalRoute<T>) widget?.route;
_ModalScopeStatus widget = context.dependOnInheritedWidgetOfExactType<_ModalScopeStatus>();
return widget?.route as ModalRoute;
}

}
base.didAdd();
}
/*public override void dispose() {
focusScopeNode.detach();
base.dispose();
}*/
public virtual bool barrierDismissible { get; }

protected internal override void changedExternalState() {
base.changedExternalState();
//_scopeKey.currentState?._forceRebuildPage();
if (_scopeKey.currentState != null)
_scopeKey.currentState._forceRebuildPage();
}

public readonly GlobalKey<_ModalScopeState> _scopeKey = new LabeledGlobalKey<_ModalScopeState>();
internal readonly GlobalKey _subtreeKey = GlobalKey.key();
internal readonly PageStorageBucket _storageBucket = new PageStorageBucket();
//static readonly Animatable<float> _easeCurveTween = new CurveTween(curve: Curves.ease);
OverlayEntry _modalBarrier;
Widget _buildModalBarrier(BuildContext context) {

public Widget _modalScopeCache;
public virtual Widget _buildModalScope(BuildContext context) {
return _modalScopeCache = _modalScopeCache ?? new _ModalScope(
key: _scopeKey,
route: this
// _ModalScope calls buildTransitions() and buildChild(), defined above
);
return _modalScopeCache = _modalScopeCache ?? new _ModalScope(key: _scopeKey, route: this);
public override ICollection<OverlayEntry> createOverlayEntries() {
public override IEnumerable<OverlayEntry> createOverlayEntries() {
_modalBarrier = new OverlayEntry(builder: _buildModalBarrier);
var content = new OverlayEntry(
builder: _buildModalScope, maintainState: maintainState

}
public override Widget _buildModalScope(BuildContext context) {
return _modalScopeCache = _modalScopeCache ?? new _ModalScope<T>(
key: _scopeKey,
route: this
// _ModalScope calls buildTransitions() and buildChild(), defined above
);
return _modalScopeCache = _modalScopeCache ?? new _ModalScope<T>(key: _scopeKey, route: this);
}

}
}
var subscribers =_listeners.getOrDefault((R) route);
/* foreach (var key in _listeners.Keys) {
subscribers.Add(_listeners[key].ToList());
}*/
var subscribers =_listeners.getOrDefault((R) route).ToList();
if (subscribers != null) {
foreach (RouteAware routeAware in subscribers) {
routeAware.didPop();

正在加载...
取消
保存