From b6747a63edac8f521dd606f1043cff7166634cce Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 30 Sep 2019 16:41:31 -0400 Subject: [PATCH] stub out support for dark theme by default --- src/Android/Services/DeviceActionService.cs | 5 +++++ src/App/Abstractions/IDeviceActionService.cs | 1 + src/App/Utilities/ThemeManager.cs | 18 ++++++++++++++++-- src/iOS.Core/Services/DeviceActionService.cs | 5 +++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Android/Services/DeviceActionService.cs b/src/Android/Services/DeviceActionService.cs index e08ef81e5..93061a336 100644 --- a/src/Android/Services/DeviceActionService.cs +++ b/src/Android/Services/DeviceActionService.cs @@ -612,6 +612,11 @@ namespace Bit.Droid.Services } } + public bool UsingDarkTheme() + { + return false; + } + private bool DeleteDir(Java.IO.File dir) { if(dir != null && dir.IsDirectory) diff --git a/src/App/Abstractions/IDeviceActionService.cs b/src/App/Abstractions/IDeviceActionService.cs index f9e120bcf..85c92e71a 100644 --- a/src/App/Abstractions/IDeviceActionService.cs +++ b/src/App/Abstractions/IDeviceActionService.cs @@ -35,5 +35,6 @@ namespace Bit.App.Abstractions string GetBuildNumber(); void OpenAccessibilitySettings(); void OpenAutofillSettings(); + bool UsingDarkTheme(); } } diff --git a/src/App/Utilities/ThemeManager.cs b/src/App/Utilities/ThemeManager.cs index 7fe6b6d85..963a02432 100644 --- a/src/App/Utilities/ThemeManager.cs +++ b/src/App/Utilities/ThemeManager.cs @@ -1,6 +1,8 @@ -using Bit.App.Services; +using Bit.App.Abstractions; +using Bit.App.Services; using Bit.App.Styles; using Bit.Core; +using Bit.Core.Utilities; using Xamarin.Forms; namespace Bit.App.Utilities @@ -29,9 +31,21 @@ namespace Bit.App.Utilities { Application.Current.Resources.MergedDictionaries.Add(new Nord()); } + else if(name == "light") + { + Application.Current.Resources.MergedDictionaries.Add(new Nord()); + } else { - Application.Current.Resources.MergedDictionaries.Add(new Light()); + var deviceActionService = ServiceContainer.Resolve("deviceActionService", true); + if(deviceActionService?.UsingDarkTheme() ?? false) + { + Application.Current.Resources.MergedDictionaries.Add(new Dark()); + } + else + { + Application.Current.Resources.MergedDictionaries.Add(new Light()); + } } // Base styles diff --git a/src/iOS.Core/Services/DeviceActionService.cs b/src/iOS.Core/Services/DeviceActionService.cs index 0c7b12604..2125cdc9e 100644 --- a/src/iOS.Core/Services/DeviceActionService.cs +++ b/src/iOS.Core/Services/DeviceActionService.cs @@ -351,6 +351,11 @@ namespace Bit.iOS.Core.Services throw new NotImplementedException(); } + public bool UsingDarkTheme() + { + return false; + } + private void ImagePicker_FinishedPickingMedia(object sender, UIImagePickerMediaPickedEventArgs e) { if(sender is UIImagePickerController picker)