import SwiftUI
struct ContentView: View {
@AppStorage("Test") private var toggle = false
@State private var toggle2 = false
var body: some View {
VStack {
Toggle("Demo Toggle", isOn: $toggle)
Toggle("Demo Toggle2", isOn: $toggle2)
.padding()
}
}
}
Normally both toggle will work fine. But if we write such code under Settings.Section
and build it with macOS 14 SDK(Xcode 15.0)
import SwiftUI
import Settings
struct ContentView: View {
@AppStorage("Test")
private var toggle = false
@State
private var toggle2 = false
var body: some View {
Settings.Container(contentWidth: 600) {
Settings.Section {
Text("Hello")
} content: {
Section {
Toggle("Demo Toggle", isOn: $toggle)
Toggle("Demo Toggle2", isOn: $toggle2)
.padding()
}
}
}
}
}
The toggle2 will work while toggle will not. The value stored in UserDefaults is actually changed in both case, but the UI is not updating in the first case automatically unless we trigger an update for toggle2.
See screen recording below if my description is vague
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too