From 40484a7bf08063467bfa7ae3d579ba4f1bc905d9 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 29 May 2019 14:23:55 -0400 Subject: [PATCH] set theme on options change --- .../Pages/Settings/OptionsPageViewModel.cs | 27 ++++++++++----- src/App/Styles/Dark.xaml | 34 +++++++++---------- src/App/Utilities/ThemeManager.cs | 3 -- 3 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/App/Pages/Settings/OptionsPageViewModel.cs b/src/App/Pages/Settings/OptionsPageViewModel.cs index 1e859f463..6a41366e8 100644 --- a/src/App/Pages/Settings/OptionsPageViewModel.cs +++ b/src/App/Pages/Settings/OptionsPageViewModel.cs @@ -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(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); } diff --git a/src/App/Styles/Dark.xaml b/src/App/Styles/Dark.xaml index bf8769112..aac5757f2 100644 --- a/src/App/Styles/Dark.xaml +++ b/src/App/Styles/Dark.xaml @@ -2,33 +2,33 @@ - #5DAA00 - #3c8dbc - #dd4b39 + #ffffff + #52bdfb + #ff3e24 #00a65a #555555 #bf7e16 - #777777 - #007fde - #c40800 + #a3a3a3 + #52bdfb + #ff7c70 - #dddddd + #111111 #c7c7cd - #f0f0f0 - #3c8dbc + #2f2f2f + #52bdfb - #ffffff - #ffffff - #707070 + #ffffff + #ffffff + #707070 - #f0f0f0 - #3c8dbc + #2f2f2f + #52bdfb #ffffff #b5b5b5 - #3c8dbc + #52bdfb - #3c8dbc - #3883af + #52bdfb + #52bdfb diff --git a/src/App/Utilities/ThemeManager.cs b/src/App/Utilities/ThemeManager.cs index 0a1b0ca85..8e7c59879 100644 --- a/src/App/Utilities/ThemeManager.cs +++ b/src/App/Utilities/ThemeManager.cs @@ -1,8 +1,5 @@ using Bit.App.Styles; -using System; -using System.Reflection; using Xamarin.Forms; -using Xamarin.Forms.StyleSheets; namespace Bit.App.Utilities {