This is a companion discussion topic for the original entry at https://www.kodeco.com/38052670-your-first-ios-swiftui-app-polishing-the-app/lessons/28
This is a companion discussion topic for the original entry at https://www.kodeco.com/38052670-your-first-ios-swiftui-app-polishing-the-app/lessons/28
I should have noticed this problem before, but not having created a separate “TextViews” file (on the video “SwiftUI Views and View Modifiers” > “Extract View”) i only noticed it in this video.
Using Xcode 15.3 something has definitely changed in the code used to show the preview of a struct in the canvas.
struct TextViews_Previews: PreviewProvider {
static var previews: some View {
TextViews()
}
}
Now it’s only:
#Preview {
TextViews()
}
So now trying to add the variables to pass to the PointsView() generates errors
Ok, this seems to work, is it correct to proceed this way?
#Preview {
let alertIsVisible = Binding.constant(true)
let sliderValue = Binding.constant(50.0)
let game = Binding.constant(Game())
return PointsView(alertIsVisible: alertIsVisible, sliderValue: sliderValue, game: game)
}
Thank you