Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public struct FlipView: View
{
/// ¿Mostramos el resultado?
@State private var showResults: Bool = false
public var body: some View
{
ZStack
{
Side(text: "Question?")
.background(Color.yellow)
.rotation3DEffect(.degrees(self.showResults ? 180.0 : 0.0), axis: (x: 0.0, y: 1.0, z: 0.0))
.zIndex(self.showResults ? 0 : 1)
.frame(width: 300, alignment: .center)
Side(text: "Answer!")
.background(Color.yellow)
.rotation3DEffect(.degrees(self.showResults ? 0.0 : 180.0), axis: (x: 0.0, y: -1.0, z: 0.0))
.zIndex($showResults ? 1 : 0)
.frame(width: 300, alignment: .center)
}
.tapAction(self.handleFlipViewTap)
}
// MARK: - Actions -
private func handleFlipViewTap() -> Void
{
withAnimation(.basic(duration: 0.25, curve: .easeOut))
{
self.showResults.toggle()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.