1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-23 11:45:38 +01:00

ios themeing

This commit is contained in:
Kyle Spearrin 2019-06-24 14:29:23 -04:00
parent 1af0178b50
commit 2b670a5ae1
16 changed files with 135 additions and 31 deletions

View File

@ -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())
{

View File

@ -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<MobilePlatformUtilsService>("platformUtilsService").Init();

View File

@ -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";
}

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.Styles.Android">
x:Class="Bit.App.Styles.Android"
xmlns:controls="clr-namespace:Bit.App.Controls">
<Style TargetType="Entry"
ApplyToDerivedTypes="True">
<Setter Property="PlaceholderColor"
@ -31,6 +32,16 @@
<Setter Property="PlaceholderColor"
Value="{StaticResource TitleEntryPlaceholderColor}" />
</Style>
<Style TargetType="controls:ExtendedSlider">
<Setter Property="MinimumTrackColor"
Value="{StaticResource SliderTrackMinColor}" />
<Setter Property="MaximumTrackColor"
Value="{StaticResource SliderTrackMinColor}" />
<Setter Property="ThumbColor"
Value="{StaticResource SliderThumbColor}" />
<Setter Property="ThumbBorderColor"
Value="{StaticResource SliderThumbBorderColor}" />
</Style>
<!-- Buttons -->

View File

@ -2,8 +2,7 @@
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.Styles.Base"
xmlns:fab="clr-namespace:Refractored.FabControl;assembly=Refractored.FabControl"
xmlns:controls="clr-namespace:Bit.App.Controls">
xmlns:fab="clr-namespace:Refractored.FabControl;assembly=Refractored.FabControl">
<!-- General -->
<Style TargetType="Label"
@ -60,16 +59,6 @@
<Setter Property="FontAttributes"
Value="Bold" />
</Style>
<Style TargetType="controls:ExtendedSlider">
<Setter Property="MinimumTrackColor"
Value="{StaticResource SliderTrackMinColor}" />
<Setter Property="MaximumTrackColor"
Value="{StaticResource SliderTrackMaxColor}" />
<Setter Property="ThumbColor"
Value="{StaticResource SliderThumbColor}" />
<Setter Property="ThumbBorderColor"
Value="{StaticResource SliderThumbBorderColor}" />
</Style>
<!-- Pages -->
<Style TargetType="TabbedPage"

View File

@ -14,6 +14,7 @@
<Color x:Key="ButtonColor">#e0e0e0</Color>
<Color x:Key="InputPlaceholderColor">#707070</Color>
<Color x:Key="BackgroundColor">#000000</Color>
<Color x:Key="BorderColor">#282828</Color>
<Color x:Key="DisabledIconColor">#c7c7cd</Color>
@ -32,12 +33,12 @@
<Color x:Key="SliderThumbColor">#B9B9B9</Color>
<Color x:Key="SliderThumbBorderColor">#000000</Color>
<Color x:Key="SliderTrackMinColor">#52bdfb</Color>
<Color x:Key="SliderTrackMaxColor">#52bdfb</Color>
<Color x:Key="SliderTrackMaxColor">#282828</Color>
<Color x:Key="SwitchOnColor">#52bdfb</Color>
<Color x:Key="ButtonTextColor">#000000</Color>
<Color x:Key="ButtonBackgroundColor">#dddddd</Color>
<Color x:Key="ButtonBackgroundColor">#5A595B</Color>
<Color x:Key="FabColor">#52bdfb</Color>
<Color x:Key="FabPressedColor">#3ea1da</Color>

View File

@ -14,6 +14,7 @@
<Color x:Key="ButtonColor">#e0e0e0</Color>
<Color x:Key="InputPlaceholderColor">#707070</Color>
<Color x:Key="BackgroundColor">#303030</Color>
<Color x:Key="BorderColor">#191919</Color>
<Color x:Key="DisabledIconColor">#c7c7cd</Color>
@ -27,17 +28,17 @@
<Color x:Key="ListItemBorderColor">#262626</Color>
<Color x:Key="ListSectionBorderColor">#191919</Color>
<Color x:Key="ListHeaderTextColor">#52bdfb</Color>
<Color x:Key="ListHeaderBackgroundColor">#efeff4</Color>
<Color x:Key="ListHeaderBackgroundColor">#222222</Color>
<Color x:Key="SliderThumbColor">#B9B9B9</Color>
<Color x:Key="SliderThumbBorderColor">#000000</Color>
<Color x:Key="SliderTrackMinColor">#52bdfb</Color>
<Color x:Key="SliderTrackMaxColor">#52bdfb</Color>
<Color x:Key="SliderTrackMaxColor">#191919</Color>
<Color x:Key="SwitchOnColor">#52bdfb</Color>
<Color x:Key="ButtonTextColor">#000000</Color>
<Color x:Key="ButtonBackgroundColor">#dddddd</Color>
<Color x:Key="ButtonTextColor">#ffffff</Color>
<Color x:Key="ButtonBackgroundColor">#5A595B</Color>
<Color x:Key="FabColor">#52bdfb</Color>
<Color x:Key="FabPressedColor">#3ea1da</Color>

