private int InitLayout() { switch (this.Element.OnThisPlatform().GetToolbarPlacement()) { case ToolbarPlacement.Default: case ToolbarPlacement.Bottom: _bottomTabStrip = ViewGroup.FindChildOfType <BottomNavigationView>()?.GetChildAt(0) as ViewGroup; _bottomNavigationView = ViewGroup.FindChildOfType <BottomNavigationView>(); if (_bottomNavigationView != null) { _bottomNavigationView.SetOnNavigationItemSelectedListener(this); _bottomNavigationView.ItemIconTintList = null; _bottomNavigationView.LabelVisibilityMode = LabelVisibilityMode.LabelVisibilityLabeled; } if (_bottomTabStrip == null) { Console.WriteLine("Plugin.Badge: No bottom tab layout found. Badge not added."); return(0); } return(_bottomTabStrip.ChildCount); default: throw new ArgumentOutOfRangeException(); } }
protected override void OnElementChanged(ElementChangedEventArgs <TabbedPage> e) { base.OnElementChanged(e); _tabLayout = ViewGroup.FindChildOfType <TabLayout>(); if (_tabLayout == null) { Console.WriteLine("No TabLayout found. Badge not added."); return; } _tabbedPage = e.NewElement as TabbedPage; _viewPager = (ViewPager)GetChildAt(0); _tabLayout.TabSelected += (s, a) => { var page = _tabbedPage.Children[a.Tab.Position]; SetTab(a.Tab, page.Icon.File); _viewPager.SetCurrentItem(a.Tab.Position, false); }; _tabStrip = _tabLayout.FindChildOfType <LinearLayout>(); for (var i = 0; i < _tabLayout.TabCount; i++) { AddTabBadge(i); } Element.ChildAdded += OnTabAdded; Element.ChildRemoved += OnTabRemoved; }
private int InitLayout() { switch (this.Element.OnThisPlatform().GetToolbarPlacement()) { case ToolbarPlacement.Default: case ToolbarPlacement.Top: _topTabLayout = ViewGroup.FindChildOfType <TabLayout>(); if (_topTabLayout == null) { Console.WriteLine("Plugin.Badge: No TabLayout found. Badge not added."); return(0); } _topTabStrip = _topTabLayout.FindChildOfType <LinearLayout>(); return(_topTabLayout.TabCount); case ToolbarPlacement.Bottom: _bottomTabStrip = ViewGroup.FindChildOfType <BottomNavigationView>()?.GetChildAt(0) as ViewGroup; if (_bottomTabStrip == null) { Console.WriteLine("Plugin.Badge: No bottom tab layout found. Badge not added."); return(0); } return(_bottomTabStrip.ChildCount); default: throw new ArgumentOutOfRangeException(); } }
protected override void OnElementChanged(ElementChangedEventArgs <TabbedPage> e) { base.OnElementChanged(e); // make sure we cleanup old event registrations Cleanup(e.OldElement); Cleanup(Element); _tabLayout = ViewGroup.FindChildOfType <TabLayout>(); if (_tabLayout == null) { Console.WriteLine("Plugin.Badge: No TabLayout found. Badge not added."); return; } _tabStrip = _tabLayout.FindChildOfType <LinearLayout>(); for (var i = 0; i < _tabLayout.TabCount; i++) { AddTabBadge(i); } Element.ChildAdded += OnTabAdded; Element.ChildRemoved += OnTabRemoved; }
protected override void OnElementChanged(ElementChangedEventArgs <TabbedPage> e) { base.OnElementChanged(e); // make sure we cleanup old event registrations Cleanup(e.OldElement); Cleanup(Element); switch (this.Element.OnThisPlatform().GetToolbarPlacement()) { case ToolbarPlacement.Default: case ToolbarPlacement.Top: _topTabLayout = ViewGroup.FindChildOfType <TabLayout>(); if (_topTabLayout == null) { Console.WriteLine("Plugin.Badge: No TabLayout found. Badge not added."); return; } _topTabStrip = _topTabLayout.FindChildOfType <LinearLayout>(); for (var i = 0; i < _topTabLayout.TabCount; i++) { AddTabBadge(i); } break; case ToolbarPlacement.Bottom: _bottomTabStrip = ViewGroup.FindChildOfType <BottomNavigationView>()?.GetChildAt(0) as ViewGroup; if (_bottomTabStrip == null) { Console.WriteLine("Plugin.Badge: No bottom tab layout found. Badge not added."); return; } for (var i = 0; i < _bottomTabStrip.ChildCount; i++) { AddTabBadge(i); } break; default: throw new ArgumentOutOfRangeException(); } Element.ChildAdded += OnTabAdded; Element.ChildRemoved += OnTabRemoved; }
protected override void OnElementChanged(ElementChangedEventArgs <TabbedPage> e) { base.OnElementChanged(e); tabLayout = ViewGroup.FindChildOfType <TabLayout>(); if (tabLayout == null) { return; } tabStrip = tabLayout.FindChildOfType <TabLayout.SlidingTabStrip>(); for (var i = 0; i < tabLayout.TabCount; i++) { AddTabBadge(i); } Element.ChildAdded += OnTabAdded; Element.ChildRemoved += OnTabRemoved; }
protected override void OnElementChanged(ElementChangedEventArgs <TabbedPage> e) { base.OnElementChanged(e); _tabLayout = ViewGroup.FindChildOfType <TabLayout>(); if (_tabLayout == null) { Console.WriteLine("Plugin.Badge: No TabLayout found. Bedge not added."); return; } _tabStrip = _tabLayout.FindChildOfType <TabLayout.SlidingTabStrip>(); for (var i = 0; i < _tabLayout.TabCount; i++) { AddTabBadge(i); } Element.ChildAdded += OnTabAdded; Element.ChildRemoved += OnTabRemoved; }