Ejemplo n.º 1
0
 public bool ChangePresentation(MvxPresentationHint hint)
 {
     Action action = () =>
                         {
                             MvxTrace.TaggedTrace("MacNavigation", "Change presentation requested");
                             this._presenter.ChangePresentation(hint);
                         };
     return this.RequestMainThreadAction(action);
 }
Ejemplo n.º 2
0
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            if (hint is MvxClosePresentationHint)
            {
                this.Close((hint as MvxClosePresentationHint).ViewModelToClose);
                return;
            }

            base.ChangePresentation(hint);
        }
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            if (HandlePresentationChange(hint))
            {
                return;
            }

            if (hint is MvxClosePresentationHint presentationHint)
            {
                Close(presentationHint.ViewModelToClose);
                return;
            }

            MvxLog.Instance.Warn("Hint ignored {0}", hint.GetType().Name);
        }
Ejemplo n.º 4
0
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            if (base.HandlePresentationChange(hint))
            {
                return;
            }

            if (hint is MvxClosePresentationHint)
            {
                this.Close((hint as MvxClosePresentationHint).ViewModelToClose);
                return;
            }

            MvxTrace.Warning("Hint ignored {0}", hint.GetType().Name);
        }
        public override async Task <bool> ChangePresentation(MvxPresentationHint hint)
        {
            if (await HandlePresentationChange(hint))
            {
                return(true);
            }

            if (hint is MvxClosePresentationHint)
            {
                return(await Close((hint as MvxClosePresentationHint).ViewModelToClose));
            }

            MvxLog.Instance.Warn("Hint ignored {0}", hint.GetType().Name);
            return(false);
        }
        public override Task <bool> ChangePresentation(MvxPresentationHint hint)
        {
            if (hint is MvxClosePresentationHint)
            {
                var viewModel = (hint as MvxClosePresentationHint).ViewModelToClose;

                Activity activity = this.CurrentActivity;

                IMvxView mvxView = activity as IMvxView;

                activity.Finish();
            }

            return(Task.FromResult(true));
        }
Ejemplo n.º 7
0
        public override async Task <bool> ChangePresentation(MvxPresentationHint hint)
        {
            if (await HandlePresentationChange(hint).ConfigureAwait(true))
            {
                return(true);
            }

            if (hint is MvxClosePresentationHint closeHint)
            {
                return(await Close(closeHint.ViewModelToClose).ConfigureAwait(true));
            }

            MvxLogHost.GetLog <MvxConsoleContainer>()?.Log(LogLevel.Trace, "Hint ignored {0}", hint.GetType().Name);
            return(false);
        }
