コード例 #1
0
        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);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        protected virtual bool CloseTabViewController(IMvxViewModel viewModel, MvxTabPresentationAttribute attribute)
        {
            if (TabBarViewController != null && TabBarViewController.CloseTabViewModel(viewModel))
            {
                return(true);
            }

            return(false);
        }
コード例 #6
0
        protected virtual Task <bool> CloseTabViewController(IMvxViewModel viewModel,
                                                             MvxTabPresentationAttribute attribute)
        {
            if (TabBarViewController != null && TabBarViewController.CloseTabViewModel(viewModel))
            {
                return(Task.FromResult(true));
            }

            return(Task.FromResult(false));
        }
コード例 #7
0
 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);
 }
コード例 #8
0
        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);
        }
コード例 #9
0
        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));
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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();
        }
コード例 #12
0
 public override void ShowTabView(UIViewController viewController, MvxTabPresentationAttribute attribute)
 {
     base.ShowTabView(viewController, attribute);
 }
コード例 #13
0
        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);
        }
コード例 #14
0
        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);
            }
        }
コード例 #15
0
 protected override void SetTitleAndTabBarItem(UIViewController viewController, MvxTabPresentationAttribute attribute)
 {
     base.SetTitleAndTabBarItem(viewController, attribute);
     if (string.IsNullOrEmpty(Title))
     {
         Title = attribute.TabName;
     }
 }