Bitwarden-app-android-iphon.../src/iOS.Core/Utilities/ThemeHelpers.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

100 lines
3.3 KiB
C#
Raw Normal View History

using Bit.App.Utilities;
using UIKit;
2019-06-24 20:29:23 +02:00
using Xamarin.Forms.Platform.iOS;
namespace Bit.iOS.Core.Utilities
{
public static class ThemeHelpers
{
2019-06-28 18:30:48 +02:00
public static bool LightTheme = true;
public static UIColor SplashBackgroundColor
2019-06-24 20:29:23 +02:00
{
get => ThemeManager.GetResourceColor("SplashBackgroundColor").ToUIColor();
}
public static UIColor BackgroundColor
{
get => ThemeManager.GetResourceColor("BackgroundColor").ToUIColor();
}
public static UIColor MutedColor
{
get => ThemeManager.GetResourceColor("MutedColor").ToUIColor();
}
public static UIColor SuccessColor
{
get => ThemeManager.GetResourceColor("SuccessColor").ToUIColor();
}
public static UIColor DangerColor
{
get => ThemeManager.GetResourceColor("DangerColor").ToUIColor();
}
public static UIColor PrimaryColor
{
get => ThemeManager.GetResourceColor("PrimaryColor").ToUIColor();
}
public static UIColor TextColor
{
get => ThemeManager.GetResourceColor("TextColor").ToUIColor();
}
public static UIColor SeparatorColor
{
get => ThemeManager.GetResourceColor("SeparatorColor").ToUIColor();
}
public static UIColor ListHeaderBackgroundColor
{
get => ThemeManager.GetResourceColor("ListHeaderBackgroundColor").ToUIColor();
}
public static UIColor NavBarBackgroundColor
{
get => ThemeManager.GetResourceColor("NavigationBarBackgroundColor").ToUIColor();
}
public static UIColor NavBarTextColor
{
get => ThemeManager.GetResourceColor("NavigationBarTextColor").ToUIColor();
}
public static UIColor TabBarBackgroundColor
{
get => ThemeManager.GetResourceColor("TabBarBackgroundColor").ToUIColor();
}
public static UIColor TabBarItemColor
{
get => ThemeManager.GetResourceColor("TabBarItemColor").ToUIColor();
}
public static void SetAppearance(string theme, bool osDarkModeEnabled)
{
SetThemeVariables(theme, osDarkModeEnabled);
UINavigationBar.Appearance.ShadowImage = new UIImage();
UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
2019-06-28 18:30:48 +02:00
UIStepper.Appearance.TintColor = MutedColor;
if (!LightTheme)
2019-06-28 18:30:48 +02:00
{
UISwitch.Appearance.TintColor = MutedColor;
}
}
public static UIFont GetDangerFont()
{
return Xamarin.Forms.Font.SystemFontOfSize(Xamarin.Forms.NamedSize.Small,
Xamarin.Forms.FontAttributes.Bold).ToUIFont();
}
2019-06-28 18:30:48 +02:00
private static void SetThemeVariables(string theme, bool osDarkModeEnabled)
2019-06-28 18:30:48 +02:00
{
if (string.IsNullOrWhiteSpace(theme) && osDarkModeEnabled)
{
theme = ThemeManager.Dark;
}
if (theme == ThemeManager.Dark || theme == ThemeManager.Black || theme == ThemeManager.Nord)
2019-06-24 20:29:23 +02:00
{
LightTheme = false;
2019-06-24 20:29:23 +02:00
}
else
{
2019-06-28 18:30:48 +02:00
LightTheme = true;
2019-06-24 20:29:23 +02:00
}
}
}
2019-06-24 21:13:33 +02:00
}