mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-23 07:39:59 +01:00
Try conditional modifier for preferredColorScheme
This commit is contained in:
parent
959eef6a1a
commit
fc548ac913
@ -146,7 +146,9 @@ struct MainApp: App {
|
||||
SceneNavigationView()
|
||||
.environmentObject(sceneModel)
|
||||
.environmentObject(defaults)
|
||||
}.commands {
|
||||
.modifier(PreferredColorSchemeModifier(preferredColorScheme: defaults.userInterfaceColorPalette))
|
||||
}
|
||||
.commands {
|
||||
CommandGroup(after: .newItem, addition: {
|
||||
Button("New Feed", action: {})
|
||||
.keyboardShortcut("N")
|
||||
@ -193,3 +195,20 @@ struct MainApp: App {
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
struct PreferredColorSchemeModifier: ViewModifier {
|
||||
|
||||
var preferredColorScheme: UserInterfaceColorPalette
|
||||
|
||||
@ViewBuilder
|
||||
func body(content: Content) -> some View {
|
||||
switch preferredColorScheme {
|
||||
case .automatic:
|
||||
content
|
||||
case .dark:
|
||||
content.preferredColorScheme(.dark)
|
||||
case .light:
|
||||
content.preferredColorScheme(.light)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,8 @@
|
||||
import SwiftUI
|
||||
|
||||
struct SidebarToolbar: View {
|
||||
|
||||
|
||||
@EnvironmentObject private var appSettings: AppDefaults
|
||||
@State private var showSettings: Bool = false
|
||||
|
||||
var body: some View {
|
||||
@ -40,7 +41,7 @@ struct SidebarToolbar: View {
|
||||
}
|
||||
.background(VisualEffectBlur(blurStyle: .systemChromeMaterial).edgesIgnoringSafeArea(.bottom))
|
||||
.sheet(isPresented: $showSettings, onDismiss: { showSettings = false }) {
|
||||
SettingsView()
|
||||
SettingsView().modifier(PreferredColorSchemeModifier(preferredColorScheme: appSettings.userInterfaceColorPalette))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -407,13 +407,13 @@ private extension AppDelegate {
|
||||
}
|
||||
|
||||
func updateUserInterfaceStyle() {
|
||||
switch AppDefaults.shared.userInterfaceColorPalette {
|
||||
case .automatic:
|
||||
window?.overrideUserInterfaceStyle = .unspecified
|
||||
case .light:
|
||||
window?.overrideUserInterfaceStyle = .light
|
||||
case .dark:
|
||||
window?.overrideUserInterfaceStyle = .dark
|
||||
}
|
||||
// switch AppDefaults.shared.userInterfaceColorPalette {
|
||||
// case .automatic:
|
||||
// window?.overrideUserInterfaceStyle = .unspecified
|
||||
// case .light:
|
||||
// window?.overrideUserInterfaceStyle = .light
|
||||
// case .dark:
|
||||
// window?.overrideUserInterfaceStyle = .dark
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ struct ColorPaletteContainerView: View {
|
||||
if let colorPalette = UserInterfaceColorPalette(rawValue: index) {
|
||||
appSettings.userInterfaceColorPalette = colorPalette
|
||||
}
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
self.presentationMode.wrappedValue.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user