1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-14 10:15:56 +01:00

set theme on options change

This commit is contained in:
Kyle Spearrin 2019-05-29 14:23:55 -04:00
parent 48376d0a93
commit 40484a7bf0
3 changed files with 35 additions and 29 deletions

View File

@ -1,5 +1,6 @@
using Bit.App.Abstractions;
using Bit.App.Resources;
using Bit.App.Utilities;
using Bit.Core;
using Bit.Core.Abstractions;
using Bit.Core.Enums;
@ -19,10 +20,10 @@ namespace Bit.App.Pages
private bool _disableFavicon;
private bool _disableAutoTotpCopy;
private int _clearClipboardSelectedIndex;
private int _themeSelectedIndex;
private int _uriMatchSelectedIndex;
private bool _inited;
public OptionsPageViewModel()
{
@ -136,22 +137,29 @@ namespace Bit.App.Pages
UriMatchOptions.FindIndex(k => (int?)k.Key == defaultUriMatch);
var clearClipboard = await _storageService.GetAsync<int?>(Constants.ClearClipboardKey);
ClearClipboardSelectedIndex = ClearClipboardOptions.FindIndex(k => k.Key == clearClipboard);
_inited = true;
}
private async Task UpdateAutoTotpCopyAsync()
{
await _storageService.SaveAsync(Constants.DisableAutoTotpCopyKey, DisableAutoTotpCopy);
if(_inited)
{
await _storageService.SaveAsync(Constants.DisableAutoTotpCopyKey, DisableAutoTotpCopy);
}
}
private async Task UpdateDisableFaviconAsync()
{
await _storageService.SaveAsync(Constants.DisableFaviconKey, DisableFavicon);
await _stateService.SaveAsync(Constants.DisableFaviconKey, DisableFavicon);
if(_inited)
{
await _storageService.SaveAsync(Constants.DisableFaviconKey, DisableFavicon);
await _stateService.SaveAsync(Constants.DisableFaviconKey, DisableFavicon);
}
}
private async Task SaveClipboardChangedAsync()
{
if(ClearClipboardSelectedIndex > -1)
if(_inited && ClearClipboardSelectedIndex > -1)
{
await _storageService.SaveAsync(Constants.ClearClipboardKey,
ClearClipboardOptions[ClearClipboardSelectedIndex].Key);
@ -160,16 +168,17 @@ namespace Bit.App.Pages
private async Task SaveThemeAsync()
{
if(ThemeSelectedIndex > -1)
if(_inited && ThemeSelectedIndex > -1)
{
await _storageService.SaveAsync(Constants.ThemeKey, ThemeOptions[ThemeSelectedIndex].Key);
// TODO: change theme
var theme = ThemeOptions[ThemeSelectedIndex].Key;
await _storageService.SaveAsync(Constants.ThemeKey, theme);
ThemeManager.SetThemeStyle(theme);
}
}
private async Task SaveDefaultUriAsync()
{
if(UriMatchSelectedIndex > -1)
if(_inited && UriMatchSelectedIndex > -1)
{
await _storageService.SaveAsync(Constants.DefaultUriMatch, UriMatchOptions[UriMatchSelectedIndex].Key);
}

View File

@ -2,33 +2,33 @@
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.Styles.Dark">
<Color x:Key="TextColor">#5DAA00</Color>
<Color x:Key="PrimaryColor">#3c8dbc</Color>
<Color x:Key="DangerColor">#dd4b39</Color>
<Color x:Key="TextColor">#ffffff</Color>
<Color x:Key="PrimaryColor">#52bdfb</Color>
<Color x:Key="DangerColor">#ff3e24</Color>
<Color x:Key="SuccessColor">#00a65a</Color>
<Color x:Key="InfoColor">#555555</Color>
<Color x:Key="WarningColor">#bf7e16</Color>
<Color x:Key="MutedColor">#777777</Color>
<Color x:Key="PasswordNumberColor">#007fde</Color>
<Color x:Key="PasswordSpecialColor">#c40800</Color>
<Color x:Key="MutedColor">#a3a3a3</Color>
<Color x:Key="PasswordNumberColor">#52bdfb</Color>
<Color x:Key="PasswordSpecialColor">#ff7c70</Color>
<Color x:Key="BorderColor">#dddddd</Color>
<Color x:Key="BorderColor">#111111</Color>
<Color x:Key="DisabledIconColor">#c7c7cd</Color>
<Color x:Key="BoxBorderColor">#f0f0f0</Color>
<Color x:Key="BoxHeaderTextColor">#3c8dbc</Color>
<Color x:Key="BoxBorderColor">#2f2f2f</Color>
<Color x:Key="BoxHeaderTextColor">#52bdfb</Color>
<Color x:Key="HeaderTextColor">#ffffff</Color>
<Color x:Key="HeaderEntryTextColor">#ffffff</Color>
<Color x:Key="HeaderEntryPlaceholderColor">#707070</Color>
<Color x:Key="TitleTextColor">#ffffff</Color>
<Color x:Key="TitleEntryTextColor">#ffffff</Color>
<Color x:Key="TitleEntryPlaceholderColor">#707070</Color>
<Color x:Key="ListItemBorderColor">#f0f0f0</Color>
<Color x:Key="ListHeaderTextColor">#3c8dbc</Color>
<Color x:Key="ListItemBorderColor">#2f2f2f</Color>
<Color x:Key="ListHeaderTextColor">#52bdfb</Color>
<Color x:Key="SliderThumbColor">#ffffff</Color>
<Color x:Key="SliderThumbBorderColor">#b5b5b5</Color>
<Color x:Key="SliderTrackColor">#3c8dbc</Color>
<Color x:Key="SliderTrackColor">#52bdfb</Color>
<Color x:Key="FabColor">#3c8dbc</Color>
<Color x:Key="FabPressedColor">#3883af</Color>
<Color x:Key="FabColor">#52bdfb</Color>
<Color x:Key="FabPressedColor">#52bdfb</Color>
</ResourceDictionary>

View File

@ -1,8 +1,5 @@
using Bit.App.Styles;
using System;
using System.Reflection;
using Xamarin.Forms;
using Xamarin.Forms.StyleSheets;
namespace Bit.App.Utilities
{