protected virtual void ShowChildViewController( UIViewController viewController, MvxChildPresentationAttribute attribute, MvxViewModelRequest request) { if (viewController is IMvxSplitViewController) { throw new MvxException("A SplitViewController cannot be presented as a child. Consider using Root instead"); } if (ModalNavigationController != null) { ModalNavigationController.PushViewController(viewController, attribute.Animated); return; } if (TabBarViewController != null && TabBarViewController.ShowChildView(viewController)) { return; } if (MasterNavigationController != null) { MasterNavigationController.PushViewController(viewController, attribute.Animated); if (viewController is IMvxTabBarViewController) { TabBarViewController = viewController as IMvxTabBarViewController; } return; } throw new MvxException($"Trying to show View type: {viewController.GetType().Name} as child, but there is no current Root!"); }
public override void Show(MvxViewModelRequest request) { var viewModelLoader = Mvx.Resolve <IMvxViewModelLoader>(); var viewModel = viewModelLoader.LoadViewModel(request, null); if (request.ViewModelType == typeof(FormsViewModel)) { var page = new TestPage { BindingContext = viewModel }; var viewController = page.CreateViewController(); MasterNavigationController.PushViewController(viewController, true); return; } if (request.ViewModelType == typeof(FormsTabViewModel)) { var page = new TabPage() { BindingContext = viewModel }; var viewController = page.CreateViewController(); var attribute = new MvxTabPresentationAttribute() { TabName = page.Title }; TabBarViewController.ShowTabView(viewController, attribute); return; } base.Show(request); }
public override void Show(MvxViewModelRequest request) { if (request.PresentationValues != null) { var viewCreator = GetViewCreator(); // More info at: // - http://gregshackles.com/presenters-in-mvvmcross-using-presentation-values/ // - https://gist.github.com/gshackles/5735595 if (request.PresentationValues.ContainsKey(PresentationBundleFlagKeys.CLEAR_STACK)) { var nextViewController = (UIViewController)viewCreator.CreateView(request); if (MasterNavigationController.TopViewController.GetType() != nextViewController.GetType()) { MasterNavigationController.PopToRootViewController(false); MasterNavigationController.PushViewController(nextViewController, false); } return; } else if (request.PresentationValues.ContainsKey(PresentationBundleFlagKeys.MAKE_IT_THE_FIRST_ONE)) { MasterNavigationController.SetViewControllers(new UIViewController[] { }, false); } else if (request.PresentationValues.ContainsKey(PresentationBundleFlagKeys.BACK_OR_IN_PLACE)) { var nextViewController = (UIViewController)viewCreator.CreateView(request); var existingViewController = MasterNavigationController.ViewControllers.FirstOrDefault( vc => vc.GetType() == nextViewController.GetType() && vc != CurrentTopViewController); if (existingViewController != null) { MasterNavigationController.PopToViewController(existingViewController, true); } else { var transition = new CATransition { Duration = 0.3, Type = CAAnimation.TransitionPush, Subtype = CAAnimation.TransitionFade }; MasterNavigationController.PopViewController(false); MasterNavigationController.View.Layer.AddAnimation(transition, null); MasterNavigationController.PushViewController(nextViewController, false); } return; } } base.Show(request); }
/// <summary> /// Shows the first view. /// </summary> /// <param name="viewController">The view controller.</param> protected override void ShowFirstView(UIViewController viewController) { base.ShowFirstView(viewController); // So lets push our JaSidePanels viewController and then our first viewController in the centre panel to start things off // We will let our initial viewmodel load up the panels as required MasterNavigationController.NavigationBarHidden = true; MasterNavigationController.PushViewController(_multiPanelController, false); _multiPanelController.CenterPanel = new UINavigationController(viewController); }
protected override void ShowChildViewController(UIViewController viewController, MvxChildPresentationAttribute attribute, MvxViewModelRequest request) { if (request.ViewModelType == typeof(LoginViewModel)) { MasterNavigationController.View.Layer.AddAnimation(fadeAnimation, CALayer.Transition); MasterNavigationController.PushViewController(viewController, false); return; } base.ShowChildViewController(viewController, attribute, request); }
protected override void ShowChildViewController(UIViewController viewController, MvxChildPresentationAttribute attribute, MvxViewModelRequest request) { //Fix to show tabchild child view correctly if (MasterNavigationController != null) { MasterNavigationController.PushViewController(viewController, attribute.Animated); if (viewController is IMvxTabBarViewController) { TabBarViewController = viewController as IMvxTabBarViewController; } return; } //throw new MvxException($"Trying to show View type: {viewController.GetType().Name} as child, but there is no current stack!"); }
public virtual void Show(IMvxTouchView view) { var viewController = view as UIViewController; if (viewController == null) { throw new MvxException("Passed in IMvxTouchView is not a UIViewController"); } if (MasterNavigationController == null) { ShowFirstView(viewController); } else { MasterNavigationController.PushViewController(viewController, true /*animated*/); } }
public override void Show(Cirrious.MvvmCross.Touch.Views.IMvxTouchView view) { if (MasterNavigationController == null) { base.Show(view); return; } if (MasterNavigationController.ViewControllers.Length <= 1) { base.Show(view); return; } MasterNavigationController.PopViewController(false); MasterNavigationController.PushViewController( view as UIViewController, true); }
public override void Show(MvxViewModelRequest request) { if (request.PresentationValues != null) { if (request.PresentationValues.ContainsKey(PresentationBundleFlagKeys.ClearStack)) { foreach (var vc in MasterNavigationController.ViewControllers) { vc.DismissViewController(true, null); } var nextViewController = this.CreateViewControllerFor(request) as UIViewController; if (MasterNavigationController.TopViewController.GetType() != nextViewController.GetType()) { MasterNavigationController.PopToRootViewController(false); MasterNavigationController.PushViewController(nextViewController, false); } return; } if (request.PresentationValues.ContainsKey(PresentationBundleFlagKeys.NoAnimation)) { var nextViewController = this.CreateViewControllerFor(request) as UIViewController; MasterNavigationController.PushViewController(nextViewController, false); return; } if (request.PresentationValues.ContainsKey(PresentationBundleFlagKeys.TransitionLeftToRight)) { var nextViewController = this.CreateViewControllerFor(request) as UIViewController; MasterNavigationController.PushControllerWithTransition(nextViewController, UIViewAnimationOptions.TransitionCurlDown); return; } } base.Show(request); }
public override void Show(MvvmCross.Core.ViewModels.MvxViewModelRequest request) { if (request.PresentationValues != null) { #region ClearStack if (request.PresentationValues.ContainsKey(PresentationBundleFlagKeys.ClearStack)) { //MasterNavigationController.PopToRootViewController(false); var nextViewController = (UIViewController)ViewCreator.CreateView(request); MasterNavigationController.PushViewController(nextViewController, true); return; } #endregion #region ShowBack if (request.PresentationValues.ContainsKey(PresentationBundleFlagKeys.ShowBack)) { var nextViewController = (UIViewController)ViewCreator.CreateView(request); var currentViewController = MasterNavigationController.TopViewController; bool animated = false; while (!animated && currentViewController != null && currentViewController.GetType() != nextViewController.GetType()) { if (MasterNavigationController.ViewControllers.Length > 1) { var backViewController = MasterNavigationController.ViewControllers[MasterNavigationController.ViewControllers.Length - 2]; if (backViewController.GetType() == nextViewController.GetType()) { animated = true; } } else { break; } MasterNavigationController.PopViewController(animated); if (animated) { MemoryUtils.DelayReleaseObject(2000, currentViewController); } else { MemoryUtils.ReleaseObject(currentViewController); } currentViewController = MasterNavigationController.TopViewController; } if (MasterNavigationController.ViewControllers.Length <= 1) { MasterNavigationController.PushViewController(nextViewController, true); } return; } #endregion #region CloseCurrentAndShow if (request.PresentationValues.ContainsKey(PresentationBundleFlagKeys.CloseCurrentAndShow)) { // let make a async task to remove current from history to not make UI flash System.Threading.Tasks.Task.Run(async() => { await System.Threading.Tasks.Task.Delay(1000); if (closeViewController == null) { return; } MasterNavigationController.InvokeOnMainThread(async() => { //wait for until top view controller is showed while (closeViewController != MasterNavigationController.TopViewController) { await System.Threading.Tasks.Task.Delay(100); } int countVc = MasterNavigationController.ViewControllers.Length; if (countVc > 1) { UIViewController releaseViewController = MasterNavigationController.ViewControllers[countVc - 2]; UIViewController[] newHistory = new UIViewController[countVc - 1]; for (int i = 0; i < countVc - 2; i++) { newHistory[i] = MasterNavigationController.ViewControllers[i]; } newHistory[countVc - 2] = MasterNavigationController.ViewControllers[countVc - 1]; MasterNavigationController.ViewControllers = newHistory; MemoryUtils.ReleaseObject(releaseViewController); } closeViewController = null; }); }); } #endregion } base.Show(request); }