Improves behaviour of dark/light changes on iOS

This commit is contained in:
Stuart Breckenridge 2020-07-17 22:18:10 +08:00
parent ee69714b90
commit b739f6dd61
No known key found for this signature in database
GPG Key ID: 79BD673276AE83CE
3 changed files with 6 additions and 3 deletions

View File

@ -134,7 +134,9 @@ final class AppDefaults: ObservableObject {
} }
set { set {
AppDefaults.store.set(newValue.rawValue, forKey: Key.userInterfaceColorPalette) AppDefaults.store.set(newValue.rawValue, forKey: Key.userInterfaceColorPalette)
objectWillChange.send() DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
self.objectWillChange.send()
})
} }
} }

View File

@ -93,7 +93,7 @@ struct MainApp: App {
.onAppear { refreshProgress.startup() } .onAppear { refreshProgress.startup() }
.environmentObject(refreshProgress) .environmentObject(refreshProgress)
.environmentObject(defaults) .environmentObject(defaults)
.modifier(PreferredColorSchemeModifier(preferredColorScheme: defaults.userInterfaceColorPalette)) .preferredColorScheme(AppDefaults.userInterfaceColorScheme)
} }
.commands { .commands {
CommandGroup(after: .newItem, addition: { CommandGroup(after: .newItem, addition: {

View File

@ -94,7 +94,8 @@ struct SidebarToolbarModifier: ViewModifier {
AddFolderView() AddFolderView()
} }
if viewModel.sheetToShow == .settings { if viewModel.sheetToShow == .settings {
SettingsView().modifier(PreferredColorSchemeModifier(preferredColorScheme: defaults.userInterfaceColorPalette)) SettingsView()
.preferredColorScheme(AppDefaults.userInterfaceColorScheme)
} }
} }
#else #else