Ejemplo n.º 8
0
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            // This will be null if hint isn't a close hint.
            var closeHint = hint as MvxClosePresentationHint;

            // Only navigate up the tree if the hint is an MvxClosePresentationHint
            // and there is a parent view in the navigation tree.
            if (closeHint != null &&
                this.navigationTree.Count > 1)
            {
                this.navigationTree.Pop();
                this.Present(this.navigationTree.Peek());
                base.ChangePresentation(hint);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Processes the reset root presentation.
        /// </summary>
        /// <param name="hint">The hint.</param>
        private void ProcessResetRootPresentation(MvxPresentationHint hint)
        {
            var popHint = hint as MvxPanelResetRootPresentationHint;

            if (popHint != null)
            {
                var panelHint = popHint;
                UINavigationController navController;
                switch (panelHint.Panel)
                {
                case MvxPanelEnum.Center:
                    navController = _multiPanelController.CenterPanel as UINavigationController;
                    if (navController != null)
                    {
                        navController.ViewControllers = new UIViewController[0];
                    }
                    else
                    {
                        _multiPanelController.CenterPanel = null;
                    }
                    break;

                case MvxPanelEnum.Left:
                    navController = _multiPanelController.LeftPanel as UINavigationController;
                    if (navController != null)
                    {
                        navController.ViewControllers = new UIViewController[0];
                    }
                    else
                    {
                        _multiPanelController.LeftPanel = null;
                    }
                    break;

                case MvxPanelEnum.Right:
                    navController = _multiPanelController.RightPanel as UINavigationController;
                    if (navController != null)
                    {
                        navController.ViewControllers = new UIViewController[0];
                    }
                    else
                    {
                        _multiPanelController.RightPanel = null;
                    }
                    break;
                }
            }
        }
        /// <summary>
        /// Processes the active panel presentation.
        /// </summary>
        /// <param name="hint">The hint.</param>
        private void ProcessActivePanelPresentation(MvxPresentationHint hint)
        {
            var activePresentationHint = hint as MvxActivePanelPresentationHint;

            if (activePresentationHint != null)
            {
                var panelHint = activePresentationHint;

                _activePanel = panelHint.ActivePanel;

                if (panelHint.ShowPanel)
                {
                    ShowPanel(panelHint.ActivePanel);
                }
            }
        }
Ejemplo n.º 11
0
        private void CheckLogout(MvxPresentationHint hint)
        {
            if (hint is LogOutPresentationHint)
            {
                var loginController = this.CreateViewControllerFor <LoginViewModel>() as UIViewController;

                if (loginController != null)
                {
                    MainViewPresenter = null;

                    MasterNavigationController = CreateNavigationController(loginController);

                    ChangeRootViewController(MasterNavigationController);
                }
            }
        }
Ejemplo n.º 12
0
        protected Task <bool> HandlePresentationChange(MvxPresentationHint hint)
        {
            if (hint == null)
            {
                throw new ArgumentNullException(nameof(hint));
            }

            if (_presentationHintHandlers.TryGetValue(
                    hint.GetType(),
                    out Func <MvxPresentationHint, Task <bool> > handler))
            {
                return(handler(hint));
            }

            return(Task.FromResult(false));
        }
Ejemplo n.º 13
0
        public virtual async void ChangePresentation(MvxPresentationHint hint)
        {
            if (hint is MvxClosePresentationHint)
            {
                var mainPage = MvxFormsApp.MainPage as NavigationPage;

                if (mainPage == null)
                {
                    Mvx.TaggedTrace("MvxFormsPresenter:ChangePresentation()", "Shit, son! Don't know what to do");
                }
                else
                {
                    // TODO - perhaps we should do more here... also async void is a boo boo
                    await mainPage.PopAsync();
                }
            }
        }
Ejemplo n.º 14
0
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            if (HandlePresentationChange(hint))
            {
                return;
            }

            var presentationHint = hint as MvxClosePresentationHint;

            if (presentationHint != null)
            {
                Close(presentationHint.ViewModelToClose);
                return;
            }

            MvxTrace.Warning("Hint ignored {0}", hint.GetType().Name);
        }
Ejemplo n.º 15
0
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            if (HandlePresentationChange(hint))
            {
                return;
            }


            if (_history.Count == 0)
            {
                base.ChangePresentation(hint);
                return;
            }

            (_contentControl as IDisposable)?.Dispose();
            _contentControl.Content = _history.Pop();
        }
Ejemplo n.º 16
0
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            if (hint is ClearBackStackHint)
            {
                //this approach navigates to another screen and then removes the back button
                if (this.MasterNavigationController != null)
                {
                    var controllers    = this.MasterNavigationController.ViewControllers;
                    var newcontrollers = new UIViewController[1];
                    newcontrollers[0] = controllers[controllers.Length - 1];

                    this.MasterNavigationController.ViewControllers = newcontrollers;
                }
            }

            base.ChangePresentation(hint);
        }
Ejemplo n.º 17
0
        public async void ChangePresentation(MvxPresentationHint hint)
        {
            //   if (HandlePresentationChange(hint)) return;

            if (hint is MvxClosePresentationHint)
            {
                var mainPage = _mvxFormsApp.MainPage as NavigationPage;

                if (mainPage == null)
                {
                    Mvx.TaggedTrace("MvxFormsPresenter:ChangePresentation()", "Application loading error");
                }
                else
                {
                    await mainPage.PopAsync();
                }
            }
        }
Ejemplo n.º 18
0
        public override async Task <bool> ChangePresentation(MvxPresentationHint hint)
        {
            if (hint is GoBackPresentationHint goBackPresentation)
            {
                if (goBackPresentation.BackPageCount.HasValue)
                {
                    await NavigationHelper.GoBack(goBackPresentation.BackPageCount.Value);
                }
                else
                {
                    await NavigationHelper.GoBack(goBackPresentation.ViewModelType);
                }

                return(true);
            }

            return(await base.ChangePresentation(hint));
        }
