protected virtual void ShowTabViewController( UIViewController viewController, MvxTabPresentationAttribute attribute, MvxViewModelRequest request) { if (TabBarViewController == null) { throw new MvxException("Trying to show a tab without a TabBarViewController, this is not possible!"); } if (viewController is IMvxTabBarItemViewController tabBarItem) { attribute.TabName = tabBarItem.TabName; attribute.TabIconName = tabBarItem.TabIconName; attribute.TabSelectedIconName = tabBarItem.TabSelectedIconName; } if (attribute.WrapInNavigationController) { viewController = CreateNavigationController(viewController); } TabBarViewController.ShowTabView( viewController, attribute); }
public override void ShowTabView(UIViewController viewController, MvxTabPresentationAttribute attribute) { System.Type vcType; if (viewController is UINavigationController) { vcType = viewController.ChildViewControllers[0].GetType(); } else { vcType = viewController.GetType(); } var existingVc = ChildViewControllers.FirstOrDefault(x => { if (x is UINavigationController) { return(x.ChildViewControllers[0].GetType() == vcType); } else { return(x.GetType() == vcType); } }); if (existingVc != null && ChildViewControllers != null) { SelectedIndex = Array.IndexOf(ChildViewControllers, existingVc); } else { base.ShowTabView(viewController, attribute); } }
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); }
protected override void SetTitleAndTabBarItem(UIViewController viewController, MvxTabPresentationAttribute attribute) { if (string.IsNullOrEmpty(attribute.TabName)) { // attribute.TabName = "offers"; //if (string.IsNullOrEmpty(attribute.TabIconName)) // attribute.TabIconName = "offers"; base.SetTitleAndTabBarItem(viewController, attribute); } viewController.TabBarItem.SetTitleTextAttributes(new UITextAttributes { TextColor = CustomColor.JunctionXGray, Font = UIFont.FromName("sf_pro_text_regular", 11) }, UIControlState.Normal); viewController.TabBarItem.SetTitleTextAttributes(new UITextAttributes { TextColor = CustomColor.JunctionXBlue, Font = UIFont.FromName("sf_pro_text_regular", 11) }, UIControlState.Selected); viewController.TabBarItem.Title = ViewModel.LocalizedTextSource.GetText(attribute.TabName); viewController.TabBarItem.Image = UIImage.FromBundle(attribute.TabIconName).ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal); viewController.TabBarItem.SelectedImage = UIImage.FromBundle(attribute.TabIconName).ImageWithRenderingMode(UIImageRenderingMode.Automatic); }
protected virtual bool CloseTabViewController(IMvxViewModel viewModel, MvxTabPresentationAttribute attribute) { if (TabBarViewController != null && TabBarViewController.CloseTabViewModel(viewModel)) { return(true); } return(false); }
protected virtual Task <bool> CloseTabViewController(IMvxViewModel viewModel, MvxTabPresentationAttribute attribute) { if (TabBarViewController != null && TabBarViewController.CloseTabViewModel(viewModel)) { return(Task.FromResult(true)); } return(Task.FromResult(false)); }
protected override void SetTitleAndTabBarItem(UIViewController viewController, MvxTabPresentationAttribute attribute) { // you can override this method to set title or iconName if (string.IsNullOrEmpty(attribute.TabName)) { attribute.TabName = "Tab 2"; } if (string.IsNullOrEmpty(attribute.TabIconName)) { attribute.TabIconName = "ic_tabbar_menu"; } base.SetTitleAndTabBarItem(viewController, attribute); }
protected virtual void ShowTabViewController( NSViewController viewController, MvxTabPresentationAttribute attribute, MvxViewModelRequest request) { var window = Windows.FirstOrDefault(w => w.Identifier == attribute.WindowIdentifier) ?? Windows.Last(); var tabViewController = window.ContentViewController as IMvxTabViewController; if (tabViewController == null) { throw new MvxException($"trying to display a tab but there is no TabViewController! View type: {viewController.GetType()}"); } tabViewController.ShowTabView(viewController, attribute.TabTitle); }
protected virtual Task <bool> ShowTabViewController( NSViewController viewController, MvxTabPresentationAttribute attribute, MvxViewModelRequest request) { var window = FindPresentingWindow(attribute.WindowIdentifier, viewController); var tabViewController = window.ContentViewController as IMvxTabViewController; if (tabViewController == null) { throw new MvxException($"Trying to display a tab but there is no TabViewController to host it! View type: {viewController.GetType()}"); } tabViewController.ShowTabView(viewController, attribute.TabTitle); return(Task.FromResult(true)); }
protected virtual void ShowTabViewController( UIViewController viewController, MvxTabPresentationAttribute attribute, MvxViewModelRequest request) { if (TabBarViewController == null) { throw new MvxException("Trying to show a tab without a TabBarViewController, this is not possible!"); } if (attribute.WrapInNavigationController) { viewController = new MvxNavigationController(viewController); } TabBarViewController.ShowTabView( viewController, attribute.TabName, attribute.TabIconName, attribute.TabAccessibilityIdentifier); }
public virtual void ShowTabView(UIViewController viewController, MvxTabPresentationAttribute attribute) { if (!string.IsNullOrEmpty(attribute.TabAccessibilityIdentifier)) { viewController.View.AccessibilityIdentifier = attribute.TabAccessibilityIdentifier; } // setup Tab SetTitleAndTabBarItem(viewController, attribute); // add Tab var currentTabs = new List <UIViewController>(); if (ViewControllers != null) { currentTabs = ViewControllers.ToList(); } currentTabs.Add(viewController); // update current Tabs ViewControllers = currentTabs.ToArray(); }
public override void ShowTabView(UIViewController viewController, MvxTabPresentationAttribute attribute) { base.ShowTabView(viewController, attribute); }
protected override void SetTitleAndTabBarItem(UIViewController viewController, MvxTabPresentationAttribute attribute) { // you can override this method to set title or iconName if (string.IsNullOrEmpty(attribute.TabName)) { attribute.TabName = "Tab 2"; } //if (string.IsNullOrEmpty(attribute.TabIconName)) //attribute.TabIconName = "ic_tabbar_menu"; //this.TabBar.BarTintColor = UIColor.FromRGB(3,90,91); //this.TabBar.TintColor = UIColor.White; this.TabBar.BarTintColor = UIColor.FromRGB(3, 90, 91); this.TabBar.TintColor = UIColor.White; //this.TabBar.SelectedImageTintColor = UIColor.Red; //this.TabBar.UnselectedItemTintColor = UIColor.White; base.SetTitleAndTabBarItem(viewController, attribute); }
protected virtual void SetTitleAndTabBarItem(UIViewController viewController, MvxTabPresentationAttribute attribute) { _tabsCount++; viewController.Title = attribute.TabName; if (!string.IsNullOrEmpty(attribute.TabIconName)) { viewController.TabBarItem = new UITabBarItem(attribute.TabName, UIImage.FromBundle(attribute.TabIconName), _tabsCount); } if (!string.IsNullOrEmpty(attribute.TabSelectedIconName)) { viewController.TabBarItem.SelectedImage = UIImage.FromBundle(attribute.TabSelectedIconName); } }
protected override void SetTitleAndTabBarItem(UIViewController viewController, MvxTabPresentationAttribute attribute) { base.SetTitleAndTabBarItem(viewController, attribute); if (string.IsNullOrEmpty(Title)) { Title = attribute.TabName; } }