From fbd62153eefe232947136b4fe606c85a01c30c0e Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 28 Jun 2019 12:30:48 -0400 Subject: [PATCH] theme splash for extensions --- .../CredentialProviderViewController.cs | 3 ++ ...edentialProviderViewController.designer.cs | 8 ++++ src/iOS.Autofill/MainInterface.storyboard | 1 + src/iOS.Core/Utilities/ThemeHelpers.cs | 44 ++++++++++++++----- src/iOS.Extension/LoadingViewController.cs | 4 +- .../LoadingViewController.designer.cs | 8 ++++ src/iOS.Extension/MainInterface.storyboard | 1 + 7 files changed, 56 insertions(+), 13 deletions(-) diff --git a/src/iOS.Autofill/CredentialProviderViewController.cs b/src/iOS.Autofill/CredentialProviderViewController.cs index 3d451e928..bdd77a0f5 100644 --- a/src/iOS.Autofill/CredentialProviderViewController.cs +++ b/src/iOS.Autofill/CredentialProviderViewController.cs @@ -23,6 +23,8 @@ namespace Bit.iOS.Autofill { InitApp(); base.ViewDidLoad(); + Logo.Image = new UIImage(ThemeHelpers.LightTheme ? "logo.png" : "logo_white.png"); + View.BackgroundColor = ThemeHelpers.SplashBackgroundColor; _context = new Context { ExtContext = ExtensionContext @@ -249,6 +251,7 @@ namespace Bit.iOS.Autofill ServiceContainer.Init(); iOSCoreHelpers.RegisterHockeyApp(); iOSCoreHelpers.Bootstrap(); + iOSCoreHelpers.AppearanceAdjustments(); } } } \ No newline at end of file diff --git a/src/iOS.Autofill/CredentialProviderViewController.designer.cs b/src/iOS.Autofill/CredentialProviderViewController.designer.cs index cd537d30c..ac62805d2 100644 --- a/src/iOS.Autofill/CredentialProviderViewController.designer.cs +++ b/src/iOS.Autofill/CredentialProviderViewController.designer.cs @@ -14,8 +14,16 @@ namespace Bit.iOS.Autofill [Register ("CredentialProviderViewController")] partial class CredentialProviderViewController { + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UIKit.UIImageView Logo { get; set; } + void ReleaseDesignerOutlets () { + if (Logo != null) { + Logo.Dispose (); + Logo = null; + } } } } \ No newline at end of file diff --git a/src/iOS.Autofill/MainInterface.storyboard b/src/iOS.Autofill/MainInterface.storyboard index 08b5e4368..a5e219e6d 100644 --- a/src/iOS.Autofill/MainInterface.storyboard +++ b/src/iOS.Autofill/MainInterface.storyboard @@ -32,6 +32,7 @@ + diff --git a/src/iOS.Core/Utilities/ThemeHelpers.cs b/src/iOS.Core/Utilities/ThemeHelpers.cs index dd75bf6fe..16631698c 100644 --- a/src/iOS.Core/Utilities/ThemeHelpers.cs +++ b/src/iOS.Core/Utilities/ThemeHelpers.cs @@ -5,31 +5,51 @@ namespace Bit.iOS.Core.Utilities { public static class ThemeHelpers { + public static bool LightTheme = true; + 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(); + public static void SetAppearance(string theme) { - var lightTheme = false; - var mutedColor = Xamarin.Forms.Color.FromHex("#777777").ToUIColor(); + SetThemeVariables(theme); + UIStepper.Appearance.TintColor = MutedColor; + if(!LightTheme) + { + UISwitch.Appearance.TintColor = MutedColor; + } + } + + public static void SetExtensionAppearance(string theme) + { + SetAppearance(theme); + UIView.Appearance.BackgroundColor = BackgroundColor; + } + + private static void SetThemeVariables(string theme) + { + LightTheme = false; if(theme == "dark") { - mutedColor = Xamarin.Forms.Color.FromHex("#a3a3a3").ToUIColor(); + MutedColor = Xamarin.Forms.Color.FromHex("#a3a3a3").ToUIColor(); + BackgroundColor = Xamarin.Forms.Color.FromHex("#303030").ToUIColor(); + SplashBackgroundColor = Xamarin.Forms.Color.FromHex("#222222").ToUIColor(); } else if(theme == "black") { - mutedColor = Xamarin.Forms.Color.FromHex("#a3a3a3").ToUIColor(); + MutedColor = Xamarin.Forms.Color.FromHex("#a3a3a3").ToUIColor(); + BackgroundColor = Xamarin.Forms.Color.FromHex("#000000").ToUIColor(); + SplashBackgroundColor = BackgroundColor; } else if(theme == "nord") { - mutedColor = Xamarin.Forms.Color.FromHex("#d8dee9").ToUIColor(); + MutedColor = Xamarin.Forms.Color.FromHex("#d8dee9").ToUIColor(); + BackgroundColor = Xamarin.Forms.Color.FromHex("#3b4252").ToUIColor(); + SplashBackgroundColor = Xamarin.Forms.Color.FromHex("#2e3440").ToUIColor(); } else { - lightTheme = true; - } - - UIStepper.Appearance.TintColor = mutedColor; - if(!lightTheme) - { - UISwitch.Appearance.TintColor = mutedColor; + LightTheme = true; } } } diff --git a/src/iOS.Extension/LoadingViewController.cs b/src/iOS.Extension/LoadingViewController.cs index 08dff301c..be6250f34 100644 --- a/src/iOS.Extension/LoadingViewController.cs +++ b/src/iOS.Extension/LoadingViewController.cs @@ -30,7 +30,8 @@ namespace Bit.iOS.Extension { InitApp(); base.ViewDidLoad(); - View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f); + Logo.Image = new UIImage(ThemeHelpers.LightTheme ? "logo.png" : "logo_white.png"); + View.BackgroundColor = ThemeHelpers.SplashBackgroundColor; _context.ExtContext = ExtensionContext; foreach(var item in ExtensionContext.InputItems) { @@ -385,6 +386,7 @@ namespace Bit.iOS.Extension ServiceContainer.Init(); iOSCoreHelpers.RegisterHockeyApp(); iOSCoreHelpers.Bootstrap(); + iOSCoreHelpers.AppearanceAdjustments(); } private bool IsLocked() diff --git a/src/iOS.Extension/LoadingViewController.designer.cs b/src/iOS.Extension/LoadingViewController.designer.cs index 100bc9ef8..412e58d24 100644 --- a/src/iOS.Extension/LoadingViewController.designer.cs +++ b/src/iOS.Extension/LoadingViewController.designer.cs @@ -14,8 +14,16 @@ namespace Bit.iOS.Extension [Register ("LoadingViewController")] partial class LoadingViewController { + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UIKit.UIImageView Logo { get; set; } + void ReleaseDesignerOutlets () { + if (Logo != null) { + Logo.Dispose (); + Logo = null; + } } } } \ No newline at end of file diff --git a/src/iOS.Extension/MainInterface.storyboard b/src/iOS.Extension/MainInterface.storyboard index afdb9215c..da6e453d3 100644 --- a/src/iOS.Extension/MainInterface.storyboard +++ b/src/iOS.Extension/MainInterface.storyboard @@ -32,6 +32,7 @@ +