1
0
mirror of https://github.com/bitwarden/mobile synced 2025-02-09 00:18:53 +01:00

support dark theme default on extensions

This commit is contained in:
kspearrin 2019-09-30 21:39:50 -04:00
parent e51aa39ede
commit 53bdd92e72
5 changed files with 15 additions and 8 deletions

View File

@ -276,7 +276,7 @@ namespace Bit.iOS.Autofill
_initedHockeyApp = true;
}
iOSCoreHelpers.Bootstrap();
iOSCoreHelpers.AppearanceAdjustments();
iOSCoreHelpers.AppearanceAdjustments(deviceActionService);
}
private void InitAppIfNeeded()

View File

@ -6,6 +6,7 @@ namespace Bit.iOS.Core.Utilities
public static class ThemeHelpers
{
public static bool LightTheme = true;
public static bool UsingOsDarkTheme = false;
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();
@ -18,8 +19,9 @@ namespace Bit.iOS.Core.Utilities
public static UIColor NavBarBackgroundColor = Xamarin.Forms.Color.FromHex("#3c8dbc").ToUIColor();
public static UIColor NavBarTextColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor();
public static void SetAppearance(string theme)
public static void SetAppearance(string theme, bool usingOsDarkTheme)
{
UsingOsDarkTheme = usingOsDarkTheme;
SetThemeVariables(theme);
UINavigationBar.Appearance.ShadowImage = new UIImage();
UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
@ -30,9 +32,9 @@ namespace Bit.iOS.Core.Utilities
}
}
public static void SetExtensionAppearance(string theme)
public static void SetExtensionAppearance(string theme, bool usingOsDarkTheme)
{
SetAppearance(theme);
SetAppearance(theme, usingOsDarkTheme);
UIView.Appearance.BackgroundColor = BackgroundColor;
UILabel.Appearance.TextColor = TextColor;
UITextField.Appearance.TintColor = TextColor;
@ -57,6 +59,11 @@ namespace Bit.iOS.Core.Utilities
private static void SetThemeVariables(string theme)
{
LightTheme = false;
if(string.IsNullOrWhiteSpace(theme) && UsingOsDarkTheme)
{
theme = "dark";
}
if(theme == "dark")
{
var whiteColor = Xamarin.Forms.Color.FromHex("#ffffff").ToUIColor();

View File

@ -72,9 +72,9 @@ namespace Bit.iOS.Core.Utilities
var bootstrapTask = BootstrapAsync();
}
public static void AppearanceAdjustments()
public static void AppearanceAdjustments(IDeviceActionService deviceActionService)
{
ThemeHelpers.SetAppearance(ThemeManager.GetTheme(false));
ThemeHelpers.SetAppearance(ThemeManager.GetTheme(false), deviceActionService.UsingDarkTheme());
UIApplication.SharedApplication.StatusBarHidden = false;
UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;
}

View File

@ -395,7 +395,7 @@ namespace Bit.iOS.Extension
_initedHockeyApp = true;
}
iOSCoreHelpers.Bootstrap();
iOSCoreHelpers.AppearanceAdjustments();
iOSCoreHelpers.AppearanceAdjustments(deviceActionService);
}
private bool IsLocked()

View File

@ -59,7 +59,7 @@ namespace Bit.iOS
_eventService = ServiceContainer.Resolve<IEventService>("eventService");
LoadApplication(new App.App(null));
iOSCoreHelpers.AppearanceAdjustments();
iOSCoreHelpers.AppearanceAdjustments(_deviceActionService);
ZXing.Net.Mobile.Forms.iOS.Platform.Init();
_broadcasterService.Subscribe(nameof(AppDelegate), async (message) =>