Setting
Setting copied to clipboard
Conditionals do not behave as expected
https://github.com/aheze/Setting/assets/1085707/c561f23f-4c8f-44a9-addb-90b8f24b48d6
struct ContentView: View {
@State var enableSecondGroup = false
var body: some View {
VStack {
Button {
enableSecondGroup.toggle()
} label: {
Text("Toggle Group 2")
}
SettingStack {
SettingPage(title: "Playground") {
SettingGroup(header: "Group 1") {
SettingCustomView {
Text("Hello Group 1")
}
}
if enableSecondGroup {
SettingGroup(header: "Group 2") {
SettingCustomView {
Text("Hello Group 2")
}
}
}
}
}
}
.padding()
}
}
Expected behavior
Group 1 should only be visible when the toggle is off; Group 1 and 2 should be visible when toggle is on
Actual behavior
Group 1 is visible when toggle is off; Group 2 is duplicated when toggle is on