Exemplo n.º 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);
        }
        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 virtual void ShowTabViewController(
            UIViewController viewController,
            bool needsNavigationController,
            string tabTitle,
            string tabIconName)
        {
            if (TabBarViewController == null)
            {
                throw new MvxException("You need a TabBarViewController to show a ViewModel as a Tab!");
            }

            if (string.IsNullOrEmpty(tabTitle) && string.IsNullOrEmpty(tabIconName))
            {
                throw new MvxException("You need to set at least an icon or a title when trying to show a ViewModel as a Tab!");
            }

            TabBarViewController.ShowTabView(viewController, needsNavigationController, tabTitle, tabIconName);
        }
Exemplo n.º 4
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);
        }