private void Tabs_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
                case NotifyCollectionChangedAction.Add:
                    var tab = e.NewItems[0] as TabBarTab;
                    tab.BadgeChanged += this.OnTabBadgeChanged;           // TODO: unsubscribe from the event for removed tabs
                    var stack = new StackNavigationFrame(this.styler);
                    this.navigationStacks.Add(stack);
                    if (tab.Icon != null)
                    {
                        stack.TabBarItem.Image = tab.Icon.GetUIImage();
                    }
                    stack.TabBarItem.Title = tab.Title;

                    this.AddChildViewController(stack);
                    stack.Navigate(tab.PageType, tab.NavigationParameter, NavigationType.Default);
                    if (this.currentTabIndex == -1)
                    {
                        this.currentTabIndex = 0;
                    }
                    break;
                case NotifyCollectionChangedAction.Remove:
                case NotifyCollectionChangedAction.Replace:
                    break;
                default:
                    throw new InvalidEnumArgumentException();
            }
            this.CurrentPage = this.navigationStacks[this.currentTabIndex].CurrentPage;
            this.visualRoot.Child = this.CurrentPage;
        }
Beispiel #2
0
        private void Tabs_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                var tab = e.NewItems[0] as TabBarTab;
                tab.BadgeChanged += this.OnTabBadgeChanged;               // TODO: unsubscribe from the event for removed tabs
                var stack = new StackNavigationFrame(this.styler);
                this.navigationStacks.Add(stack);
                if (tab.Icon != null)
                {
                    stack.TabBarItem.Image = tab.Icon.GetUIImage();
                }
                stack.TabBarItem.Title = tab.Title;

                this.AddChildViewController(stack);
                stack.Navigate(tab.PageType, tab.NavigationParameter, NavigationType.Default);
                if (this.currentTabIndex == -1)
                {
                    this.currentTabIndex = 0;
                }
                break;

            case NotifyCollectionChangedAction.Remove:
            case NotifyCollectionChangedAction.Replace:
                break;

            default:
                throw new InvalidEnumArgumentException();
            }
            this.CurrentPage      = this.navigationStacks[this.currentTabIndex].CurrentPage;
            this.visualRoot.Child = this.CurrentPage;
        }
        private void NativeShowPage(AppercodePage pageInstance, NavigationMode mode, NavigationType navigationType)
        {
            if (mode == NavigationMode.New || mode == NavigationMode.Forward)
            {
                if (navigationType == NavigationType.Modal)
                {
                    // the idea taken at https://github.com/HugeLawn-MiracleApps/Xamarin-Forms-Labs/commit/87a8d5a5c1b9628de222d1d509e46865d255db7b
                    var topViewController = UIApplication.SharedApplication.KeyWindow.RootViewController;
                    while (topViewController.PresentedViewController != null)
                    {
                        topViewController = topViewController.PresentedViewController;
                    }

                    var modalNavigationFrame = new StackNavigationFrame(this, pageInstance.ViewController);
                    topViewController.PresentViewController(modalNavigationFrame, true, null);
                }
                else
                {
                    this.PushViewController(pageInstance.ViewController, true);
                }
            }
            else if (mode == NavigationMode.Back)
            {
                if (navigationType == NavigationType.Modal)
                {
                    this.DismissViewController(true, null);
                }
                else
                {
                    this.isGoingBack = true;
                    this.PopToViewController(pageInstance.ViewController, true);
                }
            }
        }
 private StackNavigationFrame(StackNavigationFrame parent, UIViewController rootViewController)
     : base(rootViewController)
 {
     this.styler = parent.styler;
     this.Initialize();
 }
 private void NativeShowPage(AppercodePage pageInstance, NavigationMode mode, NavigationType navigationType)
 {
     if (mode == NavigationMode.New || mode == NavigationMode.Forward)
     {
         if (navigationType == NavigationType.Modal)
         {
             var modalNavigationFrame = new StackNavigationFrame(this, pageInstance.ViewController);
             this.PresentViewController(modalNavigationFrame, true, null);
         }
         else
         {
             this.PushViewController(pageInstance.ViewController, true);
         }
     }
     else if (mode == NavigationMode.Back)
     {
         if (navigationType == NavigationType.Modal)
         {
             this.DismissViewController(true, null);
         }
         else
         {
             this.isGoingBack = true;
             this.PopToViewController(pageInstance.ViewController, true);
         }
     }
 }
        private void NativeShowPage(AppercodePage pageInstance, NavigationMode mode, NavigationType navigationType)
        {
            if (mode == NavigationMode.New || mode == NavigationMode.Forward)
            {
                if (navigationType == NavigationType.Modal)
                {
                    // the idea taken at https://github.com/HugeLawn-MiracleApps/Xamarin-Forms-Labs/commit/87a8d5a5c1b9628de222d1d509e46865d255db7b
                    var topViewController = UIApplication.SharedApplication.KeyWindow.RootViewController;
                    while (topViewController.PresentedViewController != null)
                    {
                        topViewController = topViewController.PresentedViewController;
                    }

                    var modalNavigationFrame = new StackNavigationFrame(this, pageInstance.ViewController);
                    topViewController.PresentViewController(modalNavigationFrame, true, null);
                }
                else
                {
                    this.PushViewController(pageInstance.ViewController, true);
                }
            }
            else if (mode == NavigationMode.Back)
            {
                if (navigationType == NavigationType.Modal)
                {
                    this.DismissViewController(true, null);
                }
                else
                {
                    this.isGoingBack = true;
                    this.PopToViewController(pageInstance.ViewController, true);
                }
            }
        }
 private StackNavigationFrame(StackNavigationFrame parent, UIViewController rootViewController)
     : base(rootViewController)
 {
     this.styler = parent.styler;
     this.Initialize();
 }