Пример #1
0
        public override void Show(MvxViewModelRequest request)
        {
            base.Show(request);
#if DEBUG // Only showing this when debugging MVX
            MvxTrace.Trace(FormsApplication.Hierarchy());
#endif
        }
Пример #2
0
        public override Task <bool> Show(MvxViewModelRequest request)
        {
#if DEBUG // Only wrap in try-finally when in debug
            try
            {
#endif
            return(base.Show(request));

#if DEBUG // Only showing this when debugging MVX
        }
        finally
        {
            MvxFormsLog.Instance.Trace(FormsApplication.Hierarchy());
        }
#endif
        }
Пример #3
0
        public override Task <bool> Show(MvxViewModelRequest request)
        {
#if DEBUG // Only wrap in try-finally when in debug
            try
            {
#endif
            return(base.Show(request));

#if DEBUG // Only showing this when debugging MVX
        }
        catch (Exception exception)
        {
            Logger.Log(MvxLogLevel.Debug, () => exception.ToString());
            throw;
        }
        finally
        {
            Logger.Log(MvxLogLevel.Debug, () => FormsApplication.Hierarchy());
        }
#endif
        }
Пример #4
0
        public async override void ChangePresentation(MvxPresentationHint hint)
        {
            var navigation = GetPageOfType <NavigationPage>().Navigation;

            if (hint is MvxPopToRootPresentationHint popToRootHint)
            {
                // Make sure all modals are closed
                CloseAllModals(popToRootHint.Animated);

                // Double check we have a navigation page, otherwise
                // we can just return as we must be already at the root page
                if (navigation == null)
                {
                    return;
                }

                // Close all pages back to the root
                await navigation.PopToRootAsync(popToRootHint.Animated);

                return;
            }
            if (hint is MvxPopPresentationHint popHint)
            {
                var matched = await PopModalToViewModel(navigation, popHint);

                if (matched)
                {
                    return;
                }


                await PopToViewModel(navigation, popHint.ViewModelToPopTo, popHint.Animated);

                return;
            }
            if (hint is MvxRemovePresentationHint removeHint)
            {
                foreach (var modal in navigation.ModalStack)
                {
                    var removed = RemoveByViewModel(modal.Navigation, removeHint.ViewModelToRemove);
                    if (removed)
                    {
                        return;
                    }
                }

                RemoveByViewModel(navigation, removeHint.ViewModelToRemove);
                return;
            }
            if (hint is MvxPagePresentationHint pageHint)
            {
                var pageType = ViewsContainer.GetViewType(pageHint.ViewModel);
                if (GetPageOfTypeByType(pageType) is Page page)
                {
                    if (page.Parent is TabbedPage tabbedPage)
                    {
                        tabbedPage.CurrentPage = page;
                    }
                    else if (page.Parent is CarouselPage carouselPage && page is ContentPage contentPage)
                    {
                        carouselPage.CurrentPage = contentPage;
                    }
                }
                return;
            }

            base.ChangePresentation(hint);

#if DEBUG // Only showing this when debugging MVX
            MvxTrace.Trace(FormsApplication.Hierarchy());
#endif
        }
Пример #5
0
        public async override Task <bool> ChangePresentation(MvxPresentationHint hint)
        {
#if DEBUG // Only wrap in try-finally when in debug
            try
            {
#endif
            var navigation = GetPageOfType <NavigationPage>()?.Navigation;
            if (hint is MvxPopToRootPresentationHint popToRootHint)
            {
                // Make sure all modals are closed
                await CloseAllModals(popToRootHint.Animated);

                // Double check we have a navigation page, otherwise
                // we can just return as we must be already at the root page
                if (navigation == null)
                {
                    return(true);
                }

                // Close all pages back to the root
                await navigation.PopToRootAsync(popToRootHint.Animated);

                return(true);
            }
            if (hint is MvxPopPresentationHint popHint)
            {
                var matched = await PopModalToViewModel(navigation, popHint);

                if (matched)
                {
                    return(true);
                }


                await PopToViewModel(navigation, popHint.ViewModelToPopTo, popHint.Animated);

                return(true);
            }
            if (hint is MvxRemovePresentationHint removeHint)
            {
                foreach (var modal in navigation.ModalStack)
                {
                    var removed = RemoveByViewModel(modal.Navigation, removeHint.ViewModelToRemove);
                    if (removed)
                    {
                        return(true);
                    }
                }

                RemoveByViewModel(navigation, removeHint.ViewModelToRemove);
                return(true);
            }
            if (hint is MvxPagePresentationHint pageHint)
            {
                var pageType = ViewsContainer.GetViewType(pageHint.ViewModel);
                if (GetPageOfTypeByType(pageType) is Page page)
                {
                    if (page.Parent is TabbedPage tabbedPage)
                    {
                        tabbedPage.CurrentPage = page;
                    }
                    else if (page.Parent is CarouselPage carouselPage && page is ContentPage contentPage)
                    {
                        carouselPage.CurrentPage = contentPage;
                    }
                }
                return(true);
            }
            if (hint is MvxPopRecursivePresentationHint popRecursiveHint)
            {
                var levels = popRecursiveHint.LevelsDeep;
                if (levels > navigation.NavigationStack.Count())
                {
                    levels = navigation.NavigationStack.Count();
                }
                for (int i = 0; i < levels; i++)
                {
                    await navigation.PopAsync(popRecursiveHint.Animated);
                }

                return(true);
            }

            return(true);

#if DEBUG // Only showing this when debugging MVX
        }

        finally
        {
            MvxFormsLog.Instance.Trace(FormsApplication.Hierarchy());
        }
#endif
        }