void SetTabColors() { for (int i = 0; i < Element.Children.Count; ++i) { Page page = Element.Children[i]; Color tabColor = BottomBarPageExtension.GetTabColor(page); if (tabColor != Color.Transparent) { _bottomBar.MapColorForTab(i, tabColor.ToAndroid()); } } }
/// <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 = BottomBarPageExtension.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 = BottomBarPageExtension.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(); } }