void SetTabItems() { BottomBarTab[] tabs = Element.Children.Select(page => { var tabIconId = ResourceManagerEx.IdFromTitle(page.Icon, ResourceManager.DrawableClass); return(new BottomBarTab(tabIconId, null)); }).ToArray(); _bottomBar.SetItems(tabs); _bottomBar.MakeBadgeForTabAt(3, Element.BarTextColor.ToAndroid(), 1); }
/// <summary> /// Creates or updates a badge for a page /// </summary> /// <param name="page"></param> void CreateOrUpdateBadgeForPage(Page page) { var pageIndex = Element.Children.IndexOf(page); var badgeCount = BottomBarPageExtensions.GetBadgeCount(page); BottomBarBadge badge; // We'll have to keep track of our badges, otherwise we can't update // and removing + inserting again gives a crappy user experience if (_badges.ContainsKey(page)) { badge = _badges[page]; } else { // Don't need to create a badge when there's no badge to show if (badgeCount == 0) { return; } // BottomBarBadge does not allow us to set color after init. You could, but you'd have to // do it manually because the circle background logic is hidden from us var badgeColor = BottomBarPageExtensions.GetBadgeColor(page); badge = _bottomBar.MakeBadgeForTabAt(pageIndex, badgeColor.ToAndroid(), badgeCount); _badges.Add(page, badge); } // Let's assume that if the new badge count is zero the // default behavior will be to hide the badge if (badgeCount == 0) { badge.Hide(); } else { badge.Count = badgeCount; badge.Show(); } }