Hello! I'm a beginner with swift, and I'm trying to make a wordle solver for iPhone. So far, I've been able to make a 5x6 grid of 30 rectangles where the letters will go, and I want to be able to change the color of each letter by tapping on it. However, I'm running into an error that only appears when I have the code that changes the color of the rectangle. The error message reads: " Protocol 'Any' as a type cannot conform to 'ShapeStyle' ", and the error is on the RoundedRectangle... line. I can't figure out how to fix this.
Here's the code:
struct ContentView: View { // (vvv Current color, number of times clicked)
@State private var letterColors = Array(repeating: [Color.black, 0], count: 30)
@State private var colors = [Color.black, Color.yellow, Color.green]
var columns: [GridItem] = Array(repeating: GridItem(.flexible()), count: 5)
var body: some View {
VStack{
LazyVGrid(columns: columns){
ForEach((0...29), id: \.self) { i in
RoundedRectangle(cornerRadius: 20, style: .continuous)
.fill(letterColors[i][0])
.shadow(radius: 10)
.frame(width: 70, height: 70)
.onTapGesture {
letterColors[i][1] += 1
letterColors[i][0] = colors[letterColors[i][1] as! Int % 3]
}
}
}
Spacer()
}
}
}