-
-
Save fitomad/a4641db10dad95ba59c458eb136aaac7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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