Exemplo n.º 1
0
 public Task GoToAsync(
     ShellNavigationState state,
     bool?animate,
     bool enableRelativeShellRoutes,
     ShellNavigatingEventArgs deferredArgs = null,
     ShellRouteParameters parameters       = null,
     bool?canCancel = null)
 {
     return(GoToAsync(new ShellNavigationParameters
     {
         TargetState = state,
         Animated = animate,
         EnableRelativeShellRoutes = enableRelativeShellRoutes,
         DeferredArgs = deferredArgs,
         Parameters = parameters,
         CanCancel = canCancel
     }));
 }
Exemplo n.º 2
0
        public static ShellNavigationParameters GetNavigationParameters(
            ShellItem shellItem,
            ShellSection shellSection,
            ShellContent shellContent,
            IReadOnlyList <Page> sectionStack,
            IReadOnlyList <Page> modalStack)
        {
            var state    = GetNavigationState(shellItem, shellSection, shellContent, sectionStack, modalStack);
            var navStack = shellSection.Navigation.NavigationStack;

            var topNavStackPage =
                (modalStack?.Count > 0 ? modalStack[modalStack.Count - 1] : null) ??
                (navStack?.Count > 0 ? navStack[navStack.Count - 1] : null);

            var queryParametersTarget =
                topNavStackPage as BindableObject ??
                (shellContent?.Content as BindableObject) ??
                shellContent;

            ShellRouteParameters routeParameters = null;

            if (queryParametersTarget?.GetValue(ShellContent.QueryAttributesProperty) is
                ShellRouteParameters shellRouteParameters)
            {
                routeParameters = shellRouteParameters;
            }

            return(new ShellNavigationParameters()
            {
                TargetState = state,
                Animated = false,
                EnableRelativeShellRoutes = false,
                DeferredArgs = null,
                Parameters = routeParameters
            });
        }
Exemplo n.º 3
0
        public static void ApplyQueryAttributes(Element element, ShellRouteParameters query, bool isLastItem, bool isPopping)
        {
            string prefix = "";

            if (!isLastItem)
            {
                var route = Routing.GetRoute(element);
                if (string.IsNullOrEmpty(route) || Routing.IsImplicit(route))
                {
                    return;
                }
                prefix = route + ".";
            }

            //if the lastItem is implicitly wrapped, get the actual ShellContent
            if (isLastItem)
            {
                if (element is IShellItemController shellitem && shellitem.GetItems().FirstOrDefault() is ShellSection section)
                {
                    element = section;
                }
                if (element is IShellSectionController shellsection && shellsection.GetItems().FirstOrDefault() is ShellContent content)
                {
                    element = content;
                }
                if (element is ShellContent shellcontent && shellcontent.Content is Element e)
                {
                    element = e;
                }
            }

            if (!(element is BaseShellItem baseShellItem))
            {
                baseShellItem = element?.Parent as BaseShellItem;
            }

            //filter the query to only apply the keys with matching prefix
            var filteredQuery = new ShellRouteParameters(query.Count);

            foreach (var q in query)
            {
                if (!q.Key.StartsWith(prefix, StringComparison.Ordinal))
                {
                    continue;
                }
                var key = q.Key.Substring(prefix.Length);
                if (key.IndexOf(".", StringComparison.Ordinal) != -1)
                {
                    continue;
                }
                filteredQuery.Add(key, q.Value);
            }


            if (baseShellItem is ShellContent)
            {
                baseShellItem.ApplyQueryAttributes(MergeData(element, filteredQuery, isPopping));
            }
            else if (isLastItem)
            {
                element.SetValue(ShellContent.QueryAttributesProperty, MergeData(element, query, isPopping));
            }

            ShellRouteParameters MergeData(Element shellElement, ShellRouteParameters data, bool isPopping)
            {
                if (!isPopping)
                {
                    return(data);
                }

                var returnValue = new ShellRouteParameters(data);

                var existing = (ShellRouteParameters)shellElement.GetValue(ShellContent.QueryAttributesProperty);

                if (existing == null)
                {
                    return(data);
                }

                foreach (var datum in existing)
                {
                    if (!returnValue.ContainsKey(datum.Key))
                    {
                        returnValue[datum.Key] = datum.Value;
                    }
                }

                return(returnValue);
            }
        }
Exemplo n.º 4
0
 public ShellRouteParameters(ShellRouteParameters shellRouteParams) : base(shellRouteParams)
 {
 }