david-swift / SettingsKit-macOS

Add a settings window to a SwiftUI macOS app
https://david-swift.github.io/SettingsKit-macOS/
MIT License
87 stars 2 forks source link

Manually set dark mode #13

Closed duncsand closed 4 months ago

duncsand commented 4 months ago

Is your feature request related to a problem? Please describe.

No response

Describe the solution you'd like

I have a switch in my app that allows the user to choose light/dark mode, independently of the global mac setting.

This is implemented as so:

ContentView()
    .preferredColorScheme(darkModeIsOn ? .dark : .light)

I'd like to be able to set dark mode on settingsKit as well, as currently my app will show a light settings dialog when they've set dark mode on.

Describe alternatives you've considered

None

Additional context

None

david-swift commented 4 months ago

I added support for this via preferred color scheme here.

The problem is that there is a SwiftUI bug that makes it currently quite difficult to seriously use with settings windows:

Screenshot 2024-05-18 at 21 28 10 Screenshot 2024-05-18 at 21 28 55

The same happens when setting the appearance globally for the app:

NSApplication.shared.appearance = .init(appearanceNamed: .darkAqua, bundle: nil)

As this is really a SwiftUI or even AppKit bug and not connected to SettingsKit, I'll close this issue. The feature is usable and will become useful once this bug is fixed.