public virtual void SetAppearance(UITabBarController controller, ShellAppearance appearance) { IShellAppearanceElement appearanceElement = appearance; var backgroundColor = appearanceElement.EffectiveTabBarBackgroundColor; var foregroundColor = appearanceElement.EffectiveTabBarForegroundColor; // currently unused var disabledColor = appearanceElement.EffectiveTabBarDisabledColor; // unused on iOS var unselectedColor = appearanceElement.EffectiveTabBarUnselectedColor; var titleColor = appearanceElement.EffectiveTabBarTitleColor; var tabBar = controller.TabBar; if (_defaultTint == null) { _defaultBarTint = tabBar.BarTintColor; _defaultTint = tabBar.TintColor; _defaultUnselectedTint = tabBar.UnselectedItemTintColor; } if (!backgroundColor.IsDefault) { tabBar.BarTintColor = backgroundColor.ToUIColor(); } if (!titleColor.IsDefault) { tabBar.TintColor = titleColor.ToUIColor(); } if (!unselectedColor.IsDefault) { tabBar.UnselectedItemTintColor = unselectedColor.ToUIColor(); } }
public virtual void SetAppearance(BottomNavigationView bottomView, ShellAppearance appearance) { IShellAppearanceElement controller = appearance; var background = controller.EffectiveTabBarBackgroundColor; var foreground = controller.EffectiveTabBarForegroundColor; var disabled = controller.EffectiveTabBarDisabledColor; var unselected = controller.EffectiveTabBarUnselectedColor; var title = controller.EffectiveTabBarTitleColor; if (_defaultList == null) { #if __ANDROID_28__ _defaultList = bottomView.ItemTextColor ?? MakeColorStateList(title.ToAndroid().ToArgb(), disabled.ToAndroid().ToArgb(), unselected.ToAndroid().ToArgb()); #else _defaultList = bottomView.ItemTextColor; #endif } var colorStateList = MakeColorStateList(title, disabled, unselected); bottomView.ItemTextColor = colorStateList; bottomView.ItemIconTintList = colorStateList; colorStateList.Dispose(); SetBackgroundColor(bottomView, background); }
public void SetAppearance(UITabBarController controller, ShellAppearance appearance) { IShellAppearanceElement appearanceElement = appearance; var backgroundColor = appearanceElement.EffectiveTabBarBackgroundColor; var unselectedColor = appearanceElement.EffectiveTabBarUnselectedColor; var titleColor = appearanceElement.EffectiveTabBarTitleColor; var tabBar = controller.TabBar; bool operatingSystemHasUnselectedTint = UIDevice.CurrentDevice.CheckSystemVersion(10, 0); if (_defaultTint == null) { _defaultBarTint = tabBar.BarTintColor; _defaultTint = tabBar.TintColor; if (operatingSystemHasUnselectedTint) { _defaultUnselectedTint = tabBar.UnselectedItemTintColor; } } if (!backgroundColor.IsDefault) { tabBar.BarTintColor = backgroundColor.ToUIColor(); } if (!titleColor.IsDefault) { tabBar.TintColor = titleColor.ToUIColor(); } if (operatingSystemHasUnselectedTint && !unselectedColor.IsDefault) { tabBar.UnselectedItemTintColor = unselectedColor.ToUIColor(); } }
public virtual void SetAppearance(UITabBarController controller, ShellAppearance appearance) { IShellAppearanceElement appearanceElement = appearance; var backgroundColor = appearanceElement.EffectiveTabBarBackgroundColor; var foregroundColor = appearanceElement.EffectiveTabBarForegroundColor; // Currently unused var disabledColor = appearanceElement.EffectiveTabBarDisabledColor; // Unused on iOS var unselectedColor = appearanceElement.EffectiveTabBarUnselectedColor; var titleColor = appearanceElement.EffectiveTabBarTitleColor; var tabBar = controller.TabBar; bool operatingSystemSupportsUnselectedTint = Forms.IsiOS10OrNewer; if (_defaultTint == null) { _defaultBarTint = tabBar.BarTintColor; _defaultTint = tabBar.TintColor; if (operatingSystemSupportsUnselectedTint) { _defaultUnselectedTint = tabBar.UnselectedItemTintColor; } } if (Forms.IsiOS15OrNewer) { UpdateiOS15TabBarAppearance(controller, appearance); } else { UpdateTabBarAppearance(controller, appearance); } }
void UpdateTabBarAppearance(UITabBarController controller, ShellAppearance appearance) { IShellAppearanceElement appearanceElement = appearance; var backgroundColor = appearanceElement.EffectiveTabBarBackgroundColor; var unselectedColor = appearanceElement.EffectiveTabBarUnselectedColor; var titleColor = appearanceElement.EffectiveTabBarTitleColor; var tabBar = controller.TabBar; if (backgroundColor != null) { tabBar.BarTintColor = backgroundColor.ToUIColor(); } if (titleColor.IsDefault != null) { tabBar.TintColor = titleColor.ToUIColor(); } bool operatingSystemSupportsUnselectedTint = Forms.IsiOS10OrNewer; if (operatingSystemSupportsUnselectedTint) { if (unselectedColor.IsDefault != null) { tabBar.UnselectedItemTintColor = unselectedColor.ToUIColor(); } } }
public virtual void SetAppearance(UITabBarController controller, ShellAppearance appearance) { IShellAppearanceElement appearanceElement = appearance; var backgroundColor = appearanceElement.EffectiveTabBarBackgroundColor; var foregroundColor = appearanceElement.EffectiveTabBarForegroundColor; // Currently unused var disabledColor = appearanceElement.EffectiveTabBarDisabledColor; // Unused on iOS var unselectedColor = appearanceElement.EffectiveTabBarUnselectedColor; var titleColor = appearanceElement.EffectiveTabBarTitleColor; var tabBar = controller.TabBar; if (_defaultTint == null) { _defaultBarTint = tabBar.BarTintColor; _defaultTint = tabBar.TintColor; _defaultUnselectedTint = tabBar.UnselectedItemTintColor; } if (PlatformVersion.IsAtLeast(15)) { UpdateiOS15TabBarAppearance(controller, appearance); } else { UpdateTabBarAppearance(controller, appearance); } }
public virtual void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance) { IShellAppearanceElement controller = appearance; var backgroundColor = controller.EffectiveTabBarBackgroundColor; var foregroundColor = controller.EffectiveTabBarForegroundColor; // currently unused var disabledColor = controller.EffectiveTabBarDisabledColor; var unselectedColor = controller.EffectiveTabBarUnselectedColor; var titleColor = controller.EffectiveTabBarTitleColor; if (_defaultList == null) { #if __ANDROID_28__ _defaultList = bottomView.ItemTextColor ?? bottomView.ItemIconTintList ?? MakeColorStateList(titleColor.ToAndroid().ToArgb(), disabledColor.ToAndroid().ToArgb(), unselectedColor.ToAndroid().ToArgb()); #else _defaultList = bottomView.ItemTextColor ?? bottomView.ItemIconTintList; #endif } _colorStateList = MakeColorStateList(titleColor, disabledColor, unselectedColor); bottomView.ItemTextColor = _colorStateList; bottomView.ItemIconTintList = _colorStateList; SetBackgroundColor(bottomView, backgroundColor); }
//public void SetAppearance(BottomNavigationView bottomView, ShellAppearance appearance) //{ // // Hide title for bottom nav items // // https://montemagno.com/xamarin-forms-fully-customize-bottom-tabs-on-android-turn-off-shifting/ // bottomView.LabelVisibilityMode = LabelVisibilityMode.LabelVisibilityLabeled; // IMenu myMenu = bottomView.Menu; // IMenuItem myItemOne = myMenu.GetItem(0); // //if (myItemOne.IsChecked) // //{ // // myItemOne.SetIcon(Resource.Drawable.icon_home); // //} // //else // //{ // // myItemOne.SetIcon(Resource.Drawable.icon_home); // //} // //The same logic if you have myItemTwo, myItemThree.... //} public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance) { bottomView.LabelVisibilityMode = LabelVisibilityMode.LabelVisibilityLabeled; IMenu myMenu = bottomView.Menu; IMenuItem myItemOne = myMenu.GetItem(0); }
public virtual void SetAppearance(BottomNavigationView bottomView, ShellAppearance appearance) { IShellAppearanceElement controller = appearance; var backgroundColor = controller.EffectiveTabBarBackgroundColor; var foregroundColor = controller.EffectiveTabBarForegroundColor; // currently unused var disabledColor = controller.EffectiveTabBarDisabledColor; var unselectedColor = controller.EffectiveTabBarUnselectedColor; var titleColor = controller.EffectiveTabBarTitleColor; if (_defaultList == null) {
void UpdateiOS15TabBarAppearance(UITabBarController controller, ShellAppearance appearance) { IShellAppearanceElement appearanceElement = appearance; controller.TabBar .UpdateiOS15TabBarAppearance( ref _tabBarAppearance, null, null, appearanceElement.EffectiveTabBarForegroundColor, appearanceElement.EffectiveTabBarUnselectedColor, appearanceElement.EffectiveTabBarBackgroundColor, appearanceElement.EffectiveTabBarTitleColor); }
public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance) { IMenu myMenu = bottomView.Menu; for (int i = 0; i < myMenu.Size(); i++) { var item = myMenu.GetItem(i); SpannableString span = new SpannableString(item.ToString()); int end = span.Length(); //span.SetSpan(new AbsoluteSizeSpan(14, true), 0, end, SpanTypes.ExclusiveExclusive); span.SetSpan(new Rel ativeSizeSpan(0.8f), 0, end, SpanTypes.ExclusiveExclusive); item.SetTitle(span); } }
public void SetAppearance(UITabBarController controller, ShellAppearance appearance) { IShellAppearanceElement el = appearance; var backgroundColor = el.EffectiveTabBarBackgroundColor; var foregroundColor = el.EffectiveTabBarForegroundColor; var titleColor = el.EffectiveTabBarTitleColor; var disabledColor = el.EffectiveTabBarDisabledColor; var unselectedColor = el.EffectiveTabBarUnselectedColor; var tabBar = controller.TabBar; if (_blurView == null) { _defaultBackgroundImage = tabBar.BackgroundImage; _defaultTint = tabBar.TintColor; _defaultUnselectedTint = tabBar.UnselectedItemTintColor; var effect = UIBlurEffect.FromStyle(UIBlurEffectStyle.Regular); _blurView = new UIVisualEffectView(effect); _blurView.Frame = tabBar.Bounds; _colorView = new UIView(_blurView.Frame); } tabBar.BackgroundImage = new UIImage(); tabBar.InsertSubview(_colorView, 0); tabBar.InsertSubview(_blurView, 0); var button = new UIButton(UIButtonType.Custom); button.SetTitle("test", UIControlState.Normal); button.Frame = tabBar.Bounds; button.Center = tabBar.Center; tabBar.InsertSubview(button, 1); if (!backgroundColor.IsDefault) { _colorView.BackgroundColor = backgroundColor.ToUIColor(); } if (!foregroundColor.IsDefault) { tabBar.TintColor = foregroundColor.ToUIColor(); } if (!unselectedColor.IsDefault) { tabBar.UnselectedItemTintColor = unselectedColor.ToUIColor(); } }
public virtual void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance) { IShellAppearanceElement controller = appearance; var backgroundColor = controller.EffectiveTabBarBackgroundColor; var foregroundColor = controller.EffectiveTabBarForegroundColor; // currently unused var disabledColor = controller.EffectiveTabBarDisabledColor; var unselectedColor = controller.EffectiveTabBarUnselectedColor; var titleColor = controller.EffectiveTabBarTitleColor; _colorStateList = MakeColorStateList(titleColor, disabledColor, unselectedColor); bottomView.ItemTextColor = _colorStateList; bottomView.ItemIconTintList = _colorStateList; SetBackgroundColor(bottomView, backgroundColor); }
public override void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance) { base.SetAppearance(bottomView, appearance); var menu = bottomView.Menu; for (int i = 0; i < bottomView.Menu.Size(); i++) { var menuItem = menu.GetItem(i); var title = menuItem.TitleFormatted; Typeface typeface = Typeface.CreateFromAsset(MainActivity.Instance.Assets, "Chocolate Covered Raindrops.ttf"); var sb = new SpannableStringBuilder(title); sb.SetSpan(new CustomTypefaceSpan("", typeface), 0, sb.Length(), SpanTypes.InclusiveInclusive); menuItem.SetTitle(sb); } }
void UpdateTabBarAppearance(UITabBarController controller, ShellAppearance appearance) { IShellAppearanceElement appearanceElement = appearance; var backgroundColor = appearanceElement.EffectiveTabBarBackgroundColor; var unselectedColor = appearanceElement.EffectiveTabBarUnselectedColor; var titleColor = appearanceElement.EffectiveTabBarTitleColor; var tabBar = controller.TabBar; if (backgroundColor != null) { tabBar.BarTintColor = backgroundColor.ToPlatform(); } if (titleColor.IsDefault != null) { tabBar.TintColor = titleColor.ToPlatform(); } if (unselectedColor.IsDefault != null) { tabBar.UnselectedItemTintColor = unselectedColor.ToPlatform(); } }
public override void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance) { base.SetAppearance(bottomView, appearance); if (Build.VERSION.SdkInt < BuildVersionCodes.P) { return; } TypefaceSpan typefaceSpan = new TypefaceSpan(CustomShellRenderer.BottomTabTitleTypeface); for (int i = 0; i < bottomView.Menu.Size(); i++) { var menuItem = bottomView.Menu.GetItem(i); if (menuItem.TitleFormatted == null) { return; } SpannableStringBuilder spannableTitle = new SpannableStringBuilder(menuItem.TitleFormatted); spannableTitle.SetSpan(typefaceSpan, 0, spannableTitle.Length(), 0); menuItem.SetTitle(spannableTitle); } }
public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance) { _shellAppearance = appearance; IMenu menu = bottomView.Menu; for (int i = 0; i < menu.Size(); i++) { IMenuItem menuItem = menu.GetItem(i); var title = menuItem.TitleFormatted; Typeface typeface = Typeface.CreateFromAsset(_context.AndroidContext.Assets, "Ubuntu-Regular.ttf"); SpannableStringBuilder sb = new SpannableStringBuilder(title); sb.SetSpan(new CustomTypefaceSpan("", typeface), 0, sb.Length(), SpanTypes.InclusiveInclusive); //sb.SetSpan(new ForegroundColorSpan(_shellAppearance.EffectiveTabBarForegroundColor.ToAndroid()), 0, sb.Length(), SpanTypes.InclusiveInclusive); //sb.SetSpan(new ForegroundColorSpan(_shellAppearance.EffectiveTabBarForegroundColor.ToAndroid()), 0, sb.Length(), SpanTypes.InclusiveInclusive); menuItem.SetTitle(sb); //_context.AndroidContext } SetBottomViewColours(bottomView); }
public override void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance) { base.SetAppearance(bottomView, appearance); IMenu menu = bottomView.Menu; var items = new List <IMenuItem>(); int index = 0; do { try { items.Add(menu.GetItem(index++)); } catch { break; } } while (true); foreach (var item in items) { // TODO: Add gradient support } }
public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance) { //throw new System.NotImplementedException(); }
public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance) { bottomView.SetBackgroundColor(Android.Graphics.Color.White); bottomView.LabelVisibilityMode = LabelVisibilityMode.LabelVisibilityUnlabeled; }
public override void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance) { base.SetAppearance(bottomView, appearance); bottomView.LabelVisibilityMode = LabelVisibilityMode.LabelVisibilityUnlabeled; }
void UpdateiOS15TabBarAppearance(UITabBarController controller, ShellAppearance appearance) { IShellAppearanceElement appearanceElement = appearance; var tabBar = controller.TabBar; var tabBarAppearance = new UITabBarAppearance(); tabBarAppearance.ConfigureWithOpaqueBackground(); // Set TabBarBackgroundColor var tabBarBackgroundColor = appearanceElement.EffectiveTabBarBackgroundColor; if (tabBarBackgroundColor != null) { tabBarAppearance.BackgroundColor = tabBarBackgroundColor.ToPlatform(); } // Set TabBarTitleColor var tabBarTitleColor = appearanceElement.EffectiveTabBarTitleColor; // Update colors for all variations of the appearance to also make it work for iPads, etc. which use different layouts for the tabbar // Also, set ParagraphStyle explicitly. This seems to be an iOS bug. If we don't do this, tab titles will be truncat... if (tabBarTitleColor != null) { tabBarAppearance.StackedLayoutAppearance.Normal.TitleTextAttributes = tabBarAppearance.StackedLayoutAppearance.Selected.TitleTextAttributes = new UIStringAttributes { ForegroundColor = tabBarTitleColor.ToPlatform(), ParagraphStyle = NSParagraphStyle.Default }; tabBarAppearance.StackedLayoutAppearance.Normal.IconColor = tabBarAppearance.StackedLayoutAppearance.Selected.IconColor = tabBarTitleColor.ToPlatform(); tabBarAppearance.InlineLayoutAppearance.Normal.TitleTextAttributes = tabBarAppearance.InlineLayoutAppearance.Selected.TitleTextAttributes = new UIStringAttributes { ForegroundColor = tabBarTitleColor.ToPlatform(), ParagraphStyle = NSParagraphStyle.Default }; tabBarAppearance.InlineLayoutAppearance.Normal.IconColor = tabBarAppearance.InlineLayoutAppearance.Selected.IconColor = tabBarTitleColor.ToPlatform(); tabBarAppearance.CompactInlineLayoutAppearance.Normal.TitleTextAttributes = tabBarAppearance.CompactInlineLayoutAppearance.Selected.TitleTextAttributes = new UIStringAttributes { ForegroundColor = tabBarTitleColor.ToPlatform(), ParagraphStyle = NSParagraphStyle.Default }; tabBarAppearance.CompactInlineLayoutAppearance.Normal.IconColor = tabBarAppearance.CompactInlineLayoutAppearance.Selected.IconColor = tabBarTitleColor.ToPlatform(); } //Set TabBarUnselectedColor var tabBarUnselectedColor = appearanceElement.EffectiveTabBarUnselectedColor; if (tabBarUnselectedColor != null) { tabBarAppearance.StackedLayoutAppearance.Normal.TitleTextAttributes = new UIStringAttributes { ForegroundColor = tabBarUnselectedColor.ToPlatform(), ParagraphStyle = NSParagraphStyle.Default }; tabBarAppearance.StackedLayoutAppearance.Normal.IconColor = tabBarUnselectedColor.ToPlatform(); tabBarAppearance.InlineLayoutAppearance.Normal.TitleTextAttributes = new UIStringAttributes { ForegroundColor = tabBarUnselectedColor.ToPlatform(), ParagraphStyle = NSParagraphStyle.Default }; tabBarAppearance.InlineLayoutAppearance.Normal.IconColor = tabBarUnselectedColor.ToPlatform(); tabBarAppearance.CompactInlineLayoutAppearance.Normal.TitleTextAttributes = new UIStringAttributes { ForegroundColor = tabBarUnselectedColor.ToPlatform(), ParagraphStyle = NSParagraphStyle.Default }; tabBarAppearance.CompactInlineLayoutAppearance.Normal.IconColor = tabBarUnselectedColor.ToPlatform(); } // Set TabBarDisabledColor var tabBarDisabledColor = appearanceElement.EffectiveTabBarDisabledColor; if (tabBarDisabledColor != null) { tabBarAppearance.StackedLayoutAppearance.Disabled.TitleTextAttributes = new UIStringAttributes { ForegroundColor = tabBarDisabledColor.ToPlatform(), ParagraphStyle = NSParagraphStyle.Default }; tabBarAppearance.StackedLayoutAppearance.Disabled.IconColor = tabBarDisabledColor.ToPlatform(); tabBarAppearance.InlineLayoutAppearance.Disabled.TitleTextAttributes = new UIStringAttributes { ForegroundColor = tabBarDisabledColor.ToPlatform(), ParagraphStyle = NSParagraphStyle.Default }; tabBarAppearance.InlineLayoutAppearance.Disabled.IconColor = tabBarDisabledColor.ToPlatform(); tabBarAppearance.CompactInlineLayoutAppearance.Disabled.TitleTextAttributes = new UIStringAttributes { ForegroundColor = tabBarDisabledColor.ToPlatform(), ParagraphStyle = NSParagraphStyle.Default }; tabBarAppearance.CompactInlineLayoutAppearance.Disabled.IconColor = tabBarDisabledColor.ToPlatform(); } tabBar.StandardAppearance = tabBar.ScrollEdgeAppearance = tabBarAppearance; }