void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance) { if (appearance == null) { _appearanceTracker.ResetAppearance(this); } else { _appearanceTracker.SetAppearance(this, appearance); } }
public void ColorSetCorrectly() { var testShell = new TestShell(CreateShellItem <FlyoutItem>()); testShell.Items[0].SetValue(Shell.DisabledColorProperty, Colors.Purple); ShellAppearance result = new ShellAppearance(); result.Ingest(testShell.Items[0]); Assert.AreEqual(Colors.Purple, result.DisabledColor); }
void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance) { if (appearance == null) { ResetAppearance(); } else { SetAppearance(appearance); } }
void UpdateStatusBarColor(ShellAppearance appearance) { Profile.FrameBegin("UpdtStatBarClr"); var activity = AndroidContext.GetActivity(); var window = activity?.Window; var decorView = window?.DecorView; var resources = AndroidContext.Resources; int statusBarHeight = 0; int resourceId = resources.GetIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { statusBarHeight = resources.GetDimensionPixelSize(resourceId); } int navigationBarHeight = 0; resourceId = resources.GetIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { navigationBarHeight = resources.GetDimensionPixelSize(resourceId); } // TODO Previewer Hack if (decorView != null) { // we are using the split drawable here to avoid GPU overdraw. // All it really is is a drawable that only draws under the statusbar/bottom bar to make sure // we dont draw over areas we dont need to. This has very limited benefits considering its // only saving us a flat color fill BUT it helps people not freak out about overdraw. AColor color; if (appearance != null) { color = appearance.BackgroundColor.ToPlatform(Color.FromArgb("#03A9F4")); } else { color = Color.FromArgb("#03A9F4").ToPlatform(); } if (!(decorView.Background is SplitDrawable splitDrawable) || splitDrawable.Color != color || splitDrawable.TopSize != statusBarHeight || splitDrawable.BottomSize != navigationBarHeight) { Profile.FramePartition("Create SplitDrawable"); var split = new SplitDrawable(color, statusBarHeight, navigationBarHeight); Profile.FramePartition("SetBackground"); decorView.SetBackground(split); } } Profile.FrameEnd("UpdtStatBarClr"); }
void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance) { if (appearance == null) { UpdateScrim(Brush.Transparent); } else { UpdateScrim(appearance.FlyoutBackdrop); } }
protected virtual void SetAppearance(ShellAppearance appearance) { if (_bottomView == null || _bottomView.Visibility == ViewStates.Gone || DisplayedPage == null) { return; } _appearanceSet = true; _appearanceTracker.SetAppearance(_bottomView, appearance); }
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 IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance) { _shellAppearance = appearance; if (appearance != null) { SetAppearance(appearance); } else { ResetAppearance(); } }
void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance) { if (appearance == null) { _backdropColor = Color.Default; } else { _backdropColor = appearance.FlyoutBackdropColor; } UpdateTapoffViewBackgroundColor(); }
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(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 void SetAppearance(BottomNavigationView bottomView, ShellAppearance appearance) { IMenu myMenu = bottomView.Menu; bottomView.ItemIconTintList = null; for (int i = 0; i < bottomView.Menu.Size(); i++) { IMenuItem myItemOne = myMenu.GetItem(i); if (!string.IsNullOrWhiteSpace(myItemOne.ToString())) { SetTabItemTitleColorAndIcon(myItemOne); } } }
void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance) { if (_navBar == null) { return; } var titleColor = (appearance as IShellAppearanceElement)?.EffectiveTabBarTitleColor ?? Xamarin.Forms.Color.Default; var backgroundColor = appearance?.BackgroundColor ?? Xamarin.Forms.Color.Default; var foregroundColor = appearance?.ForegroundColor ?? Xamarin.Forms.Color.Default; _navBar.TitleColor = titleColor.IsDefault ? ShellRenderer.DefaultTitleColor.ToNative() : titleColor.ToNative(); _navBar.BackgroundColor = backgroundColor.IsDefault ? ShellRenderer.DefaultBackgroundColor.ToNative() : backgroundColor.ToNative(); _navBar.ForegroundColor = foregroundColor.IsDefault ? ShellRenderer.DefaultForegroundColor.ToNative() : foregroundColor.ToNative(); }
void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance) { if (_navBar == null) { return; } var titleColor = (appearance as IShellAppearanceElement)?.EffectiveTabBarTitleColor; var backgroundColor = appearance?.BackgroundColor; var foregroundColor = appearance?.ForegroundColor; _navBar.TitleColor = titleColor.IsDefault() ? TThemeConstants.Shell.ColorClass.DefaultTitleColor : (titleColor?.ToPlatformEFL()).GetValueOrDefault(); _navBar.BackgroundColor = backgroundColor.IsDefault() ? TThemeConstants.Shell.ColorClass.DefaultBackgroundColor : (backgroundColor?.ToPlatformEFL()).GetValueOrDefault(); _navBar.ForegroundColor = foregroundColor.IsDefault() ? TThemeConstants.Shell.ColorClass.DefaultForegroundColor : (foregroundColor?.ToPlatformEFL()).GetValueOrDefault(); }
void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance) { if (_navBar == null) { return; } var titleColor = (appearance as IShellAppearanceElement)?.EffectiveTabBarTitleColor ?? Microsoft.Maui.Controls.Compatibility.Color.Default; var backgroundColor = appearance?.BackgroundColor ?? Microsoft.Maui.Controls.Compatibility.Color.Default; var foregroundColor = appearance?.ForegroundColor ?? Microsoft.Maui.Controls.Compatibility.Color.Default; _navBar.TitleColor = titleColor.IsDefault ? ShellRenderer.DefaultTitleColor.ToPlatform() : titleColor.ToPlatform(); _navBar.BackgroundColor = backgroundColor.IsDefault ? ShellRenderer.DefaultBackgroundColor.ToPlatform() : backgroundColor.ToPlatform(); _navBar.ForegroundColor = foregroundColor.IsDefault ? ShellRenderer.DefaultForegroundColor.ToPlatform() : foregroundColor.ToPlatform(); }
void UpdateAppearance(ShellAppearance appearance) { var tabBarBackgroundColor = ShellView.DefaultBackgroundColor; var tabBarForegroundColor = ShellView.DefaultForegroundColor; var titleColor = ShellView.DefaultTitleColor; if (appearance != null) { var a = (IShellAppearanceElement)appearance; if (a.EffectiveTabBarBackgroundColor != null) { tabBarBackgroundColor = a.EffectiveTabBarBackgroundColor.ToWindowsColor(); } if (a.EffectiveTabBarForegroundColor != null) { tabBarForegroundColor = a.EffectiveTabBarForegroundColor.ToWindowsColor(); } if (!appearance.TitleColor.IsDefault()) { titleColor = appearance.TitleColor.ToWindowsColor(); } } _HeaderArea.Background = new UwpSolidColorBrush(tabBarBackgroundColor); // Only color the bottom area if there are tabs present if (ShellItem?.Items.Count > 1) { _BottomBarArea.Background = new UwpSolidColorBrush(tabBarBackgroundColor); } _Title.Foreground = new UwpSolidColorBrush(titleColor); var tabbarForeground = new UwpSolidColorBrush(tabBarForegroundColor); foreach (var button in _BottomBar.Children.OfType <AppBarButton>()) { button.Foreground = tabbarForeground; } if (SectionView is IAppearanceObserver iao) { iao.OnAppearanceChanged(appearance); } }
void UpdateAppearance(ShellAppearance appearance) { var tabBarBackgroundColor = ShellRenderer.DefaultBackgroundColor; var tabBarForegroundColor = ShellRenderer.DefaultForegroundColor; if (appearance != null) { var a = (IShellAppearanceElement)appearance; tabBarBackgroundColor = a.EffectiveTabBarBackgroundColor.ToWindowsColor(); tabBarForegroundColor = a.EffectiveTabBarForegroundColor.ToWindowsColor(); } UpdateBrushColor("NavigationViewTopPaneBackground", tabBarBackgroundColor); UpdateBrushColor("TopNavigationViewItemForeground", tabBarForegroundColor); UpdateBrushColor("TopNavigationViewItemForegroundSelected", tabBarForegroundColor); UpdateBrushColor("NavigationViewSelectionIndicatorForeground", tabBarForegroundColor); }
public void SetAppearance(BottomNavigationView bottomView, ShellAppearance appearance) { IMenu myMenu = bottomView.Menu; IMenuItem myItemOne = myMenu.GetItem(0); if (myItemOne.IsChecked) { myItemOne.SetIcon(Resource.Drawable.tab_about); } else { myItemOne.SetIcon(Resource.Drawable.tab_feed); } //The same logic if you have myItemTwo, myItemThree.... }
public void SetAppearance(BottomNavigationView bottomView, ShellAppearance appearance) { IMenu menu = bottomView.Menu; for (int i = 0; i < bottomView.Menu.Size(); i++) { IMenuItem menuItem = menu.GetItem(i); var title = menuItem.TitleFormatted; SpannableStringBuilder sb = new SpannableStringBuilder(title); int a = sb.Length(); sb.SetSpan(new AbsoluteSizeSpan(20, true), 0, a, SpanTypes.ExclusiveExclusive); menuItem.SetTitle(sb); } }
public override void SetAppearance(UITabBarController controller, ShellAppearance appearance) { base.SetAppearance(controller, appearance); UITabBar tabBar = controller.TabBar; tabBar.Translucent |= tabBar.Items is null; if (!(tabBar.Items is null)) { foreach (UITabBarItem item in tabBar.Items) { var normalAttr = item.GetTitleTextAttributes(UIControlState.Normal); var selectedAttr = item.GetTitleTextAttributes(UIControlState.Selected); normalAttr.Font = selectedAttr.Font = UIFont.FromName("LemonMilk-Regular", 10); item.SetTitleTextAttributes(normalAttr, UIControlState.Normal); item.SetTitleTextAttributes(selectedAttr, UIControlState.Selected); } } }
void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance) { global::Windows.UI.Color backgroundColor = DefaultBackgroundColor; global::Windows.UI.Color titleColor = DefaultTitleColor; if (appearance != null) { if (!appearance.BackgroundColor.IsDefault()) backgroundColor = appearance.BackgroundColor.ToWindowsColor(); if (!appearance.TitleColor.IsDefault()) titleColor = appearance.TitleColor.ToWindowsColor(); _flyoutWidth = appearance.FlyoutWidth; _flyoutHeight = appearance.FlyoutHeight; } UpdateFlyoutBackdrop(); UpdateFlyoutPosition(); }
void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance) { var previousFlyoutWidth = FlyoutWidth; var previousFlyoutHeight = FlyoutHeight; if (appearance == null) { UpdateScrim(Brush.Transparent); _flyoutWidth = -1; _flyoutHeight = LP.MatchParent; } else { UpdateScrim(appearance.FlyoutBackdrop); if (appearance.FlyoutHeight != -1) { _flyoutHeight = Context.ToPixels(appearance.FlyoutHeight); } else { _flyoutHeight = LP.MatchParent; } if (appearance.FlyoutWidth != -1) { _flyoutWidth = Context.ToPixels(appearance.FlyoutWidth); } else { _flyoutWidth = -1; } } if (previousFlyoutWidth != FlyoutWidth || previousFlyoutHeight != FlyoutHeight) { UpdateFlyoutSize(); if (_content != null) { UpdateDrawerLockMode(_behavior); } } }
public override void SetAppearance(TabLayout tabLayout, ShellAppearance appearance) { base.SetAppearance(tabLayout, appearance); //tabLayout.TabMode = 1; //if (Build.VERSION.SdkInt < BuildVersionCodes.P) // return; //TypefaceSpan typefaceSpan = new TypefaceSpan(CustomShellRenderer.BottomTabTitleTypeface); //for (int i = 0; i < tabLayout.TabCount; i++) //{ // var menuItem = tabLayout.GetTabAt(i); // if (menuItem.TextFormatted == null) // return; // SpannableStringBuilder spannableText = new SpannableStringBuilder(menuItem.TextFormatted); // spannableText.SetSpan(typefaceSpan, 0, spannableText.Length(), 0); // menuItem.SetText(spannableText); //} }
void UpdateStatusBarColor(ShellAppearance appearance) { var activity = AndroidContext.GetActivity(); var window = activity?.Window; var decorView = window?.DecorView; var resources = AndroidContext.Resources; int statusBarHeight = 0; int resourceId = resources.GetIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { statusBarHeight = resources.GetDimensionPixelSize(resourceId); } int navigationBarHeight = 0; resourceId = resources.GetIdentifier("navigation_bar_height", "dimen", "android"); if (resourceId > 0) { navigationBarHeight = resources.GetDimensionPixelSize(resourceId); } // TODO Previewer Hack if (decorView != null) { // we are using the split drawable here to avoid GPU overdraw. // All it really is is a drawable that only draws under the statusbar/bottom bar to make sure // we dont draw over areas we dont need to. This has very limited benefits considering its // only saving us a flat color fill BUT it helps people not freak out about overdraw. if (appearance != null) { var color = appearance.BackgroundColor.ToAndroid(Color.FromHex("#03A9F4")); decorView.SetBackground(new SplitDrawable(color, statusBarHeight, navigationBarHeight)); } else { var color = Color.FromHex("#03A9F4").ToAndroid(); decorView.SetBackground(new SplitDrawable(color, statusBarHeight, navigationBarHeight)); } } }
public void SetAppearance(UINavigationController controller, ShellAppearance appearance) { var navBar = controller.NavigationBar; if (_defaultTint == null) { _defaultBarTint = navBar.BarTintColor; _defaultTint = navBar.TintColor; _defaultTitleAttributes = navBar.TitleTextAttributes; } if (OperatingSystem.IsIOSVersionAtLeast(15) || OperatingSystem.IsTvOSVersionAtLeast(15)) { UpdateiOS15NavigationBarAppearance(controller, appearance); } else { UpdateNavigationBarAppearance(controller, appearance); } }
public void SetAppearance(UINavigationController controller, ShellAppearance appearance) { var navBar = controller.NavigationBar; if (_defaultTint == null) { _defaultBarTint = navBar.BarTintColor; _defaultTint = navBar.TintColor; _defaultTitleAttributes = navBar.TitleTextAttributes; } if (Forms.IsiOS15OrNewer) { UpdateiOS15NavigationBarAppearance(controller, appearance); } else { UpdateNavigationBarAppearance(controller, appearance); } }
public void SetAppearance(UITabBarController controller, ShellAppearance appearance) { UITabBar myTabBar = controller.TabBar; if (myTabBar.Items != null) { UITabBarItem itemOne = myTabBar.Items[0]; itemOne.Image = UIImage.FromBundle("tab_about.png"); itemOne.SelectedImage = UIImage.FromBundle("tab_feed.png"); UITabBarItem itemTwo = myTabBar.Items[1]; itemTwo.Image = UIImage.FromBundle("tab_feed.png"); itemTwo.SelectedImage = UIImage.FromBundle("tab_about.png"); //The same logic if you have itemThree, itemFour.... } }
public override void SetAppearance(UITabBarController controller, ShellAppearance appearance) { UITabBar myTabBar = controller.TabBar; base.SetAppearance(controller, appearance); if (myTabBar.Items != null && myTabBar.Items.Count() == 4) { UITabBarItem item = myTabBar.Items[0]; item.Image = UIImage.FromBundle("HomeIcon.png"); item.SelectedImage = UIImage.FromBundle("HomeIcon.png"); item.Image?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); item.SelectedImage?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); item.ImageInsets = new UIEdgeInsets(5, 0, -5, 0); item = myTabBar.Items[1]; item.Image = UIImage.FromBundle("NewsIcon.png"); item.SelectedImage = UIImage.FromBundle("NewsIcon.png"); item.Image?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); item.SelectedImage?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); item.ImageInsets = new UIEdgeInsets(5, 0, -5, 0); item = myTabBar.Items[2]; item.Image = UIImage.FromBundle("EventsIcon.png"); item.SelectedImage = UIImage.FromBundle("EventsIcon.png"); item.Image?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); item.SelectedImage?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); item.ImageInsets = new UIEdgeInsets(5, 0, -5, 0); item = myTabBar.Items[3]; item.Image = UIImage.FromBundle("InfoIcon.png"); item.SelectedImage = UIImage.FromBundle("InfoIcon.png"); item.Image?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); item.SelectedImage?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); item.ImageInsets = new UIEdgeInsets(5, 0, -5, 0); } }
public void SetAppearance(UITabBarController controller, ShellAppearance appearance) { var background = appearance.BackgroundColor; var foreground = appearance.ForegroundColor; var titleColor = appearance.TitleColor; var disabledColor = appearance.DisabledColor; var unselectedColor = appearance.UnselectedColor; 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); if (!background.IsDefault) { _colorView.BackgroundColor = background.ToUIColor(); } if (!foreground.IsDefault) { tabBar.TintColor = foreground.ToUIColor(); } if (!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 (backgroundColor != null) { tabBar.BarTintColor = backgroundColor.ToUIColor(); } if (titleColor != null) { tabBar.TintColor = titleColor.ToUIColor(); } if (operatingSystemSupportsUnselectedTint) { if (unselectedColor != null) { tabBar.UnselectedItemTintColor = unselectedColor.ToUIColor(); } } }