private static IMvxViewModel LoadViewModel(this IMvxTouchView touchView) { #warning NullViewModel needed? // how to do N //if (typeof (TViewModel) == typeof (MvxNullViewModel)) // return new MvxNullViewModel() as TViewModel; if (touchView.Request == null) { MvxTrace.Trace( "Request is null - assuming this is a TabBar type situation where ViewDidLoad is called during construction... patching the request now - but watch out for problems with virtual calls during construction"); touchView.Request = Mvx.Resolve <IMvxCurrentRequest>().CurrentRequest; } var instanceRequest = touchView.Request as MvxViewModelInstaceRequest; if (instanceRequest != null) { return(instanceRequest.ViewModelInstance); } var loader = Mvx.Resolve <IMvxViewModelLoader>(); var viewModel = loader.LoadViewModel(touchView.Request, null /* no saved state on iOS currently */); if (viewModel == null) { throw new MvxException("ViewModel not loaded for " + touchView.Request.ViewModelType); } return(viewModel); }
public static IMvxTouchView CreateViewControllerFor <TTargetViewModel>( this IMvxTouchView view, MvxShowViewModelRequest <TTargetViewModel> request) where TTargetViewModel : class, IMvxViewModel { return(MvxServiceProviderExtensions.GetService <IMvxTouchViewCreator>().CreateView(request)); }
protected override IMvxTouchView CreateViewOfType(Type viewType, MvxViewModelRequest request) { // If View is "SampleViewController", then Storyboard should be "SampleViewController.storyboard" // If we can't find storyboard, then proceed to load XIB.. // // NOTE: You must have this ctor defined for Storyboard: // // public YourViewController (IntPtr handle) : base (handle) // // As indicated here: http://developer.xamarin.com/guides/ios/user_interface/introduction_to_storyboards/ // IMvxTouchView viewController = null; if (NSBundle.MainBundle.PathForResource(viewType.Name, "storyboardc") != null) { // If storyboard exists for this view, load it. System.Console.WriteLine("Creating view from Storyboard {0}.storyboard", viewType.Name); var storyboard = UIStoryboard.FromName(viewType.Name, null); viewController = (IMvxTouchView)storyboard.InstantiateInitialViewController(); } else { System.Console.WriteLine("Storyboard {0}.storyboard does not exist: creating view of type instead", viewType.Name); viewController = (IMvxTouchView)base.CreateViewOfType(viewType, request); } if (viewController == null) { System.Console.WriteLine("Can't create view for type:" + viewType.Name); throw new Exception("Can't create view for type:" + viewType.Name); } return(viewController); }
public override void Show(IMvxTouchView view) { if (view is IMvxModalTouchView) { var controller = view as UIViewController; controller.ModalPresentationStyle = UIModalPresentationStyle.Custom; controller.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve; PresentModalViewController(controller, true); return; } // Check if the MainViewPresenter has been set (i.e. user has logged in) if (MainViewPresenter != null && view != MainViewPresenter) { //EnableSliders = true; // If presenter is set use show on the presenter to show views in the tabs MainViewPresenter.Show(view); return; } // If MainViewPresenter is not set use the default show base.Show(view); }
public override void Show(IMvxTouchView view) { if (view is IPresentationHost) { presentationHosts.Add((IPresentationHost)view); } var potentialHosts = from host in presentationHosts where host.ShouldPresentViewController(view) select host; if (potentialHosts.Count() > 0) { var host = potentialHosts.First(); Action dismissalAgent = null; host.PresentViewController(view, out dismissalAgent); if (dismissalAgent == null) { throw new NullReferenceException("IPresentationHost.PresentViewController must yield a dismissal agent if .ShouldPresentViewController yields true."); } removalAgentsByView [view] = dismissalAgent; } else { base.Show(view); } }
public static void OnViewCreate <TViewModel>(this IMvxTouchView <TViewModel> touchView) where TViewModel : class, IMvxViewModel { var view = touchView as IMvxView <TViewModel>; view.OnViewCreate(() => { return(touchView.LoadViewModel()); }); }
public static IMvxTouchView CreateViewControllerFor <TTargetViewModel>( this IMvxTouchView view, MvxViewModelRequest request) where TTargetViewModel : class, IMvxViewModel { return(Mvx.Resolve <IMvxTouchViewCreator>().CreateView(request)); }
private bool TryShowViewInCurrentTab(IMvxTouchView view) { var navigationController = (UINavigationController)this.SelectedViewController; navigationController.PushViewController((UIViewController)view, true); return(true); }
public void SetPrimaryView(IMvxTouchView view) { var controller = view as UIViewController; _primaryNav.PushViewController(controller, true); //this.ViewControllers = new UIViewController[] { controller, ViewControllers[1] }; }
public static UIViewController CreateViewControllerForTab(this IMvxTouchView view, Type viewModelType, string title, string imageName, string selectedImageName, string badgeValue) { var viewController = view.CreateViewControllerFor(viewModelType) as UIViewController; viewController.SetTitleAndTabBarItem(title, imageName, selectedImageName, badgeValue); return(viewController); }
public bool ShowView(IMvxTouchView view) { if (TryShowViewInCurrentTab(view)) { return(true); } return(false); }
public static IMvxTouchView CreateViewControllerFor <TTargetViewModel>(this IMvxTouchView view, object parameterObject) where TTargetViewModel : class, IMvxViewModel { return (view.CreateViewControllerFor <TTargetViewModel>(parameterObject == null ? null : parameterObject.ToSimplePropertyDictionary())); }
public MvxTouchUserInterfaceBuilder(IMvxTouchView activity, object dataSource, IBuilderRegistry builderRegistry, string bindTag = MvxAutoViewConstants.MvxBindTag, string platformName = TouchConstants.PlatformName) : base(builderRegistry, platformName) { _propertyBuilder = new PropertyBuilder(); var setter = new MvxBindingPropertySetter(activity, dataSource); _propertyBuilder.CustomPropertySetters[bindTag] = setter; }
public override void Show(IMvxTouchView view) { if (TabBarPresenter != null && view != TabBarPresenter) { TabBarPresenter.ShowView(view); return; } base.Show(view); }
private void CloseUpTo(IMvxTouchView viewController) { for (int i = _viewPresenters.Count - 1; i >= 0; i--) { if (_viewPresenters[i] != viewController) { CloseViewController(_viewPresenters[i]); } } }
private void Show(IMvxTouchView view) { if (view is HomeView) { _splitView.SetPrimaryView(view); } else { _splitView.SetSecondaryView(view); } }
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 static IMvxTouchView CreateViewControllerFor <TTargetViewModel>( this IMvxTouchView view, IDictionary <string, string> parameterValues = null) where TTargetViewModel : class, IMvxViewModel { parameterValues = parameterValues ?? new Dictionary <string, string>(); var request = new MvxShowViewModelRequest <TTargetViewModel>(parameterValues, false, MvxRequestedBy.UserAction); return(view.CreateViewControllerFor <TTargetViewModel>(request)); }
public static IMvxTouchView CreateViewControllerFor <TTargetViewModel>( this IMvxTouchView view, IDictionary <string, string> parameterValues = null) where TTargetViewModel : class, IMvxViewModel { var parameterBundle = new MvxBundle(parameterValues); var request = new MvxViewModelRequest <TTargetViewModel>(parameterBundle, null, MvxRequestedBy.UserAction); return(view.CreateViewControllerFor(request)); }
public override bool ShowView(IMvxTouchView view) { if (view is HomeView) { _splitView.SetPrimaryView(view); } else { _splitView.SetSecondaryView(view); } return true; }
private void Show(IMvxTouchView view) { throw new NotImplementedException(); /*if (view is HomeView) * { * _splitView.SetPrimaryView(view); * } * else * { * _splitView.SetSecondaryView(view); * }*/ }
public override void Show(IMvxTouchView view) { if (view is IMvxModalTouchView) { 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; } base.Show(view); }
public override void Show(IMvxTouchView view) { if (view is MainView) { this.AddSettingsButtonToNavBar(view); } else if (view is SettingsView) { var viewController = view as SettingsView; viewController.NavigationItem.HidesBackButton = true; } base.Show(view); }
public void SetSecondaryView(IMvxTouchView view) { var controller = view as UIViewController; if (view is ExtendParkingTimeView || view is ExtendParkingTimeConfirmView || view is BookingView || view is DelayedParkingMapView) { _secondaryNav.PushViewController(controller, true); } else { _secondaryNav.SetViewControllers(new UIViewController[] { controller }, true); } //this.ViewControllers = new UIViewController[] { ViewControllers[0], controller }; }
public override void Show(IMvxTouchView view) { var viewController = view as BaseViewController; if (viewController != null) { switch (viewController.TypeOfView) { case ViewType.MenuView: var masterView = Mvx.Resolve <IMvxTouchViewCreator>().CreateView(new MasterPanelViewModel()) as MasterPanelView; if (masterView != null) { masterView.MasterContainer = new MasterPanelContainer(150, 200); masterView.MasterContainer.ChangePanelContents(viewController, PanelType.MenuPanel); masterView.MasterContainer.ChangePanelContents(new EmptyView(UIColor.Green), PanelType.DetailPanel); this.Show(masterView); } break; case ViewType.SubMenuView: masterView = MasterNavigationController.TopViewController as MasterPanelView; if (masterView == null) { return; } masterView.MasterContainer.ChangePanelContents(viewController, PanelType.SubMenuPanel); masterView.MasterContainer.ShowSubMenu(); break; case ViewType.DetailView: masterView = MasterNavigationController.TopViewController as MasterPanelView; if (masterView == null) { return; } masterView.MasterContainer.ChangePanelContents(viewController, PanelType.DetailPanel); break; case ViewType.SingleView: base.Show(view); break; } } else { base.Show(view); } }
private void AddSettingsButtonToNavBar(IMvxTouchView view) { var viewController = view as MainView; EventHandler navigateToSettings = (sender, args) => { (viewController.ViewModel as MainViewModel).NavigateToSettingsCommand.Execute(null); }; var settingsButton = new UIBarButtonItem( UIImage.FromFile("settings.png"), UIBarButtonItemStyle.Plain, navigateToSettings); viewController.NavigationItem.SetRightBarButtonItem(settingsButton, true); }
public override void Show(IMvxTouchView view) { if (view is IMvxModalTouchView) { 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; } base.Show(view); }
private static TViewModel LoadViewModel <TViewModel>(this IMvxTouchView <TViewModel> touchView) where TViewModel : class, IMvxViewModel { if (typeof(TViewModel) == typeof(MvxNullViewModel)) { return(new MvxNullViewModel() as TViewModel); } var loader = touchView.GetService <IMvxViewModelLoader>(); var viewModel = loader.LoadViewModel(touchView.ShowRequest); if (viewModel == null) { throw new MvxException("ViewModel not loaded for " + touchView.ShowRequest.ViewModelType); } return((TViewModel)viewModel); }
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 void Show(IMvxTouchView view, bool animated) { 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, animated /*animated*/); } }
public override void Show(IMvxTouchView view) { if (view is IMvxModalTouchView) { if (_currentModalViewController != null) throw new MvxException("Only one modal view controller at a time supported"); var newNav = CreateModalNavigationController(); newNav.PushViewController(view as UIViewController, false); _currentModalViewController = view as UIViewController; PresentModalViewController(newNav, true); return; } base.Show(view); }
public override void Show(IMvxTouchView view) { var viewController = view as BaseViewController; if (viewController != null) { switch (viewController.TypeOfView) { case ViewType.MenuView: var masterView = Mvx.Resolve<IMvxTouchViewCreator>().CreateView(new MasterPanelViewModel()) as MasterPanelView; if (masterView != null) { masterView.MasterContainer = new MasterPanelContainer(150, 200); masterView.MasterContainer.ChangePanelContents(viewController, PanelType.MenuPanel); masterView.MasterContainer.ChangePanelContents(new EmptyView(UIColor.Green), PanelType.DetailPanel); this.Show(masterView); } break; case ViewType.SubMenuView: masterView = MasterNavigationController.TopViewController as MasterPanelView; if (masterView == null) return; masterView.MasterContainer.ChangePanelContents(viewController, PanelType.SubMenuPanel); masterView.MasterContainer.ShowSubMenu(); break; case ViewType.DetailView: masterView = MasterNavigationController.TopViewController as MasterPanelView; if (masterView == null) return; masterView.MasterContainer.ChangePanelContents(viewController, PanelType.DetailPanel); break; case ViewType.SingleView: base.Show(view); break; } } else base.Show(view); }
public override void Show(IMvxTouchView view) { if (view is IMvxModalTouchView) { if (_currentModalViewController != null) { throw new MvxException("Only one modal view controller at a time supported"); } var newNav = CreateModalNavigationController(); newNav.PushViewController(view as UIViewController, false); _currentModalViewController = view as UIViewController; PresentModalViewController(newNav, true); return; } base.Show(view); }
public override void Show(IMvxTouchView view) { if (view is SignInView || view is SignUpView) { if (_navigationController != null) { _window.RootViewController = _navigationController; } if (view is SignInView) { _navigationController.SetViewControllers(new UIViewController[] { view as UIViewController }, true); } else { _navigationController.PushViewController(view as UIViewController, true); } //TODO : maybe using MasterNavigationController to Push SignUpView into NavigationStack //or use base.Show(view) ??? return; } else { if (_splitView != null) { _window.RootViewController = _splitView; } if (view is BaseMenuView) { _splitView.SetPrimaryView(view); } else { _splitView.SetSecondaryView(view); } } }
// TODO: We have to make sure views are opened and closed through Presenter - if view is opened private bool PresentView(IMvxTouchView view) { IViewPresenter parentView = null; // iterate reverse order...most likely latest view added will be target for presenting for (int i = _viewPresenters.Count - 1; i >= 0; i--) { parentView = _viewPresenters[i] as IViewPresenter; if (parentView != null && parentView.CanPresentView(view)) { break; } parentView = null; } if (parentView != null) { parentView.PresentView(view); _presentedViews.Add(view); } return(parentView != null); }
private void CloseViewController(IMvxTouchView viewController) { if (viewController != null) { _viewPresenters.Remove(viewController); bool viewClosed = false; var viewPresenter = viewController as IViewPresenter; if (viewPresenter != null) { viewPresenter.ViewPresenterRemoved(); } if (_loginViewController != null && _loginViewController == viewController) { base.Close(_loginViewController.ViewModel); _loginViewController = null; } else if (_mainViewController != null && _mainViewController == viewController) { base.Close(_mainViewController.ViewModel); _mainViewController = null; } else if (_presentedViews.Contains(viewController)) { // This view is already presented - we don't handle the close for this. They should // have removed themselves on ViewPresenterRemoved _presentedViews.Remove(viewController); } else { // Close another view that was not presented, was not login, or not main view controller base.Close(viewController.ViewModel); } } }
public void PresentView(IMvxTouchView view) { }
public void SetPrimaryView(IMvxTouchView view) { var controller = view as UIViewController; this.ViewControllers = new UIViewController[] { controller, ViewControllers[1] }; }
private bool TryShowViewInCurrentTab(IMvxTouchView view) { var navigationController = (UINavigationController)this.SelectedViewController; navigationController.PushViewController((UIViewController)view, true); return true; }
public bool CanPresentView(IMvxTouchView view) { return false; //return (view.Request.RequestedBy.AdditionalInfo == ViewModel.ViewInstanceId.ToString()) ; }
public bool CanShow(IMvxTouchView view) { return _viewModelTypes.ContainsKey(view.ShowRequest.ViewModelType); }
// TODO: We have to make sure views are opened and closed through Presenter - if view is opened private bool PresentView(IMvxTouchView view) { IViewPresenter parentView = null; // iterate reverse order...most likely latest view added will be target for presenting for (int i = _viewPresenters.Count - 1; i >= 0; i--) { parentView = _viewPresenters[i] as IViewPresenter; if (parentView != null && parentView.CanPresentView(view)) { break; } parentView = null; } if (parentView != null) { parentView.PresentView(view); _presentedViews.Add(view); } return parentView != null; }
public void ShowGrandChild(IMvxTouchView view) { var currentNav = SelectedViewController as UINavigationController; currentNav.PushViewController(view as UIViewController, true); }
public void SetSecondaryView(IMvxTouchView view) { var controller = view as UIViewController; this.ViewControllers = new UIViewController[] { ViewControllers[0], controller }; }
public void PresentView(IMvxTouchView view) { // Don't load any views through Presenter }
public virtual bool ShowView(IMvxTouchView view) { return false; }
public MvxBindingPropertySetter(IMvxTouchView touchView, object source) { _touchView = touchView; _source = source; }
public bool ShowView(IMvxTouchView view) { if (TryShowViewInCurrentTab(view)) return true; return false; }
public override void Show(IMvxTouchView view) { Trc.Mn("IMvxTouchView"); // Handle modal first // This will use our TopLevel UINavigation Controller, to present over the top of the Panels UX if (view is IMvxModalTouchView) { 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 UIViewController viewController = view as UIViewController; if (viewController == null) throw new MvxException("Passed in IMvxTouchView is not a UIViewController"); if (MasterNavigationController == null) { ShowFirstView(viewController); } else { 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 PanelEnum.Center: _jaSidePanelController.CenterPanel = new UINavigationController(viewController); break; case PanelEnum.Left: _jaSidePanelController.LeftPanel = new UINavigationController(viewController); break; case PanelEnum.Right: _jaSidePanelController.RightPanel = new UINavigationController(viewController); break; } } else { // Otherwise we just want to push to the designated panel GetActivePanelUiNavigationController.PushViewController(viewController, true); } } }
public bool CanPresentView(IMvxTouchView view) { // We don't load any views! return false; }