Ejemplo n.º 19
0
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            switch (hint)
            {
            case CardVisibilityHint cardHint:
                if (CurrentActivity is MainActivity mainActivity)
                {
                    mainActivity.OnTimeEntryCardVisibilityChanged(cardHint.Visible);
                }

                return;

            case ToggleCalendarVisibilityHint calendarHint:
                return;
            }

            base.ChangePresentation(hint);
        }
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            if (HandlePresentationChange(hint)) return;

            if (hint is MvxClosePresentationHint)
            {
                var mainPage = MvxFormsApp.MainPage as NavigationPage;

                if (mainPage == null)
                {
                    Mvx.TaggedTrace("MvxFormsPresenter:ChangePresentation()", "Oops! Don't know what to do");
                }
                else
                {
                    mainPage.PopAsync();
                }
            }
        }
        public override async void ChangePresentation(MvxPresentationHint hint)
        {
            try
            {
                if (HandlePresentationChange(hint))
                {
                    return;
                }

                if (MvxFormsApplication.Current.MainPage == null)
                {
                    return;
                }

                //ToDo figure this out, make Cancel awaitable :P
                // this will prevent closing multiple modal views quickly one after the other
                //if (_isBusyClosing)
                //   return;

                _isBusyClosing = true;

                // handle normal close
                if (hint is GoBackToHomePresentationHint)
                {
                    await HandleGoBackToHOmePresentationHint();
                }
                else if (hint is CloseModalPresentationHint)
                {
                    await HandleCloseModalPresentationHint((CloseModalPresentationHint)hint);
                }
                else if (hint is MvxClosePresentationHint)
                {
                    await HandleClosePesentationHint();
                }
            }
            catch (Exception ex)
            {
                Logger.Exception(nameof(ChangePresentation), ex);
            }
            finally
            {
                _isBusyClosing = false;
            }
        }
Ejemplo n.º 22
0
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            switch (hint)
            {
            case ReloadLogHint _:
            {
                var mainViewController =
                    MasterNavigationController
                    ?.ChildViewControllers
                    .FirstOrDefault(vc => vc is MainViewController) as MainViewController;

                mainViewController?.Reload();

                return;
            }

            case CardVisibilityHint cardHint:
            {
                if (MasterNavigationController?.TopViewController is MainViewController mainViewController)
                {
                    mainViewController.OnTimeEntryCardVisibilityChanged(cardHint.Visible);
                }
                return;
            }

            case ToggleCalendarVisibilityHint calendarHint:
                if (MasterNavigationController?.TopViewController is ReportsViewController reportsViewController)
                {
                    if (calendarHint.ForceHide || reportsViewController.CalendarIsVisible)
                    {
                        reportsViewController.HideCalendar();
                    }
                    else
                    {
                        reportsViewController.ShowCalendar();
                    }
                }
                return;
            }

            base.ChangePresentation(hint);
        }
 public virtual void ChangePresentation(MvxPresentationHint hint)
 {
     if (hint is MvxClosePresentationHint)
     {
         var finder  = Mvx.Resolve <IMvxControlFinder>();
         var control = finder.GetControl((hint as MvxClosePresentationHint).ViewModelToClose);
         if (control != null)
         {
             control.ViewModel = null;
         }
         else
         {
             _viewPresenter.ChangePresentation(hint);
         }
     }
     else
     {
         _viewPresenter.ChangePresentation(hint);
     }
 }
Ejemplo n.º 24
0
 public override void ChangePresentation(MvxPresentationHint hint)
 {
     if (hint is ClearBackstackHint)
     {
         var mainPage = _mvxFormsApp.MainPage as NavigationPage;
         if (mainPage != null && mainPage.CurrentPage != null)
         {
             var navigation = mainPage.CurrentPage.Navigation;
             for (var i = navigation.NavigationStack.Count - 1; i >= 0; i--)
             {
                 var page = navigation.NavigationStack[i];
                 if (page != mainPage.CurrentPage)
                 {
                     navigation.RemovePage(page);
                 }
             }
         }
     }
     base.ChangePresentation(hint);
 }
Ejemplo n.º 25
0
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            CheckCreateChat(hint);

            CheckDetail(hint);

            CheckLogout(hint);

            CheckLogin(hint);

            CheckGroup(hint);

            CheckEvent(hint);

            CheckChangeTab(hint);

            CheckLanguageChanged(hint);

            base.ChangePresentation(hint);
        }
