Whereas creating animation logic in order that when the button is pressed, the Card would swipe away, nonetheless, with the present strategy through the use of State and Binding nothing occurs.
I suppose the trick right here is that I am not letting the cardboard view know when the button is triggered.
Here is button the place @State personal var isFLipped = false
:
Button(motion: {
// Deal with button motion
// isTapped.toggle()
isFLipped.toggle()
}) {
Textual content("👍")
.body(width: 70, top: 50)
.background(Shade("Simple"))
.clipShape(RoundedRectangle(cornerRadius: 8))
}
Here is SingleCardView:
ZStack {
RoundedRectangle(cornerRadius: 25, fashion: .steady)
.fill(Shade.white)
.overlay(RoundedRectangle(cornerRadius: 25).stroke(getColor(), lineWidth: 2))// Right here we modify the border colour based mostly on the swipe course
.shadow(radius: 3)
VStack {
NavigationStack {
Textual content(card.time period ?? "Unnamed Card")
Divider()
if isTapped {
Textual content(card.definition ?? "Unnamed Card")
}
}
}
}
.body(width: 300, top: 500)
.rotation3DEffect(
Angle(levels: isFLipped ? 360: 0),
axis: (x: 0, y: isFLipped ? 360 : 0, z: 0)
)
.onTapGesture {
isTapped.toggle()
}
}