Exemplo n.º 1
0
 public static Future <T> showGeneralDialog <T>(
     BuildContext context         = null,
     RoutePageBuilder pageBuilder = null,
     bool?barrierDismissible      = null,
     string barrierLabel          = null,
     Color barrierColor           = null,
     TimeSpan?transitionDuration  = null,
     RouteTransitionsBuilder transitionBuilder = null,
     bool useRootNavigator       = true,
     RouteSettings routeSettings = null
     )
 {
     //D.assert(!barrierDismissible || barrierLabel != null);
     D.assert(pageBuilder != null);
     return(Navigator.of(context, rootNavigator: true).push(
                new _DialogRoute(
                    pageBuilder: pageBuilder,
                    barrierDismissible: barrierDismissible ?? false,
                    barrierLabel: barrierLabel,
                    barrierColor: barrierColor,
                    transitionDuration: transitionDuration,
                    transitionBuilder: transitionBuilder,
                    settings: routeSettings)  as Route
                ).to <T>());
 }
Exemplo n.º 2
0
        _allHeroesFor(BuildContext context, bool isUserGestureTransition, NavigatorState navigator)
        {
            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 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);
                            }
                        }
                    }
                }

                element.visitChildren(visitor);
            }

            context.visitChildElements(visitor);
            return(result);
        }
Exemplo n.º 3
0
 public static IPromise <object> showGeneralDialog(
     BuildContext context         = null,
     RoutePageBuilder pageBuilder = null,
     bool barrierDismissible      = false,
     Color barrierColor           = null,
     TimeSpan?transitionDuration  = null,
     RouteTransitionsBuilder transitionBuilder = null
     )
 {
     D.assert(pageBuilder != null);
     return(Navigator.of(context, rootNavigator: true).push(new _DialogRoute(
                                                                pageBuilder: pageBuilder,
                                                                barrierDismissible: barrierDismissible,
                                                                barrierColor: barrierColor,
                                                                transitionDuration: transitionDuration,
                                                                transitionBuilder: transitionBuilder
                                                                )));
 }
Exemplo n.º 4
0
 public static void removeRoute(BuildContext context, Route route)
 {
     Navigator.of(context).removeRoute(route);
 }
Exemplo n.º 5
0
 public static void popUntil(BuildContext context, RoutePredicate predicate)
 {
     Navigator.of(context).popUntil(predicate);
 }
Exemplo n.º 6
0
 public static bool pop(BuildContext context, object result = null)
 {
     return(Navigator.of(context).pop(result));
 }
Exemplo n.º 7
0
 public static IPromise <bool> maybePop(BuildContext context, object result = null)
 {
     return(Navigator.of(context).maybePop(result));
 }
Exemplo n.º 8
0
        public static bool canPop(BuildContext context)
        {
            NavigatorState navigator = Navigator.of(context, nullOk: true);

            return(navigator != null && navigator.canPop());
        }
Exemplo n.º 9
0
 public static void replaceRouteBelow(BuildContext context, Route anchorRoute = null, Route newRoute = null)
 {
     D.assert(anchorRoute != null);
     D.assert(newRoute != null);
     Navigator.of(context).replaceRouteBelow(anchorRoute: anchorRoute, newRoute: newRoute);
 }
Exemplo n.º 10
0
 public static IPromise <object> pushAndRemoveUntil(BuildContext context, Route newRoute,
                                                    RoutePredicate predicate)
 {
     return(Navigator.of(context).pushAndRemoveUntil(newRoute, predicate));
 }
Exemplo n.º 11
0
 public static IPromise <object> pushReplacement(BuildContext context, Route newRoute, object result = null)
 {
     return(Navigator.of(context).pushReplacement(newRoute, result));
 }
Exemplo n.º 12
0
 public static IPromise <object> push(BuildContext context, Route route)
 {
     return(Navigator.of(context).push(route));
 }
Exemplo n.º 13
0
 public static IPromise <object> popAndPushNamed(BuildContext context, string routeName, object result = null)
 {
     return(Navigator.of(context).popAndPushNamed(routeName, result: result));
 }
Exemplo n.º 14
0
 public static IPromise <object> pushNamed(BuildContext context, string routeName)
 {
     return(Navigator.of(context).pushNamed(routeName));
 }
Exemplo n.º 15
0
 static void removeRouteBelow(BuildContext context, Route anchorRoute)
 {
     Navigator.of(context).removeRouteBelow(anchorRoute);
 }
Exemplo n.º 16
0
 public static void replace(BuildContext context, Route oldRoute = null, Route newRoute = null)
 {
     D.assert(oldRoute != null);
     D.assert(newRoute != null);
     Navigator.of(context).replace(oldRoute: oldRoute, newRoute: newRoute);
 }
Exemplo n.º 17
0
        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> {
            };

            void inviteHero(StatefulElement hero, object tag)
            {
                D.assert(() => {
                    if (result.ContainsKey(tag))
                    {
                        throw new UIWidgetsError(
                            new List <DiagnosticsNode>()
                        {
                            new ErrorSummary("There are multiple heroes that share the same tag within a subtree."),
                            new ErrorDescription(
                                "Within each subtree for which heroes are to be animated (i.e. a PageRoute subtree), " +
                                "each Hero must have a unique non-null tag.\n" +
                                $"In this case, multiple heroes had the following tag: {tag}\n"
                                ),
                            new DiagnosticsProperty <StatefulElement>("Here is the subtree for one of the offending heroes", hero, linePrefix: "# ", style: DiagnosticsTreeStyle.dense),
                        });
                    }
                    return(true);
                });
                Hero       heroWidget = hero.widget as Hero;
                _HeroState heroState  = hero.state as _HeroState;

                if (!isUserGestureTransition || heroWidget.transitionOnUserGestures)
                {
                    result[tag] = heroState;
                }
                else
                {
                    heroState.ensurePlaceholderIsHidden();
                }
            }

            void visitor(Element element)
            {
                Widget widget = element.widget;

                if (widget is Hero)
                {
                    StatefulElement hero = element as StatefulElement;
                    object          tag  = ((Hero)widget).tag;
                    D.assert(tag != null);
                    if (Navigator.of(hero) == navigator)
                    {
                        inviteHero(hero, tag);
                    }
                    else
                    {
                        ModalRoute heroRoute = ModalRoute.of(hero);
                        if (heroRoute != null && heroRoute is PageRoute && heroRoute.isCurrent)
                        {
                            inviteHero(hero, tag);
                        }
                    }
                }

                element.visitChildren(visitor);
            }

            context.visitChildElements(visitor);
            return(result);
        }