mirror of
https://github.com/bitwarden/mobile
synced 2025-12-27 21:53:57 +00:00
themeing
This commit is contained in:
@@ -62,13 +62,7 @@ namespace Bit.App
|
||||
_i18nService = ServiceContainer.Resolve<II18nService>("i18nService") as MobileI18nService;
|
||||
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||
|
||||
InitializeComponent();
|
||||
SetCulture();
|
||||
ThemeManager.SetThemeStyle("light");
|
||||
MainPage = new HomePage();
|
||||
var mainPageTask = SetMainPageAsync();
|
||||
|
||||
ServiceContainer.Resolve<MobilePlatformUtilsService>("platformUtilsService").Init();
|
||||
Bootstrap();
|
||||
_broadcasterService.Subscribe(nameof(App), async (message) =>
|
||||
{
|
||||
if(message.Command == "showDialog")
|
||||
@@ -257,5 +251,15 @@ namespace Bit.App
|
||||
var parsedDomain = DomainName.TryParse("https://bitwarden.com", out var domainName);
|
||||
});
|
||||
}
|
||||
|
||||
private void Bootstrap()
|
||||
{
|
||||
InitializeComponent();
|
||||
SetCulture();
|
||||
ThemeManager.SetTheme();
|
||||
MainPage = new HomePage();
|
||||
var mainPageTask = SetMainPageAsync();
|
||||
ServiceContainer.Resolve<MobilePlatformUtilsService>("platformUtilsService").Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using Bit.Core.Enums;
|
||||
using Bit.Core.Utilities;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
@@ -17,6 +18,7 @@ namespace Bit.App.Pages
|
||||
private readonly IStorageService _storageService;
|
||||
private readonly ITotpService _totpService;
|
||||
private readonly IStateService _stateService;
|
||||
private readonly IMessagingService _messagingService;
|
||||
|
||||
private bool _disableFavicon;
|
||||
private bool _disableAutoTotpCopy;
|
||||
@@ -32,6 +34,7 @@ namespace Bit.App.Pages
|
||||
_storageService = ServiceContainer.Resolve<IStorageService>("storageService");
|
||||
_totpService = ServiceContainer.Resolve<ITotpService>("totpService");
|
||||
_stateService = ServiceContainer.Resolve<IStateService>("stateService");
|
||||
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
||||
|
||||
PageTitle = AppResources.Options;
|
||||
|
||||
@@ -172,7 +175,11 @@ namespace Bit.App.Pages
|
||||
{
|
||||
var theme = ThemeOptions[ThemeSelectedIndex].Key;
|
||||
await _storageService.SaveAsync(Constants.ThemeKey, theme);
|
||||
ThemeManager.SetThemeStyle(theme);
|
||||
if(Device.RuntimePlatform == Device.Android)
|
||||
{
|
||||
await _deviceActionService.ShowLoadingAsync(AppResources.Saving);
|
||||
}
|
||||
_messagingService.Send("updatedTheme", theme);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,10 @@ namespace Bit.App.Pages
|
||||
Xamarin.Forms.PlatformConfiguration.AndroidSpecific.ToolbarPlacement.Bottom);
|
||||
Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetIsSwipePagingEnabled(this, false);
|
||||
Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetIsSmoothScrollEnabled(this, false);
|
||||
Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetBarSelectedItemColor(this,
|
||||
(Color)Application.Current.Resources["TabBarSelectedItemColor"]);
|
||||
Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetBarItemColor(this,
|
||||
(Color)Application.Current.Resources["TabBarItemColor"]);
|
||||
}
|
||||
|
||||
protected async override void OnCurrentPageChanged()
|
||||
|
||||
@@ -349,7 +349,7 @@ namespace Bit.App.Pages
|
||||
col.Checked = CollectionIds.Contains(col.Collection.Id);
|
||||
}
|
||||
}
|
||||
if(Cipher.Login.Uris != null)
|
||||
if(Cipher.Login?.Uris != null)
|
||||
{
|
||||
Uris.ResetWithRange(Cipher.Login.Uris);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,17 @@ namespace Bit.App.Services
|
||||
|
||||
private readonly HashSet<string> _preferenceStorageKeys = new HashSet<string>
|
||||
{
|
||||
Constants.LockOptionKey
|
||||
Constants.LockOptionKey,
|
||||
Constants.ThemeKey,
|
||||
Constants.DefaultUriMatch,
|
||||
Constants.DisableAutoTotpCopyKey,
|
||||
Constants.DisableFaviconKey,
|
||||
Constants.ClearClipboardKey,
|
||||
Constants.AccessibilityAutofillPasswordFieldKey,
|
||||
Constants.AccessibilityAutofillPersistNotificationKey,
|
||||
Constants.LastActiveKey,
|
||||
Constants.PushInitialPromptShownKey,
|
||||
Constants.LastFileCacheClearKey
|
||||
};
|
||||
|
||||
public MobileStorageService(
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace Bit.App.Services
|
||||
{
|
||||
public class PreferencesStorageService : IStorageService
|
||||
{
|
||||
private readonly string _keyFormat = "bwPreferencesStorage:{0}";
|
||||
public static string KeyFormat = "bwPreferencesStorage:{0}";
|
||||
|
||||
private readonly string _sharedName;
|
||||
private readonly JsonSerializerSettings _jsonSettings = new JsonSerializerSettings
|
||||
{
|
||||
@@ -22,7 +23,7 @@ namespace Bit.App.Services
|
||||
|
||||
public Task<T> GetAsync<T>(string key)
|
||||
{
|
||||
var formattedKey = string.Format(_keyFormat, key);
|
||||
var formattedKey = string.Format(KeyFormat, key);
|
||||
if(!Xamarin.Essentials.Preferences.ContainsKey(formattedKey, _sharedName))
|
||||
{
|
||||
return Task.FromResult(default(T));
|
||||
@@ -73,7 +74,7 @@ namespace Bit.App.Services
|
||||
return RemoveAsync(key);
|
||||
}
|
||||
|
||||
var formattedKey = string.Format(_keyFormat, key);
|
||||
var formattedKey = string.Format(KeyFormat, key);
|
||||
var objType = typeof(T);
|
||||
if(objType == typeof(string))
|
||||
{
|
||||
@@ -109,7 +110,7 @@ namespace Bit.App.Services
|
||||
|
||||
public Task RemoveAsync(string key)
|
||||
{
|
||||
var formattedKey = string.Format(_keyFormat, key);
|
||||
var formattedKey = string.Format(KeyFormat, key);
|
||||
if(Xamarin.Essentials.Preferences.ContainsKey(formattedKey, _sharedName))
|
||||
{
|
||||
Xamarin.Essentials.Preferences.Remove(formattedKey, _sharedName);
|
||||
|
||||
@@ -2,6 +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:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
|
||||
xmlns:fab="clr-namespace:Refractored.FabControl;assembly=Refractored.FabControl"
|
||||
xmlns:controls="clr-namespace:Bit.App.Controls">
|
||||
|
||||
@@ -62,6 +63,13 @@
|
||||
Value="{StaticResource SliderThumbBorderColor}" />
|
||||
</Style>
|
||||
|
||||
<!-- Pages -->
|
||||
<Style TargetType="TabbedPage"
|
||||
ApplyToDerivedTypes="True">
|
||||
<Setter Property="BarBackgroundColor"
|
||||
Value="{StaticResource TabBarBackgroundColor}" />
|
||||
</Style>
|
||||
|
||||
<!-- Buttons -->
|
||||
<Style TargetType="Button"
|
||||
ApplyToDerivedTypes="True"
|
||||
@@ -89,7 +97,7 @@
|
||||
<Setter Property="ColorRipple"
|
||||
Value="{StaticResource FabPressedColor}" />
|
||||
</Style>
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<Style TargetType="Button"
|
||||
Class="btn-title"
|
||||
@@ -212,7 +220,7 @@
|
||||
<Setter Property="VerticalOptions"
|
||||
Value="CenterAndExpand" />
|
||||
</Style>
|
||||
|
||||
|
||||
<!-- Box -->
|
||||
|
||||
<Style TargetType="StackLayout"
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
<Color x:Key="BorderColor">#111111</Color>
|
||||
<Color x:Key="DisabledIconColor">#c7c7cd</Color>
|
||||
|
||||
<Color x:Key="BoxBorderColor">#2f2f2f</Color>
|
||||
<Color x:Key="BoxBorderColor">#545454</Color>
|
||||
<Color x:Key="BoxHeaderTextColor">#52bdfb</Color>
|
||||
|
||||
<Color x:Key="TitleTextColor">#ffffff</Color>
|
||||
<Color x:Key="TitleEntryTextColor">#ffffff</Color>
|
||||
<Color x:Key="TitleEntryPlaceholderColor">#707070</Color>
|
||||
|
||||
<Color x:Key="ListItemBorderColor">#2f2f2f</Color>
|
||||
<Color x:Key="ListItemBorderColor">#545454</Color>
|
||||
<Color x:Key="ListHeaderTextColor">#52bdfb</Color>
|
||||
|
||||
<Color x:Key="SliderThumbColor">#ffffff</Color>
|
||||
@@ -30,5 +30,9 @@
|
||||
<Color x:Key="SliderTrackColor">#52bdfb</Color>
|
||||
|
||||
<Color x:Key="FabColor">#52bdfb</Color>
|
||||
<Color x:Key="FabPressedColor">#52bdfb</Color>
|
||||
<Color x:Key="FabPressedColor">#449BCE</Color>
|
||||
|
||||
<Color x:Key="TabBarBackgroundColor">#212121</Color>
|
||||
<Color x:Key="TabBarItemColor">#C0C0C0</Color>
|
||||
<Color x:Key="TabBarSelectedItemColor">#52bdfb</Color>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -31,4 +31,8 @@
|
||||
|
||||
<Color x:Key="FabColor">#3c8dbc</Color>
|
||||
<Color x:Key="FabPressedColor">#3883af</Color>
|
||||
|
||||
<Color x:Key="TabBarBackgroundColor">#ffffff</Color>
|
||||
<Color x:Key="TabBarItemColor">#C0C0C0</Color>
|
||||
<Color x:Key="TabBarSelectedItemColor">#3c8dbc</Color>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Bit.App.Styles;
|
||||
using Bit.App.Services;
|
||||
using Bit.App.Styles;
|
||||
using Bit.Core;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Utilities
|
||||
@@ -37,5 +39,16 @@ namespace Bit.App.Utilities
|
||||
Application.Current.Resources.MergedDictionaries.Add(new iOS());
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetTheme()
|
||||
{
|
||||
SetThemeStyle(GetTheme());
|
||||
}
|
||||
|
||||
public static string GetTheme()
|
||||
{
|
||||
return Xamarin.Essentials.Preferences.Get(
|
||||
string.Format(PreferencesStorageService.KeyFormat, Constants.ThemeKey), default(string));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user