Ejemplo n.º 26
0
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            var closeHint = hint as MvxClosePresentationHint;

            if (closeHint != null)
            {
                for (int i = _generalNavigationController.ViewControllers.Length - 1; i >= 1; i--)
                {
                    var vc        = _generalNavigationController.ViewControllers[i];
                    var touchView = vc as IMvxIosView;
                    if (touchView != null && touchView.ViewModel == closeHint.ViewModelToClose)
                    {
                        _generalNavigationController.PopToViewController(_generalNavigationController.ViewControllers[i - 1], true);
                        return;
                    }
                }

                //If it didnt trigger above it's because it was probably the root.
                _generalNavigationController.PopToRootViewController(true);
            }
        }
Ejemplo n.º 27
0
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            if (hint is MvxPanelPopToRootPresentationHint)
            {
                if (Window.ContentView.Subviews.Any())
                {
                    // there should be 1, and it should be the MainView
                    var mainView = Window.ContentView.Subviews[0];
                    if (mainView is MainView)
                    {
                        var mainViewController = mainView.NextResponder as MainViewController;
                        if (mainViewController != null)
                        {
                            mainViewController.PopToRoot();
                        }
                    }
                    return;
                }
            }

            base.ChangePresentation(hint);
        }
Ejemplo n.º 28
0
        public override Task <bool> ChangePresentation(MvxPresentationHint hint)
        {
            if (hint is MvxPagePresentationHint pagePresentationHint)
            {
                var request   = new MvxViewModelRequest(pagePresentationHint.ViewModel);
                var attribute = GetPresentationAttribute(request);
                if (attribute is MvxBottomNavigationViewPresentationAttribute bottomNavigationAttribute)
                {
                    MvxBottomNavigationView bottomNavigationView = FindMvxBottomNavigationViewInFragmentPresentation(bottomNavigationAttribute);
                    if (bottomNavigationView != null)
                    {
                        var menuItem = bottomNavigationView.FindItemByViewModel(pagePresentationHint.ViewModel);

                        if (menuItem == null)
                        {
                            //MvvmCross.MvxAndroidLog.Instance.Trace("Did not find a menu item which corresponds to {0}, skipping presentation change...",                                 pagePresentationHint.ViewModel);

                            return(Task.FromResult(false));
                        }

                        // If we are deeper in our back stack, we want to make sure that we remove the stack
                        if (CurrentFragmentManager.BackStackEntryCount > 0)
                        {
                            var name = CurrentFragmentManager.GetBackStackEntryAt(0).Name;
                            CurrentFragmentManager.PopBackStackImmediate(name, 1);
                        }

                        PerformShowFragmentTransaction(CurrentFragmentManager, bottomNavigationAttribute, new MvxViewModelRequest(pagePresentationHint.ViewModel));

                        var item = bottomNavigationView.FindItemByViewModel(pagePresentationHint.ViewModel);

                        item.SetChecked(true);

                        return(Task.FromResult(true));
                    }
                }
            }
            return(base.ChangePresentation(hint));
        }
Ejemplo n.º 29
0
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            switch (hint)
            {
            case ToggleReportsCalendarVisibilityHint calendarHint:

                if ((mainTabBarController.SelectedViewController as UINavigationController).TopViewController is ReportsViewController reportsViewController)
                {
                    if (calendarHint.ForceHide || reportsViewController.CalendarIsVisible)
                    {
                        reportsViewController.HideCalendar();
                    }
                    else
                    {
                        reportsViewController.ShowCalendar();
                    }
                }
                return;
            }

            base.ChangePresentation(hint);
        }
Ejemplo n.º 30
0
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            if (HandlePresentationChange(hint))
            {
                return;
            }

            if (hint is MvxClosePresentationHint closeHint)
            {
                FormsPagePresenter.Close(closeHint.ViewModelToClose);

                //var mainPage = FormsApplication.MainPage as NavigationPage;

                //if (mainPage == null)
                //{
                //    Mvx.TaggedTrace("MvxFormsPresenter:ChangePresentation()", "Oops! Don't know what to do");
                //}
                //else
                //{
                //    mainPage.PopAsync();
                //}
            }
        }
        /// <summary>
        /// Processes the reset root presentation.
        /// </summary>
        /// <param name="hint">The hint.</param>
        private void ProcessResetRootPresentation(MvxPresentationHint hint)
        {
            var popHint = hint as MvxPanelResetRootPresentationHint;

            if (popHint != null)
            {
                var panelHint = popHint;

                switch (panelHint.Panel)
                {
                case MvxPanelEnum.Center:
                    _multiPanelController.CenterPanel = null;
                    break;

                case MvxPanelEnum.Left:
                    _multiPanelController.LeftPanel = null;
                    break;

                case MvxPanelEnum.Right:
                    _multiPanelController.RightPanel = null;
                    break;
                }
            }
        }
