Пример #1
0
 /// <include file="../../../docs/Microsoft.Maui.Controls/ShellNavigatingEventArgs.xml" path="//Member[@MemberName='.ctor']/Docs" />
 public ShellNavigatingEventArgs(ShellNavigationState current, ShellNavigationState target, ShellNavigationSource source, bool canCancel)
 {
     _deferralFinishedTask = () => Task.CompletedTask;
     Current   = current;
     Target    = target;
     Source    = source;
     CanCancel = canCancel;
     Animate   = true;
 }
Пример #2
0
        public async Task GoTo(MC.ShellNavigationState state, bool animate = true)
        {
            if (state is null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            await NativeControl.GoToAsync(state, animate).ConfigureAwait(true);
        }
Пример #3
0
 public Task GoToAsync(ShellNavigationState state, bool?animate, bool enableRelativeShellRoutes, ShellNavigatingEventArgs deferredArgs = null)
 {
     return(GoToAsync(new ShellNavigationParameters
     {
         TargetState = state,
         Animated = animate,
         EnableRelativeShellRoutes = enableRelativeShellRoutes,
         DeferredArgs = deferredArgs
     }));
 }
Пример #4
0
        /// <include file="../../../docs/Microsoft.Maui.Controls/ShellNavigatingEventArgs.xml" path="//Member[@MemberName='.ctor']/Docs" />
        public ShellNavigatingEventArgs(ShellNavigationState current, ShellNavigationState target, ShellNavigationSource source, bool canCancel)
        {
#if !NETSTANDARD1_0
            _deferralFinishedTask = () => Task.CompletedTask;
#else
            _deferralFinishedTask = () => Task.Delay(0);
#endif
            Current   = current;
            Target    = target;
            Source    = source;
            CanCancel = canCancel;
            Animate   = true;
        }
Пример #5
0
        ShellNavigatingEventArgs ProposeNavigation(
            ShellNavigationSource source,
            ShellNavigationState proposedState,
            bool canCancel,
            bool isAnimated)
        {
            if (AccumulateNavigatedEvents)
            {
                return(null);
            }

            var navArgs = new ShellNavigatingEventArgs(_shell.CurrentState, proposedState, source, canCancel)
            {
                Animate = isAnimated
            };

            HandleNavigating(navArgs);

            return(navArgs);
        }
Пример #6
0
        public static ShellNavigationSource CalculateNavigationSource(Shell shell, ShellNavigationState current, ShellNavigationRequest request)
        {
            if (request.StackRequest == ShellNavigationRequest.WhatToDoWithTheStack.PushToIt)
            {
                return(ShellNavigationSource.Push);
            }

            if (current == null)
            {
                return(ShellNavigationSource.ShellItemChanged);
            }

            var targetUri  = ShellUriHandler.ConvertToStandardFormat(shell, request.Request.FullUri);
            var currentUri = ShellUriHandler.ConvertToStandardFormat(shell, current.FullLocation);

            var targetPaths  = ShellUriHandler.RetrievePaths(targetUri.PathAndQuery);
            var currentPaths = ShellUriHandler.RetrievePaths(currentUri.PathAndQuery);

            var targetPathsLength  = targetPaths.Length;
            var currentPathsLength = currentPaths.Length;

            if (targetPathsLength < 4 || currentPathsLength < 4)
            {
                return(ShellNavigationSource.Unknown);
            }

            if (targetPaths[1] != currentPaths[1])
            {
                return(ShellNavigationSource.ShellItemChanged);
            }
            if (targetPaths[2] != currentPaths[2])
            {
                return(ShellNavigationSource.ShellSectionChanged);
            }
            if (targetPaths[3] != currentPaths[3])
            {
                return(ShellNavigationSource.ShellContentChanged);
            }

            if (targetPathsLength == currentPathsLength)
            {
                return(ShellNavigationSource.Unknown);
            }

            if (targetPathsLength < currentPathsLength)
            {
                for (var i = 0; i < targetPathsLength; i++)
                {
                    var targetPath = targetPaths[i];
                    if (targetPath != currentPaths[i])
                    {
                        break;
                    }

                    if (i == targetPathsLength - 1)
                    {
                        if (targetPathsLength == 4)
                        {
                            return(ShellNavigationSource.PopToRoot);
                        }

                        return(ShellNavigationSource.Pop);
                    }
                }

                if (targetPaths[targetPathsLength - 1] == currentPaths[currentPathsLength - 1])
                {
                    return(ShellNavigationSource.Remove);
                }

                if (targetPathsLength == 4)
                {
                    return(ShellNavigationSource.PopToRoot);
                }

                return(ShellNavigationSource.Pop);
            }
            else if (targetPathsLength > currentPathsLength)
            {
                for (var i = 0; i < currentPathsLength; i++)
                {
                    if (targetPaths[i] != currentPaths[i])
                    {
                        break;
                    }

                    if (i == targetPathsLength - 1)
                    {
                        return(ShellNavigationSource.Push);
                    }
                }
            }

            if (targetPaths[targetPathsLength - 1] == currentPaths[currentPathsLength - 1])
            {
                return(ShellNavigationSource.Insert);
            }

            return(ShellNavigationSource.Push);
        }
Пример #7
0
 public ShellNavigatedEventArgs(ShellNavigationState previous, ShellNavigationState current, ShellNavigationSource source)
 {
     Previous = previous;
     Current  = current;
     Source   = source;
 }