
Hover to play
by Luiz Mello
@luizmellodevA credit card component that flips in 3D on tap to reveal the back side with smooth perspective and polished banking visuals.
//
// A credit card that flips in 3D on tap, revealing the back (CVV side).
// Uses rotation3DEffect with a FlipModifier that auto-hides each face
// at the 90° midpoint for a seamless two-sided effect.
struct BankCardFlip: View {
@State private var flipped = false
var body: some View {
ZStack {
CardFace()
.modifier(FlipModifier(angle: flipped ? 180 : 0))
CardBack()
.modifier(FlipModifier(angle: flipped ? 0 : -180))
}
.animation(.spring(response: 0.65, dampingFraction: 0.78), value: flipped)
.onTapGesture { flipped.toggle() }
}
}