コード例 #1
0
        private void UpdateCurrentPage()
        {
            var page   = this.Tabbed.CurrentPage;
            var itemId = this.Tabbed.Children.IndexOf(page);

            this.UpdateTabSelection(itemId, page, TabbedPageTransforms.GetDisableLoad(page));
        }
コード例 #2
0
        private void UpdateTabBarItems()
        {
            try
            {
                for (int i = 0; i < this.TabBar.Items.Length; i++)
                {
                    var page    = this.Tabbed.GetChildPageWithTransform(i);
                    var tabItem = this.TabBar.Items[i];
                    page.PropertyChanged += OnTabbedPagePropertyChanged;
                    if (TabbedPageTransforms.GetHideTitle(page))
                    {
                        this.hidepageIndex = i;
                        this.hidepageTitle = page.Title;
                        this.UpdateHideTitle(tabItem);
                    }

                    this.UpdateTabBadgeText(tabItem, page);
                    this.UpdateTabBadgeColor(tabItem, page);
                    this.UpdateTabBadgeTextAttributes(tabItem, page);

                    if (!string.IsNullOrEmpty(TabBadge.GetBadgeText(page)))
                    {
                        var view = this.GetTabItemView(tabItem.Title, true);
                        if (view != null)
                        {
                            this.UpdateBadgeView(page, view, (float)view.Frame.Width);
                        }
                    }
                }
            }
            catch
            {
            }
        }
コード例 #3
0
        private void UpdateCurrentPage()
        {
            tabCount = InitLayout();
            var page          = Element.CurrentPage;
            var selectedIndex = Element.Children.IndexOf(page);

            UpdateIconsAsync(selectedIndex);
            this.UpdateTabSelection(selectedIndex, page, TabbedPageTransforms.GetDisableLoad(page));
        }
コード例 #4
0
 protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnElementPropertyChanged(sender, e);
     if (e.PropertyName == "CurrentPage")
     {
         this.UpdateTabs();
     }
     else if (e.PropertyName == TabPage.IsSelectionChangedProperty.PropertyName && TabPage.IsSelectionChanged)
     {
         var currentPage = this.Element.CurrentPage;
         var itemId      = this.Element.Children.IndexOf(currentPage);
         this.UpdateTabSelection(itemId, currentPage, TabbedPageTransforms.GetDisableLoad(currentPage));
     }
 }
コード例 #5
0
        private void UpdateTab(int tabIndex)
        {
            var page            = Element.GetChildPageWithTransform(tabIndex);
            var menu            = (BottomNavigationMenuView)_bottomNavigationView.GetChildAt(0);
            var isTitledisabled = TabbedPageTransforms.GetHideTitle(page);
            var view            = menu.GetChildAt(tabIndex);

            if (view == null)
            {
                return;
            }
            if (view is BottomNavigationItemView itemView)
            {
                itemView.SetShifting(false);
                itemView.SetBackground(null);
                itemView.SetBackgroundColor(Android.Graphics.Color.Transparent);
                for (int j = 0; j < itemView.ChildCount; j++)
                {
                    UIView childView = itemView.GetChildAt(j);
                    if (childView is BaselineLayout baselineLayout)
                    {
                        if (isTitledisabled)
                        {
                            childView.Visibility = ViewStates.Gone;
                            childView.SetPadding(0, 0, 0, 0);
                        }

                        for (int z = 0; z < baselineLayout.ChildCount; z++)
                        {
                            var textview = baselineLayout.GetChildAt(z);
                            textview.SetPadding(0, 0, 0, 0);
                            if (isTitledisabled)
                            {
                                textview.Visibility = ViewStates.Gone;
                            }
                        }
                    }
                    else if (isTitledisabled && childView is ImageView icon)
                    {
                        FrameLayout.LayoutParams parames = (FrameLayout.LayoutParams)icon.LayoutParameters;
                        parames.Height = LayoutParams.MatchParent;
                        parames.Width  = LayoutParams.MatchParent;
                        itemView.SetChecked(false);
                        parames.SetMargins(0, 8, 0, 8);
                    }
                }
            }
        }
コード例 #6
0
        public new bool OnNavigationItemSelected(IMenuItem item)
        {
            if (Element == null)
            {
                return(false);
            }

            var id = item.ItemId;
            var tabnavigationresult = TabbedPageTransforms.TabIconClickedFunction(id, selectedTabId, this);

            if (tabnavigationresult)
            {
                return(false);
            }

            var page           = Element.GetChildPageWithTransform(id);
            var ispagedisabled = TabbedPageTransforms.GetDisableLoad(page);

            this.UpdateTabSelection(id, page, ispagedisabled);
            if (!ispagedisabled)
            {
                if (_bottomNavigationView != null)
                {
                    if (_bottomNavigationView.SelectedItemId != id && Element.Children.Count > id && id >= 0)
                    {
                        Element.CurrentPage = Element.Children[id];
                        UpdateIconsAsync(id);
                    }
                    else if (_bottomNavigationView.SelectedItemId == id)
                    {
                        UpdateIconsAsync(id);
                    }
                    else
                    {
                        UpdateIconsAsync(-1);
                    }
                }

                return(true);
            }

            return(false);
        }
