I am currently completing a task on Codecademy, and am running into an issue. I created a new view called “ChoiceTextView”, and it is supposed to shorten up my code so the code can reference this view. The issue I am running into is when I try to reference it, I receive the error "Cannot find ‘ChoiceTextView’ in scope’.
Here is the code from ChoiceTextView
import SwiftUI
struct ChoiceTextView: View {
let choiceText: String
let accentColor = Color(red: 48/255, green: 105/255, blue: 240/255)
var body: some View {
Text(choiceText)
.font(.body)
.bold()
.multilineTextAlignment(.center)
.padding()
.border(accentColor, width: 4)
}
}
struct ChoiceTextView_Previews: PreviewProvider {
static var previews: some View {
ChoiceTextView(choiceText: "Choice Text!")
}
}
Here is the code that is throwing the error:
Button(action: { print("Tapped on Choice 1"},
label:{ChoiceTextView(choiceText: question.possibleAnswers[0])
})
I hope I summarized my issue correctly. Please let me know if you have any questions, and thank you.