SwiftUI:
This code is giving me so many headaches, it works without the Switch-Case statement
struct MyModifier: ViewModifier {
@Binding var animal: Animal
init(chosenAnimal: Binding<Animal>) {
self._animal = chosenAnimal
}
func body(content: Content) -> some View {
content
.offset(x: scrollOffset + dragOffset, y: 0)
..... CODE THAT HELPS ME MAKING A SNAPPABLE HSTACK IS HERE... NOT IMPORTANT
switch index {
case 4:
self._animal = Animal.Dog
case 3:
$animal = Animal.Cat
}
})
)
}
}
Those are the images that show the errors
I have tried:
adding mutating in func body(content: Content) -> some View but then it gives me an error saying I am not conforming ViewModifier.