diff --git a/Toki Trainer.xcodeproj/project.pbxproj b/Toki Trainer.xcodeproj/project.pbxproj index 110dad7..2d0a17e 100644 --- a/Toki Trainer.xcodeproj/project.pbxproj +++ b/Toki Trainer.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ 7E28111C273302860063DC78 /* toki-partsofspeech.json in Resources */ = {isa = PBXBuildFile; fileRef = 7E28111A273302860063DC78 /* toki-partsofspeech.json */; }; 7E28111D273302860063DC78 /* toki-dictionary.json in Resources */ = {isa = PBXBuildFile; fileRef = 7E28111B273302860063DC78 /* toki-dictionary.json */; }; 7E28112227330DD30063DC78 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E28112127330DD20063DC78 /* Constants.swift */; }; + 7E71E6ED2735D70C007CFF72 /* FlashCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E71E6EC2735D70C007CFF72 /* FlashCardView.swift */; }; 7E943A21273211C200E7DDF4 /* Toki_TrainerApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E943A20273211C200E7DDF4 /* Toki_TrainerApp.swift */; }; 7E943A23273211C200E7DDF4 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E943A22273211C200E7DDF4 /* ContentView.swift */; }; 7E943A25273211C300E7DDF4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7E943A24273211C300E7DDF4 /* Assets.xcassets */; }; @@ -32,6 +33,7 @@ 7E28111A273302860063DC78 /* toki-partsofspeech.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "toki-partsofspeech.json"; sourceTree = ""; }; 7E28111B273302860063DC78 /* toki-dictionary.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "toki-dictionary.json"; sourceTree = ""; }; 7E28112127330DD20063DC78 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; + 7E71E6EC2735D70C007CFF72 /* FlashCardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlashCardView.swift; sourceTree = ""; }; 7E943A1D273211C200E7DDF4 /* Toki Trainer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Toki Trainer.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 7E943A20273211C200E7DDF4 /* Toki_TrainerApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toki_TrainerApp.swift; sourceTree = ""; }; 7E943A22273211C200E7DDF4 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; @@ -68,6 +70,7 @@ 7E943A20273211C200E7DDF4 /* Toki_TrainerApp.swift */, 7E943A22273211C200E7DDF4 /* ContentView.swift */, 7E20D5FE2733AFE700D75B9A /* PartsOfSpeechView.swift */, + 7E71E6EC2735D70C007CFF72 /* FlashCardView.swift */, ); path = Views; sourceTree = ""; @@ -208,6 +211,7 @@ 7E2811192733027F0063DC78 /* TokiPartOfSpeech.swift in Sources */, 7E943A23273211C200E7DDF4 /* ContentView.swift in Sources */, 7E2811172733027F0063DC78 /* TokiDictionary.swift in Sources */, + 7E71E6ED2735D70C007CFF72 /* FlashCardView.swift in Sources */, 7E943A21273211C200E7DDF4 /* Toki_TrainerApp.swift in Sources */, 7E2811182733027F0063DC78 /* TokiJSONLoader.swift in Sources */, 7E28112227330DD30063DC78 /* Constants.swift in Sources */, diff --git a/Toki Trainer.xcodeproj/xcuserdata/averyadapace.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Toki Trainer.xcodeproj/xcuserdata/averyadapace.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index cf492b1..a6ca121 100644 --- a/Toki Trainer.xcodeproj/xcuserdata/averyadapace.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Toki Trainer.xcodeproj/xcuserdata/averyadapace.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -3,4 +3,22 @@ uuid = "2238B32A-BF80-4351-B121-F5E36A8C39FC" type = "1" version = "2.0"> + + + + + + diff --git a/Toki Trainer/Views/FlashCardView.swift b/Toki Trainer/Views/FlashCardView.swift new file mode 100644 index 0000000..1f63527 --- /dev/null +++ b/Toki Trainer/Views/FlashCardView.swift @@ -0,0 +1,66 @@ +// +// FlashCardView.swift +// Toki Trainer +// +// Created by Avery Ada Pace on 11/5/21. +// + +import SwiftUI + +struct FlashCardView: View { + let screen = UIScreen.main.bounds + + @State var flipped = false + + var body: some View { + + let flipDegrees = flipped ? 0.0 : 180.0 + + ZStack() { + Text("sina").opacity(flipped ? 0.0 : 1.0) + Text("you") + .opacity(flipped ? 1.0 : 0.0) + .rotation3DEffect(Angle(degrees: -180 + flipDegrees), axis: (x: 0.0, y: 10.0, z: 0.0)) + } + .frame(width: 0.8 * screen.width, height: 200.0) + .font(.title) + .background(self.flipped ? .cyan : .mint) + .cornerRadius(20) + .shadow(color: .gray, radius: 10.0, x: 10, y: 10) + .rotation3DEffect(self.flipped ? Angle(degrees: 180) : Angle(degrees: 0), axis: (x: 0.0, y: 10.0, z: 0.0) + ) + .animation(.default) + .onTapGesture { + self.flipped.toggle() + } + + } +} + +struct CardFlipModifier: AnimatableModifier { + var rotationAngle: Double + + init(isFaceUp: Bool) { + rotationAngle = isFaceUp ? 0 : 180 + } + + var animatableData: Double { + get { rotationAngle } + set { rotationAngle = newValue } + } + + func body(content: Content) -> some View { + ZStack { + RoundedRectangle(cornerRadius: 20.0) + .fill(Color.blue.opacity(rotationAngle < 90 ? 0.5 : 1.0)) + content + .opacity(rotationAngle < 90 ? 1.0 : 0.0) + } + } +} + +struct FlashCardView_Previews: PreviewProvider { + static var previews: some View { + FlashCardView() + } +}