コード例 #7
0
        private async void TabbedPageTransforms_TabIconClicked(object sender, Helper.TabsEventArgs e)
        {
            var selectedPage     = TabbedPageTransforms.GetChildPageWithTransform(this, e.SelectedIndex);
            var lastSelectedPage = TabbedPageTransforms.GetChildPageWithTransform(this, e.LastSelectedIndex);

            if (selectedPage != null)
            {
                if (selectedPage.Title == "Popup")
                {
                    await Navigation.PushModalAsync(new TransitionNavigationPage(true, new HalfPopUpPage()
                    {
                        Title = selectedPage.Title, BindingContext = this.BindingContext
                    }), true);
                }
                else if (selectedPage.Title == "PopupMenu")
                {
                    await Navigation.PushModalAsync(new TransitionNavigationPage(true, new FullPopUpPage(this.BottomBarHeight)
                    {
                        Title = selectedPage.Title, BindingContext = this.BindingContext
                    }), true);
                }
            }
        }
コード例 #8
0
        private void UpdateTabSelection(int itemId, Page currentpage, bool isPagedisabled)
        {
            if (TabbedPageTransforms.GetDisableSelection(currentpage))
            {
                return;
            }

            var lastPage           = Element.GetChildPageWithTransform(selectedTabId);
            var islastpagedisabled = lastPage == null ? false : TabbedPageTransforms.GetDisableLoad(lastPage);
            var selectedtabcolor   = this.Element.SelectedTabColor;
            var unselectedtabcolor = this.Element.UnselectedTabColor;

            if (_bottomNavigationView != null)
            {
                var currentTabView = GetBottomNavigationItemView(itemId);
                var lastTabView    = GetBottomNavigationItemView(selectedTabId);
                if (selectedTabId == itemId)
                {
                    if (TabbedPageTransforms.GetDisableLoad(currentpage))
                    {
                        var setColor   = selectedtabcolor;
                        var resetColor = unselectedtabcolor;

                        if (!isdisabledTabpressed)
                        {
                            isdisabledTabpressed = true;
                            setColor             = unselectedtabcolor;
                            resetColor           = selectedtabcolor;
                        }
                        else if (isdisabledTabpressed)
                        {
                            isdisabledTabpressed = false;
                        }

                        this.UpdateTabColor(currentpage, setColor, currentTabView);
                        if (lastactiveTabId >= 0)
                        {
                            var lastactivePage    = Element.GetChildPageWithTransform(lastactiveTabId);
                            var lastactiveTabView = GetBottomNavigationItemView(lastactiveTabId);
                            this.UpdateTabColor(lastactivePage, resetColor, lastactiveTabView);
                        }
                    }
                }
                else if (selectedTabId != itemId && Element.Children.Count > itemId && itemId >= 0)
                {
                    if (isdisabledTabpressed && lastactiveTabId >= 0)
                    {
                        var lastactivePage    = Element.GetChildPageWithTransform(lastactiveTabId);
                        var lastactiveTabView = GetBottomNavigationItemView(lastactiveTabId);
                        this.UpdateTabColor(lastactivePage, unselectedtabcolor, lastactiveTabView);
                    }

                    isdisabledTabpressed = false;
                    this.UpdateTabColor(currentpage, selectedtabcolor, currentTabView);
                    this.UpdateTabColor(lastPage, unselectedtabcolor, lastTabView);

                    if (isPagedisabled && !islastpagedisabled)
                    {
                        lastactiveTabId = selectedTabId;
                    }
                }
            }

            //For future purpose.
            //if (istitledisabled && islastpagedisabled)
            //{
            //    this.UpdateTabColor(lastPage, unselectedtabcolor, lastTabView);
            //    if (lastactiveTabId >= 0)
            //    {
            //        var lastactivePage = Element.GetChildPageWithTransform(lastactiveTabId);
            //        var lastactiveTabView = GetBottomNavigationItemView(lastactiveTabId);
            //        this.UpdateTabColor(lastactivePage, selectedtabcolor, lastactiveTabView);
            //    }
            //}
            selectedTabId = itemId;
            TabPage.IsSelectionChanged = false;
        }