Card flip partially working
This commit is contained in:
		@@ -15,6 +15,7 @@
 | 
				
			|||||||
		7E28111C273302860063DC78 /* toki-partsofspeech.json in Resources */ = {isa = PBXBuildFile; fileRef = 7E28111A273302860063DC78 /* toki-partsofspeech.json */; };
 | 
							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 */; };
 | 
							7E28111D273302860063DC78 /* toki-dictionary.json in Resources */ = {isa = PBXBuildFile; fileRef = 7E28111B273302860063DC78 /* toki-dictionary.json */; };
 | 
				
			||||||
		7E28112227330DD30063DC78 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E28112127330DD20063DC78 /* Constants.swift */; };
 | 
							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 */; };
 | 
							7E943A21273211C200E7DDF4 /* Toki_TrainerApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E943A20273211C200E7DDF4 /* Toki_TrainerApp.swift */; };
 | 
				
			||||||
		7E943A23273211C200E7DDF4 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E943A22273211C200E7DDF4 /* ContentView.swift */; };
 | 
							7E943A23273211C200E7DDF4 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E943A22273211C200E7DDF4 /* ContentView.swift */; };
 | 
				
			||||||
		7E943A25273211C300E7DDF4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7E943A24273211C300E7DDF4 /* Assets.xcassets */; };
 | 
							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 = "<group>"; };
 | 
							7E28111A273302860063DC78 /* toki-partsofspeech.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "toki-partsofspeech.json"; sourceTree = "<group>"; };
 | 
				
			||||||
		7E28111B273302860063DC78 /* toki-dictionary.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "toki-dictionary.json"; sourceTree = "<group>"; };
 | 
							7E28111B273302860063DC78 /* toki-dictionary.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "toki-dictionary.json"; sourceTree = "<group>"; };
 | 
				
			||||||
		7E28112127330DD20063DC78 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
 | 
							7E28112127330DD20063DC78 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
 | 
				
			||||||
 | 
							7E71E6EC2735D70C007CFF72 /* FlashCardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlashCardView.swift; sourceTree = "<group>"; };
 | 
				
			||||||
		7E943A1D273211C200E7DDF4 /* Toki Trainer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Toki Trainer.app"; sourceTree = BUILT_PRODUCTS_DIR; };
 | 
							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 = "<group>"; };
 | 
							7E943A20273211C200E7DDF4 /* Toki_TrainerApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toki_TrainerApp.swift; sourceTree = "<group>"; };
 | 
				
			||||||
		7E943A22273211C200E7DDF4 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
 | 
							7E943A22273211C200E7DDF4 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
 | 
				
			||||||
@@ -68,6 +70,7 @@
 | 
				
			|||||||
				7E943A20273211C200E7DDF4 /* Toki_TrainerApp.swift */,
 | 
									7E943A20273211C200E7DDF4 /* Toki_TrainerApp.swift */,
 | 
				
			||||||
				7E943A22273211C200E7DDF4 /* ContentView.swift */,
 | 
									7E943A22273211C200E7DDF4 /* ContentView.swift */,
 | 
				
			||||||
				7E20D5FE2733AFE700D75B9A /* PartsOfSpeechView.swift */,
 | 
									7E20D5FE2733AFE700D75B9A /* PartsOfSpeechView.swift */,
 | 
				
			||||||
 | 
									7E71E6EC2735D70C007CFF72 /* FlashCardView.swift */,
 | 
				
			||||||
			);
 | 
								);
 | 
				
			||||||
			path = Views;
 | 
								path = Views;
 | 
				
			||||||
			sourceTree = "<group>";
 | 
								sourceTree = "<group>";
 | 
				
			||||||
@@ -208,6 +211,7 @@
 | 
				
			|||||||
				7E2811192733027F0063DC78 /* TokiPartOfSpeech.swift in Sources */,
 | 
									7E2811192733027F0063DC78 /* TokiPartOfSpeech.swift in Sources */,
 | 
				
			||||||
				7E943A23273211C200E7DDF4 /* ContentView.swift in Sources */,
 | 
									7E943A23273211C200E7DDF4 /* ContentView.swift in Sources */,
 | 
				
			||||||
				7E2811172733027F0063DC78 /* TokiDictionary.swift in Sources */,
 | 
									7E2811172733027F0063DC78 /* TokiDictionary.swift in Sources */,
 | 
				
			||||||
 | 
									7E71E6ED2735D70C007CFF72 /* FlashCardView.swift in Sources */,
 | 
				
			||||||
				7E943A21273211C200E7DDF4 /* Toki_TrainerApp.swift in Sources */,
 | 
									7E943A21273211C200E7DDF4 /* Toki_TrainerApp.swift in Sources */,
 | 
				
			||||||
				7E2811182733027F0063DC78 /* TokiJSONLoader.swift in Sources */,
 | 
									7E2811182733027F0063DC78 /* TokiJSONLoader.swift in Sources */,
 | 
				
			||||||
				7E28112227330DD30063DC78 /* Constants.swift in Sources */,
 | 
									7E28112227330DD30063DC78 /* Constants.swift in Sources */,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,4 +3,22 @@
 | 
				
			|||||||
   uuid = "2238B32A-BF80-4351-B121-F5E36A8C39FC"
 | 
					   uuid = "2238B32A-BF80-4351-B121-F5E36A8C39FC"
 | 
				
			||||||
   type = "1"
 | 
					   type = "1"
 | 
				
			||||||
   version = "2.0">
 | 
					   version = "2.0">
 | 
				
			||||||
 | 
					   <Breakpoints>
 | 
				
			||||||
 | 
					      <BreakpointProxy
 | 
				
			||||||
 | 
					         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
 | 
				
			||||||
 | 
					         <BreakpointContent
 | 
				
			||||||
 | 
					            uuid = "0CF1FB12-C902-4612-972E-1D35E74BC1AC"
 | 
				
			||||||
 | 
					            shouldBeEnabled = "No"
 | 
				
			||||||
 | 
					            ignoreCount = "0"
 | 
				
			||||||
 | 
					            continueAfterRunningActions = "No"
 | 
				
			||||||
 | 
					            filePath = "Toki Trainer/Views/FlashCardView.swift"
 | 
				
			||||||
 | 
					            startingColumnNumber = "9223372036854775807"
 | 
				
			||||||
 | 
					            endingColumnNumber = "9223372036854775807"
 | 
				
			||||||
 | 
					            startingLineNumber = "24"
 | 
				
			||||||
 | 
					            endingLineNumber = "24"
 | 
				
			||||||
 | 
					            landmarkName = "body"
 | 
				
			||||||
 | 
					            landmarkType = "24">
 | 
				
			||||||
 | 
					         </BreakpointContent>
 | 
				
			||||||
 | 
					      </BreakpointProxy>
 | 
				
			||||||
 | 
					   </Breakpoints>
 | 
				
			||||||
</Bucket>
 | 
					</Bucket>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										66
									
								
								Toki Trainer/Views/FlashCardView.swift
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								Toki Trainer/Views/FlashCardView.swift
									
									
									
									
									
										Normal file
									
								
							@@ -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()
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user