diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index ddbc46248..2f56710e4 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -68,7 +68,7 @@ namespace Bit.Droid TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; - UpdateTheme(ThemeManager.GetTheme()); + UpdateTheme(ThemeManager.GetTheme(true)); base.OnCreate(savedInstanceState); if(!CoreHelpers.InDebugMode()) { diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs index 639f499e1..0b9f17146 100644 --- a/src/App/App.xaml.cs +++ b/src/App/App.xaml.cs @@ -316,7 +316,7 @@ namespace Bit.App { InitializeComponent(); SetCulture(); - ThemeManager.SetTheme(); + ThemeManager.SetTheme(Device.RuntimePlatform == Device.Android); Current.MainPage = new HomePage(); var mainPageTask = SetMainPageAsync(); ServiceContainer.Resolve("platformUtilsService").Init(); diff --git a/src/App/Pages/Accounts/HomePage.xaml.cs b/src/App/Pages/Accounts/HomePage.xaml.cs index df595dad4..19af20143 100644 --- a/src/App/Pages/Accounts/HomePage.xaml.cs +++ b/src/App/Pages/Accounts/HomePage.xaml.cs @@ -10,7 +10,7 @@ namespace Bit.App.Pages public HomePage() { InitializeComponent(); - var theme = ThemeManager.GetTheme(); + var theme = ThemeManager.GetTheme(Device.RuntimePlatform == Device.Android); var darkbasedTheme = theme == "dark" || theme == "black" || theme == "nord"; _logo.Source = darkbasedTheme ? "logo_white.png" : "logo.png"; } diff --git a/src/App/Styles/Android.xaml b/src/App/Styles/Android.xaml index 6ecf50439..64a6a86e6 100644 --- a/src/App/Styles/Android.xaml +++ b/src/App/Styles/Android.xaml @@ -1,7 +1,8 @@  + x:Class="Bit.App.Styles.Android" + xmlns:controls="clr-namespace:Bit.App.Controls"> + diff --git a/src/App/Styles/Base.xaml b/src/App/Styles/Base.xaml index 193af79ef..b4f685e6b 100644 --- a/src/App/Styles/Base.xaml +++ b/src/App/Styles/Base.xaml @@ -2,8 +2,7 @@ + xmlns:fab="clr-namespace:Refractored.FabControl;assembly=Refractored.FabControl"> - + + + + diff --git a/src/App/Utilities/ThemeManager.cs b/src/App/Utilities/ThemeManager.cs index c36c1fca8..7fe6b6d85 100644 --- a/src/App/Utilities/ThemeManager.cs +++ b/src/App/Utilities/ThemeManager.cs @@ -48,16 +48,16 @@ namespace Bit.App.Utilities } } - public static void SetTheme() + public static void SetTheme(bool android) { - SetThemeStyle(GetTheme()); + SetThemeStyle(GetTheme(android)); } - public static string GetTheme() + public static string GetTheme(bool android) { return Xamarin.Essentials.Preferences.Get( string.Format(PreferencesStorageService.KeyFormat, Constants.ThemeKey), default(string), - Device.RuntimePlatform == Device.iOS ? "group.com.8bit.bitwarden" : default(string)); + !android ? "group.com.8bit.bitwarden" : default(string)); } } } diff --git a/src/iOS.Core/Utilities/ThemeHelpers.cs b/src/iOS.Core/Utilities/ThemeHelpers.cs new file mode 100644 index 000000000..97872bc4f --- /dev/null +++ b/src/iOS.Core/Utilities/ThemeHelpers.cs @@ -0,0 +1,48 @@ +using System; +using UIKit; +using Xamarin.Forms.Platform.iOS; + +namespace Bit.iOS.Core.Utilities +{ + public static class ThemeHelpers + { + public static void SetAppearance(string theme) + { + var lightTheme = false; + var tabBarItemColor = Xamarin.Forms.Color.FromHex("#757575").ToUIColor(); + var primaryColor = Xamarin.Forms.Color.FromHex("#3c8dbc").ToUIColor(); + var mutedColor = Xamarin.Forms.Color.FromHex("#777777").ToUIColor(); + if(theme == "dark") + { + tabBarItemColor = Xamarin.Forms.Color.FromHex("#C0C0C0").ToUIColor(); + primaryColor = Xamarin.Forms.Color.FromHex("#52bdfb").ToUIColor(); + mutedColor = Xamarin.Forms.Color.FromHex("#a3a3a3").ToUIColor(); + } + else if(theme == "black") + { + tabBarItemColor = Xamarin.Forms.Color.FromHex("#C0C0C0").ToUIColor(); + primaryColor = Xamarin.Forms.Color.FromHex("#52bdfb").ToUIColor(); + mutedColor = Xamarin.Forms.Color.FromHex("#a3a3a3").ToUIColor(); + } + else if(theme == "nord") + { + tabBarItemColor = Xamarin.Forms.Color.FromHex("#e5e9f0").ToUIColor(); + primaryColor = Xamarin.Forms.Color.FromHex("#81a1c1").ToUIColor(); + mutedColor = Xamarin.Forms.Color.FromHex("#d8dee9").ToUIColor(); + } + else + { + lightTheme = true; + } + + UITabBar.Appearance.TintColor = tabBarItemColor; + UITabBar.Appearance.SelectedImageTintColor = primaryColor; + + UIStepper.Appearance.TintColor = mutedColor; + if(!lightTheme) + { + UISwitch.Appearance.TintColor = mutedColor; + } + } + } +} \ No newline at end of file diff --git a/src/iOS.Core/iOS.Core.csproj b/src/iOS.Core/iOS.Core.csproj index 0129d3e5e..d5b418526 100644 --- a/src/iOS.Core/iOS.Core.csproj +++ b/src/iOS.Core/iOS.Core.csproj @@ -59,6 +59,7 @@ + diff --git a/src/iOS/AppDelegate.cs b/src/iOS/AppDelegate.cs index 46a2ad150..5de874d1b 100644 --- a/src/iOS/AppDelegate.cs +++ b/src/iOS/AppDelegate.cs @@ -283,9 +283,10 @@ namespace Bit.iOS private void AppearanceAdjustments() { + ThemeHelpers.SetAppearance(ThemeManager.GetTheme(false)); + /* var primaryColor = new UIColor(red: 0.24f, green: 0.55f, blue: 0.74f, alpha: 1.0f); var grayLight = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f); - UINavigationBar.Appearance.ShadowImage = new UIImage(); UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default); UIBarButtonItem.AppearanceWhenContainedIn(new Type[] { typeof(UISearchBar) }).TintColor = primaryColor; @@ -294,6 +295,7 @@ namespace Bit.iOS UIButton.AppearanceWhenContainedIn(new Type[] { typeof(UISearchBar) }).TintColor = primaryColor; UIStepper.Appearance.TintColor = grayLight; UISlider.Appearance.TintColor = primaryColor; + */ UIApplication.SharedApplication.StatusBarHidden = false; UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent; } diff --git a/src/iOS/Renderers/CustomTabbedRenderer.cs b/src/iOS/Renderers/CustomTabbedRenderer.cs new file mode 100644 index 000000000..e3ce9a19b --- /dev/null +++ b/src/iOS/Renderers/CustomTabbedRenderer.cs @@ -0,0 +1,16 @@ +using Bit.iOS.Renderers; +using Xamarin.Forms; +using Xamarin.Forms.Platform.iOS; + +[assembly: ExportRenderer(typeof(TabbedPage), typeof(CustomTabbedRenderer))] +namespace Bit.iOS.Renderers +{ + public class CustomTabbedRenderer : TabbedRenderer + { + public CustomTabbedRenderer() + { + TabBar.Translucent = false; + TabBar.Opaque = true; + } + } +} diff --git a/src/iOS/iOS.csproj b/src/iOS/iOS.csproj index 154bd26f5..8654f91e3 100644 --- a/src/iOS/iOS.csproj +++ b/src/iOS/iOS.csproj @@ -113,6 +113,7 @@ +