import SwiftUI
//#-learning-code-snippet(toggleExperiment)
struct Bindings: View {
/*#-code-walkthrough(toggle.stateVar)*/
@State var isOn = false
@State var color = Color.primary
/*#-code-walkthrough(toggle.stateVar)*/
//#-learning-code-snippet(addAStateVar)
var body: some View {
VStack {
/*#-code-walkthrough(toggle.viewDef)*/
Toggle("Press Me", isOn: /*#-code-walkthrough(toggle.binding)*/ $isOn /*#-code-walkthrough(toggle.binding)*/)
/*#-code-walkthrough(toggle.viewDef)*/
ColorPicker("Pick a color", selection: $color)
Image(systemName: isOn ? "battery.100" : "battery.25")
.font(.system(size: 150))
.foregroundColor(color)
//#-learning-code-snippet(addAColorModifier)
Text("whatz up")
.foregroundColor(color)
//#-learning-code-snippet(addATextView)
}
.padding()
}
}
struct Bindings_Previews: PreviewProvider {
static var previews: some View {
Bindings().assess()
}
}
Expected behavior
I expected that when you clicked the button "Push me!" to redirect to the MyApp page. However, when I tried to run it, it said it was unable to produce a diagnostic.
Environment
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
I was using Swift Playgrounds, "Keep Going with Apps"
Description
Failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs)
When I ran the code, I got this error on line 4 of NavigationExperiment.
Reproduction
NavigationExperiment
MyApp
Bindings
Expected behavior
I expected that when you clicked the button "Push me!" to redirect to the MyApp page. However, when I tried to run it, it said it was unable to produce a diagnostic.
Environment
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4) Target: arm64-apple-macosx14.0
I was using Swift Playgrounds, "Keep Going with Apps"
Additional information
No response