View File

@ -14,6 +14,7 @@
<Color x:Key="ButtonColor">#3c8dbc</Color>
<Color x:Key="InputPlaceholderColor">#d0d0d0</Color>
<Color x:Key="BackgroundColor">#ffffff</Color>
<Color x:Key="BorderColor">#dddddd</Color>
<Color x:Key="DisabledIconColor">#c7c7cd</Color>

View File

@ -14,6 +14,7 @@
<Color x:Key="ButtonColor">#d8dee9</Color>
<Color x:Key="InputPlaceholderColor">#7b88a1</Color>
<Color x:Key="BackgroundColor">#3b4252</Color>
<Color x:Key="BorderColor">#2e3440</Color>
<Color x:Key="DisabledIconColor">#d8dee9</Color>
@ -32,12 +33,12 @@
<Color x:Key="SliderThumbColor">#e5e9f0</Color>
<Color x:Key="SliderThumbBorderColor">#2e3440</Color>
<Color x:Key="SliderTrackMinColor">#81a1c1</Color>
<Color x:Key="SliderTrackMaxColor">#81a1c1</Color>
<Color x:Key="SliderTrackMaxColor">#2e3440</Color>
<Color x:Key="SwitchOnColor">#81a1c1</Color>
<Color x:Key="ButtonTextColor">#000000</Color>
<Color x:Key="ButtonBackgroundColor">#dddddd</Color>
<Color x:Key="ButtonTextColor">#e5e9f0</Color>
<Color x:Key="ButtonBackgroundColor">#4c566a</Color>
<Color x:Key="FabColor">#81a1c1</Color>
<Color x:Key="FabPressedColor">#81a1c1</Color>

View File

@ -1,21 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.Styles.iOS">
x:Class="Bit.App.Styles.iOS"
xmlns:controls="clr-namespace:Bit.App.Controls">
<Style TargetType="Entry"
ApplyToDerivedTypes="True">
<Setter Property="PlaceholderColor"
Value="{StaticResource InputPlaceholderColor}" />
<Setter Property="TextColor"
Value="{StaticResource TextColor}" />
<Setter Property="Margin"
Value="0, 5, 0, 12" />
</Style>
<Style TargetType="Picker"
ApplyToDerivedTypes="True">
<Setter Property="TextColor"
Value="{StaticResource TextColor}" />
<Setter Property="Margin"
Value="0, 5, 0, 12" />
</Style>
<Style TargetType="Editor"
ApplyToDerivedTypes="True">
<Setter Property="TextColor"
Value="{StaticResource TextColor}" />
<Setter Property="BackgroundColor"
Value="{StaticResource BackgroundColor}" />
<Setter Property="PlaceholderColor"
Value="{StaticResource InputPlaceholderColor}" />
<Setter Property="Margin"
@ -36,6 +45,29 @@
<Setter Property="PlaceholderColor"
Value="{StaticResource MutedColor}" />
</Style>
<Style TargetType="ContentPage"
ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor"
Value="{StaticResource BackgroundColor}" />
</Style>
<Style TargetType="ListView"
ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor"
Value="{StaticResource BackgroundColor}" />
</Style>
<Style TargetType="ActivityIndicator"
ApplyToDerivedTypes="True">
<Setter Property="Color"
Value="{StaticResource PrimaryColor}" />
</Style>
<Style TargetType="controls:ExtendedSlider">
<Setter Property="MinimumTrackColor"
Value="{StaticResource SliderTrackMinColor}" />
<Setter Property="MaximumTrackColor"
Value="{StaticResource SliderTrackMaxColor}" />
<Setter Property="ThumbColor"
Value="{StaticResource SliderThumbColor}" />
</Style>
<!-- Buttons -->

View File

@ -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));
}
}
}

View File

@ -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;
}
}
}
}

View File

@ -59,6 +59,7 @@
<Compile Include="Services\CryptoPrimitiveService.cs" />
<Compile Include="Services\KeyChainStorageService.cs" />
<Compile Include="Services\LocalizeService.cs" />
<Compile Include="Utilities\ThemeHelpers.cs" />
<Compile Include="Views\Toast.cs" />
</ItemGroup>
<ItemGroup>

View File

@ -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;
}

View File

@ -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;
}
}
}

View File

@ -113,6 +113,7 @@
<Compile Include="AppDelegate.cs" />
<Compile Include="Migration\KeyChainStorageService.cs" />
<Compile Include="NFCReaderDelegate.cs" />
<Compile Include="Renderers\CustomTabbedRenderer.cs" />
<Compile Include="Renderers\CustomPickerRenderer.cs" />
<Compile Include="Renderers\CustomEntryRenderer.cs" />
<Compile Include="Renderers\CustomEditorRenderer.cs" />