/// <summary> /// Shows the specified view. /// </summary> /// <param name="view">The view.</param> /// <exception cref="MvxException"> /// Only one modal view controller at a time supported /// or /// Passed in IMvxTouchView is not a UIViewController /// </exception> public override void Show(IMvxIosView view) { // Handle modal first // This will use our TopLevel UINavigation Controller, to present over the top of the Panels UX if (view is IMvxModalIosView) { if (_currentModalViewController != null) { throw new MvxException("Only one modal view controller at a time supported"); } _currentModalViewController = view as UIViewController; PresentModalViewController(view as UIViewController, true); return; } // Then handle panels var viewController = view as UIViewController; if (viewController == null) { throw new MvxException("Passed in IMvxTouchView is not a UIViewController"); } if (MasterNavigationController == null) { ShowFirstView(viewController); } else { // here we need to get the Presentation Panel attribute details var panelAttribute = viewController.GetType().GetCustomAttributes(typeof (MvxPanelPresentationAttribute), true).FirstOrDefault() as MvxPanelPresentationAttribute; if (panelAttribute != null) { // this section of presentation code deals with showing master/detail views on // large screen devices (i.e. iPads) if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { if (panelAttribute.SplitViewBehaviour == MvxSplitViewBehaviour.Master) { var splitHost = new MvxSplitViewControllerHost(); _splitviewController = new MvxBaseSplitViewController(); _splitviewController.SetLeft(new UINavigationController((UIViewController)view)); splitHost.DisplayContentController(_splitviewController); viewController = splitHost; } else if (panelAttribute.SplitViewBehaviour == MvxSplitViewBehaviour.Detail && _splitviewController != null) { _splitviewController.SetRight(new UINavigationController((UIViewController)view)); // since we have now shown the view simply return return; } } switch (panelAttribute.HintType) { case MvxPanelHintType.ActivePanel: ChangePresentation(new MvxActivePanelPresentationHint(panelAttribute.Panel, panelAttribute.ShowPanel)); break; case MvxPanelHintType.PopToRoot: ChangePresentation(new MvxPanelPopToRootPresentationHint(panelAttribute.Panel)); break; case MvxPanelHintType.ResetRoot: ChangePresentation(new MvxPanelResetRootPresentationHint(panelAttribute.Panel)); break; } } if (GetActivePanelUiNavigationController == null) { // If we have cleared down our panel completely, then we will be setting a new root view // this is perfect for Menu items switch (_activePanel) { case MvxPanelEnum.Center: _multiPanelController.CenterPanel = new UINavigationController(viewController); break; case MvxPanelEnum.Left: _multiPanelController.LeftPanel = new UINavigationController(viewController); break; case MvxPanelEnum.Right: _multiPanelController.RightPanel = new UINavigationController(viewController); break; } } else { // Otherwise we just want to push to the designated panel GetActivePanelUiNavigationController.PushViewController(viewController, false); } } }
/// <summary> /// Shows the specified view. /// </summary> /// <param name="view">The view.</param> /// <exception cref="MvxException"> /// Only one modal view controller at a time supported /// or /// Passed in IMvxTouchView is not a UIViewController /// </exception> public override void Show(IMvxIosView view) { // Handle modal first // This will use our TopLevel UINavigation Controller, to present over the top of the Panels UX if (view is IMvxModalIosView) { if (_currentModalViewController != null) { throw new MvxException("Only one modal view controller at a time supported"); } _currentModalViewController = view as UIViewController; PresentModalViewController(view as UIViewController, true); return; } // Then handle panels var viewController = view as UIViewController; if (viewController == null) { throw new MvxException("Passed in IMvxTouchView is not a UIViewController"); } if (MasterNavigationController == null) { ShowFirstView(viewController); } else { // here we need to get the Presentation Panel attribute details var panelAttribute = viewController.GetType().GetCustomAttributes(typeof(MvxPanelPresentationAttribute), true).FirstOrDefault() as MvxPanelPresentationAttribute; if (panelAttribute != null) { // this section of presentation code deals with showing master/detail views on // large screen devices (i.e. iPads) if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { if (panelAttribute.SplitViewBehaviour == MvxSplitViewBehaviour.Master) { var splitHost = new MvxSplitViewControllerHost(); _splitviewController = new MvxBaseSplitViewController(); _splitviewController.SetLeft(new UINavigationController((UIViewController)view)); splitHost.DisplayContentController(_splitviewController); viewController = splitHost; } else if (panelAttribute.SplitViewBehaviour == MvxSplitViewBehaviour.Detail && _splitviewController != null) { _splitviewController.SetRight(new UINavigationController((UIViewController)view)); // since we have now shown the view simply return return; } } switch (panelAttribute.HintType) { case MvxPanelHintType.ActivePanel: ChangePresentation(new MvxActivePanelPresentationHint(panelAttribute.Panel, panelAttribute.ShowPanel)); break; case MvxPanelHintType.PopToRoot: ChangePresentation(new MvxPanelPopToRootPresentationHint(panelAttribute.Panel)); break; case MvxPanelHintType.ResetRoot: ChangePresentation(new MvxPanelResetRootPresentationHint(panelAttribute.Panel)); break; } } if (GetActivePanelUiNavigationController == null) { // If we have cleared down our panel completely, then we will be setting a new root view // this is perfect for Menu items switch (_activePanel) { case MvxPanelEnum.Center: _multiPanelController.CenterPanel = new UINavigationController(viewController); break; case MvxPanelEnum.Left: _multiPanelController.LeftPanel = new UINavigationController(viewController); break; case MvxPanelEnum.Right: _multiPanelController.RightPanel = new UINavigationController(viewController); break; } } else { // Otherwise we just want to push to the designated panel GetActivePanelUiNavigationController.PushViewController(viewController, false); } } }