Skip to content

Instantly share code, notes, and snippets.

@fitomad
Created June 19, 2019 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitomad/a4641db10dad95ba59c458eb136aaac7 to your computer and use it in GitHub Desktop.
Save fitomad/a4641db10dad95ba59c458eb136aaac7 to your computer and use it in GitHub Desktop.
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