Ejemplo n.º 32
0
 public override void ChangePresentation(MvxPresentationHint hint)
 {
     if (hint is MvxClosePresentationHint)
     {
         //ensure we have at least 2 items on the stack
         //this will be the base view that shows the sliding menu and another view
         //that was selected on the base sliding view
         //ensure we do not pop the base sliding view
         if (navigationStack.Count >= 2)
         {
             navigationStack.Pop();
             if (1 == navigationStack.Count)
             {
                 //we have navigated down to the last screen, this is a base
                 //view that shows the tab menu, show it
                 homeView.ContentGrid.Children.Clear();
                 homeView.ContentGrid.Children.Add(navigationStack.Peek());
                 mainWindow.Content = homeView;
             }
         }
         return;
     }
     base.ChangePresentation(hint);
 }
        /// <summary>
        /// Changes the presentation.
        /// </summary>
        /// <param name="hint">The hint.</param>
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            ProcessActivePanelPresentation(hint);
            ProcessResetRootPresentation(hint);
            ProcessPopToRootPresentation(hint);

            base.ChangePresentation(hint);
        }
        /// <summary>
        /// Processes the active panel presentation.
        /// </summary>
        /// <param name="hint">The hint.</param>
        private void ProcessActivePanelPresentation(MvxPresentationHint hint)
        {
            var activePresentationHint = hint as MvxActivePanelPresentationHint;
            if (activePresentationHint != null)
            {
                var panelHint = activePresentationHint;

                _activePanel = panelHint.ActivePanel;

                if (panelHint.ShowPanel)
                {
                    ShowPanel(panelHint.ActivePanel);
                }
            }
        }
        /// <summary>
        /// Processes the pop to root presentation.
        /// </summary>
        /// <param name="hint">The hint.</param>
        private void ProcessPopToRootPresentation(MvxPresentationHint hint)
        {
            var popHint = hint as MvxPanelPopToRootPresentationHint;
            if (popHint != null)
            {
                var panelHint = popHint;

                switch (panelHint.Panel)
                {
                    case MvxPanelEnum.Center:
                        if (CentrePanelUiNavigationController() != null)
                        {
                            CentrePanelUiNavigationController().PopToRootViewController(false);
                        }
                        break;

                    case MvxPanelEnum.Left:
                        if (LeftPanelUiNavigationController() != null)
                        {
                            LeftPanelUiNavigationController().PopToRootViewController(false);
                        }
                        break;

                    case MvxPanelEnum.Right:
                        if (RightPanelUiNavigationController() != null)
                        {
                            RightPanelUiNavigationController().PopToRootViewController(false);
                        }
                        break;
                }
            }
        }
        /// <summary>
        /// Processes the reset root presentation.
        /// </summary>
        /// <param name="hint">The hint.</param>
        private void ProcessResetRootPresentation(MvxPresentationHint hint)
        {
            var popHint = hint as MvxPanelResetRootPresentationHint;
            if (popHint != null)
            {
                var panelHint = popHint;
                UINavigationController navController;
                switch (panelHint.Panel)
                {
                    case MvxPanelEnum.Center:
                        navController = _multiPanelController.CenterPanel as UINavigationController;
                        if (navController != null)
                        {
                            navController.ViewControllers = new UIViewController[0];
                        }
                        else
                        {
                            _multiPanelController.CenterPanel = null;
                        }
                        break;

                    case MvxPanelEnum.Left:
                        navController = _multiPanelController.LeftPanel as UINavigationController;
                        if (navController != null)
                        {
                            navController.ViewControllers = new UIViewController[0];
                        }
                        else
                        {
                            _multiPanelController.LeftPanel = null;
                        }
                        break;

                    case MvxPanelEnum.Right:
                        navController = _multiPanelController.RightPanel as UINavigationController;
                        if (navController != null)
                        {
                            navController.ViewControllers = new UIViewController[0];
                        }
                        else
                        {
                            _multiPanelController.RightPanel = null;
                        }
                        break;
                }
            }
        }
Ejemplo n.º 37
0
        public override void ChangePresentation(MvxPresentationHint hint)
        {
            if (this.HandlePresentationChange(hint)) return;

            MvxTrace.Warning("Hint ignored {0}", hint.GetType().Name);
        }