2019-06-24 21:13:33 +02:00
|
|
|
|
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;
|
2019-10-01 03:39:50 +02:00
|
|
|
|
public static bool UsingOsDarkTheme = false;
|
2019-06-28 18:30:48 +02:00
|
|
|
|
public static UIColor SplashBackgroundColor = Xamarin.Forms.Color.FromHex("#efeff4").ToUIColor();
|
|
|
|
|
public static UIColor BackgroundColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor();
|
|
|
|
|
public static UIColor MutedColor = Xamarin.Forms.Color.FromHex("#777777").ToUIColor();
|
2019-07-01 21:12:40 +02:00
|
|
|
|
public static UIColor SuccessColor = Xamarin.Forms.Color.FromHex("#00a65a").ToUIColor();
|
2020-09-26 03:14:10 +02:00
|
|
|
|
public static UIColor DangerColor = Xamarin.Forms.Color.FromHex("dd4b39").ToUIColor();
|
2020-05-06 01:13:18 +02:00
|
|
|
|
public static UIColor PrimaryColor = Xamarin.Forms.Color.FromHex("#175DDC").ToUIColor();
|
2019-07-01 21:12:40 +02:00
|
|
|
|
public static UIColor TextColor = Xamarin.Forms.Color.FromHex("#000000").ToUIColor();
|
|
|
|
|
public static UIColor PlaceholderColor = Xamarin.Forms.Color.FromHex("#d0d0d0").ToUIColor();
|
|
|
|
|
public static UIColor SeparatorColor = Xamarin.Forms.Color.FromHex("#dddddd").ToUIColor();
|
2019-07-03 01:35:01 +02:00
|
|
|
|
public static UIColor ListHeaderBackgroundColor = Xamarin.Forms.Color.FromHex("#efeff4").ToUIColor();
|
2020-05-06 01:13:18 +02:00
|
|
|
|
public static UIColor NavBarBackgroundColor = Xamarin.Forms.Color.FromHex("#175DDC").ToUIColor();
|
2019-07-01 21:12:40 +02:00
|
|
|
|
public static UIColor NavBarTextColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor();
|
2019-06-28 18:30:48 +02:00
|
|
|
|
|
2019-10-01 03:39:50 +02:00
|
|
|
|
public static void SetAppearance(string theme, bool usingOsDarkTheme)
|
2019-06-24 20:29:23 +02:00
|
|
|
|
{
|
2019-10-01 03:39:50 +02:00
|
|
|
|
UsingOsDarkTheme = usingOsDarkTheme;
|
2019-06-28 18:30:48 +02:00
|
|
|
|
SetThemeVariables(theme);
|
2019-07-03 23:37:33 +02:00
|
|
|
|
UINavigationBar.Appearance.ShadowImage = new UIImage();
|
|
|
|
|
UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
|
2019-06-28 18:30:48 +02:00
|
|
|
|
UIStepper.Appearance.TintColor = MutedColor;
|
2020-03-28 14:16:28 +01:00
|
|
|
|
if (!LightTheme)
|
2019-06-28 18:30:48 +02:00
|
|
|
|
{
|
|
|
|
|
UISwitch.Appearance.TintColor = MutedColor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-01 03:39:50 +02:00
|
|
|
|
public static void SetExtensionAppearance(string theme, bool usingOsDarkTheme)
|
2019-06-28 18:30:48 +02:00
|
|
|
|
{
|
2019-10-01 03:39:50 +02:00
|
|
|
|
SetAppearance(theme, usingOsDarkTheme);
|
2019-06-28 18:30:48 +02:00
|
|
|
|
UIView.Appearance.BackgroundColor = BackgroundColor;
|
2019-07-01 21:12:40 +02:00
|
|
|
|
UILabel.Appearance.TextColor = TextColor;
|
|
|
|
|
UITextField.Appearance.TintColor = TextColor;
|
|
|
|
|
UITextView.Appearance.TintColor = TextColor;
|
|
|
|
|
UITextField.Appearance.BackgroundColor = BackgroundColor;
|
|
|
|
|
UITextView.Appearance.BackgroundColor = BackgroundColor;
|
|
|
|
|
UITableView.Appearance.BackgroundColor = BackgroundColor;
|
|
|
|
|
UITableView.Appearance.SeparatorColor = SeparatorColor;
|
|
|
|
|
UINavigationBar.Appearance.BackgroundColor = NavBarBackgroundColor;
|
|
|
|
|
UINavigationBar.Appearance.BarTintColor = NavBarBackgroundColor;
|
|
|
|
|
UINavigationBar.Appearance.TintColor = NavBarTextColor;
|
|
|
|
|
UINavigationBar.Appearance.Translucent = false;
|
|
|
|
|
UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes()
|
|
|
|
|
{
|
|
|
|
|
TextColor = NavBarTextColor
|
|
|
|
|
});
|
|
|
|
|
UIBarButtonItem.Appearance.TintColor = NavBarTextColor;
|
|
|
|
|
UIButton.Appearance.TintColor = TextColor;
|
|
|
|
|
UILabel.AppearanceWhenContainedIn(typeof(UITableViewHeaderFooterView)).TextColor = MutedColor;
|
2019-06-28 18:30:48 +02:00
|
|
|
|
}
|
2020-09-26 03:14:10 +02:00
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
LightTheme = false;
|
2020-03-28 14:16:28 +01:00
|
|
|
|
if (string.IsNullOrWhiteSpace(theme) && UsingOsDarkTheme)
|
2019-10-01 03:39:50 +02:00
|
|
|
|
{
|
|
|
|
|
theme = "dark";
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-28 14:16:28 +01:00
|
|
|
|
if (theme == "dark")
|
2019-06-24 20:29:23 +02:00
|
|
|
|
{
|
2019-07-01 21:12:40 +02:00
|
|
|
|
var whiteColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor();
|
2019-06-28 18:30:48 +02:00
|
|
|
|
MutedColor = Xamarin.Forms.Color.FromHex("#a3a3a3").ToUIColor();
|
2019-07-01 21:12:40 +02:00
|
|
|
|
SuccessColor = Xamarin.Forms.Color.FromHex("#00a65a").ToUIColor();
|
2020-09-26 03:14:10 +02:00
|
|
|
|
DangerColor = Xamarin.Forms.Color.FromHex("ff3e24").ToUIColor();
|
2019-06-28 18:30:48 +02:00
|
|
|
|
BackgroundColor = Xamarin.Forms.Color.FromHex("#303030").ToUIColor();
|
|
|
|
|
SplashBackgroundColor = Xamarin.Forms.Color.FromHex("#222222").ToUIColor();
|
2019-07-01 21:12:40 +02:00
|
|
|
|
PrimaryColor = Xamarin.Forms.Color.FromHex("#52bdfb").ToUIColor();
|
|
|
|
|
TextColor = whiteColor;
|
|
|
|
|
PlaceholderColor = Xamarin.Forms.Color.FromHex("#707070").ToUIColor();
|
|
|
|
|
SeparatorColor = Xamarin.Forms.Color.FromHex("#191919").ToUIColor();
|
2019-07-03 01:35:01 +02:00
|
|
|
|
ListHeaderBackgroundColor = Xamarin.Forms.Color.FromHex("#222222").ToUIColor();
|
2019-07-01 21:12:40 +02:00
|
|
|
|
NavBarBackgroundColor = Xamarin.Forms.Color.FromHex("#212121").ToUIColor();
|
|
|
|
|
NavBarTextColor = whiteColor;
|
2019-06-24 20:29:23 +02:00
|
|
|
|
}
|
2020-03-28 14:16:28 +01:00
|
|
|
|
else if (theme == "black")
|
2019-06-24 20:29:23 +02:00
|
|
|
|
{
|
2019-07-01 21:12:40 +02:00
|
|
|
|
var blackColor = Xamarin.Forms.Color.FromHex("#000000").ToUIColor();
|
|
|
|
|
var whiteColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor();
|
2019-06-28 18:30:48 +02:00
|
|
|
|
MutedColor = Xamarin.Forms.Color.FromHex("#a3a3a3").ToUIColor();
|
2019-07-01 21:12:40 +02:00
|
|
|
|
SuccessColor = Xamarin.Forms.Color.FromHex("#00a65a").ToUIColor();
|
2020-09-26 03:14:10 +02:00
|
|
|
|
DangerColor = Xamarin.Forms.Color.FromHex("ff3e24").ToUIColor();
|
2019-07-01 21:12:40 +02:00
|
|
|
|
BackgroundColor = blackColor;
|
|
|
|
|
SplashBackgroundColor = blackColor;
|
|
|
|
|
PrimaryColor = Xamarin.Forms.Color.FromHex("#52bdfb").ToUIColor();
|
|
|
|
|
TextColor = whiteColor;
|
|
|
|
|
PlaceholderColor = Xamarin.Forms.Color.FromHex("#707070").ToUIColor();
|
|
|
|
|
SeparatorColor = Xamarin.Forms.Color.FromHex("#282828").ToUIColor();
|
2019-07-03 01:35:01 +02:00
|
|
|
|
ListHeaderBackgroundColor = blackColor;
|
2019-07-01 21:12:40 +02:00
|
|
|
|
NavBarBackgroundColor = blackColor;
|
|
|
|
|
NavBarTextColor = whiteColor;
|
2019-06-24 20:29:23 +02:00
|
|
|
|
}
|
2020-03-28 14:16:28 +01:00
|
|
|
|
else if (theme == "nord")
|
2019-06-24 20:29:23 +02:00
|
|
|
|
{
|
2019-06-28 18:30:48 +02:00
|
|
|
|
MutedColor = Xamarin.Forms.Color.FromHex("#d8dee9").ToUIColor();
|
2019-07-01 21:12:40 +02:00
|
|
|
|
SuccessColor = Xamarin.Forms.Color.FromHex("#a3be8c").ToUIColor();
|
2020-09-26 03:14:10 +02:00
|
|
|
|
DangerColor = Xamarin.Forms.Color.FromHex("bf616a").ToUIColor();
|
2019-06-28 18:30:48 +02:00
|
|
|
|
BackgroundColor = Xamarin.Forms.Color.FromHex("#3b4252").ToUIColor();
|
|
|
|
|
SplashBackgroundColor = Xamarin.Forms.Color.FromHex("#2e3440").ToUIColor();
|
2019-07-01 21:12:40 +02:00
|
|
|
|
PrimaryColor = Xamarin.Forms.Color.FromHex("#81a1c1").ToUIColor();
|
|
|
|
|
TextColor = Xamarin.Forms.Color.FromHex("#e5e9f0").ToUIColor();
|
|
|
|
|
PlaceholderColor = Xamarin.Forms.Color.FromHex("#7b88a1").ToUIColor();
|
|
|
|
|
SeparatorColor = Xamarin.Forms.Color.FromHex("#2e3440").ToUIColor();
|
2019-07-03 01:35:01 +02:00
|
|
|
|
ListHeaderBackgroundColor = Xamarin.Forms.Color.FromHex("#2e3440").ToUIColor();
|
2019-07-01 21:12:40 +02:00
|
|
|
|
NavBarBackgroundColor = Xamarin.Forms.Color.FromHex("#2e3440").ToUIColor();
|
|
|
|
|
NavBarTextColor = Xamarin.Forms.Color.FromHex("#e5e9f0").ToUIColor();
|
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
|
|
|
|
}
|