Exemplo n.º 1
0
 public void popUntil(RoutePredicate predicate)
 {
     while (!predicate(this._history.last()))
     {
         this.pop();
     }
 }
Exemplo n.º 2
0
        public IPromise <object> pushAndRemoveUntil(Route newRoute, RoutePredicate predicate)
        {
            D.assert(!this._debugLocked);
            D.assert(() => {
                this._debugLocked = true;
                return(true);
            });
            var removedRoutes = new List <Route>();

            while (this._history.isNotEmpty() && !predicate(this._history.last()))
            {
                var removedRoute = this._history.last();
                this._history.RemoveAt(this._history.Count - 1);
                D.assert(removedRoute != null && removedRoute._navigator == this);
                D.assert(removedRoute.overlayEntries.isNotEmpty());
                removedRoutes.Add(removedRoute);
            }

            D.assert(newRoute._navigator == null);
            D.assert(newRoute.overlayEntries.isEmpty());
            var oldRoute = this._history.isNotEmpty() ? this._history.last() : null;

            newRoute._navigator = this;
            newRoute.install(this._currentOverlayEntry);
            this._history.Add(newRoute);
            newRoute.didPush().whenCompleteOrCancel(() => {
                if (this.mounted)
                {
                    foreach (var route in removedRoutes)
                    {
                        route.dispose();
                    }
                }
            });
            newRoute.didChangeNext(null);
            if (oldRoute != null)
            {
                oldRoute.didChangeNext(newRoute);
            }

            foreach (var observer in this.widget.observers)
            {
                observer.didPush(newRoute, oldRoute);
                foreach (var removedRoute in removedRoutes)
                {
                    observer.didRemove(removedRoute, oldRoute);
                }
            }

            D.assert(() => {
                this._debugLocked = false;
                return(true);
            });
            this._afterNavigation();
            return(newRoute.popped);
        }
Exemplo n.º 3
0
 public IPromise <object> pushNamedAndRemoveUntil(string newRouteName, RoutePredicate predicate)
 {
     return(this.pushAndRemoveUntil(this._routeNamed(newRouteName), predicate));
 }
Exemplo n.º 4
0
 public static void popUntil(BuildContext context, RoutePredicate predicate)
 {
     Navigator.of(context).popUntil(predicate);
 }
Exemplo n.º 5
0
 public static IPromise <object> pushAndRemoveUntil(BuildContext context, Route newRoute,
                                                    RoutePredicate predicate)
 {
     return(Navigator.of(context).pushAndRemoveUntil(newRoute, predicate));
 }
Exemplo n.º 6
0
 public IPromise <object> pushNamedAndRemoveUntil(string newRouteName, RoutePredicate predicate,
                                                  object arguments = null)
 {
     return(this.pushAndRemoveUntil(this._routeNamed(newRouteName, arguments: arguments), predicate));
 }
Exemplo n.º 7
0
 public static IPromise <object> pushNamedAndRemoveUntil(BuildContext context, string newRouteName,
                                                         RoutePredicate predicate, object arguments = null)
 {
     return(of(context).pushNamedAndRemoveUntil(newRouteName, predicate, arguments: arguments));
 }