Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Seminar002StampBack.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Seminar002StampFront.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Binary file not shown.
31 changes: 26 additions & 5 deletions AsyncSwift/Observed/AppData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by Inho Choi on 2022/09/08.
//

import SwiftUI
import UIKit

final class AppData: ObservableObject {
Expand All @@ -13,9 +14,29 @@ final class AppData: ObservableObject {
}


enum Tab: String {
case event
case ticketing
case stamp
}
enum Tab: String, CaseIterable {
case event
case ticketing
case stamp

var title: String {
rawValue
}

var systemImageName: String {
switch self {
case .event: return "calendar"
case .ticketing: return "banknote"
case .stamp: return "checkmark.square"
}
}

@ViewBuilder
var view: some View {
switch self {
case .event: EventView()
case .ticketing: TicketingView()
case .stamp: StampView()
}
}
}
1 change: 1 addition & 0 deletions AsyncSwift/Views/MainTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct MainTabView: View {
}
}
}
}
}

struct ContentView_Previews: PreviewProvider {
Expand Down
73 changes: 72 additions & 1 deletion AsyncSwift/Views/StampView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,79 @@
import SwiftUI

struct StampView: View {
var tempisScanned = true

@State private var backDegree: Double = 0.0
@State private var frontDegree: Double = -90.0
@State private var isFlipped = false

let durationAndDelay: CGFloat = 0.3

var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
NavigationView {
Group {
if tempisScanned {
Button(action: { flipCard() }) {
ZStack {
stampBack
stampFront
}
}
} else {
notScannedView
}
}
.padding(36)
.navigationTitle("Stamp")
}
} // body
} // View

private extension StampView {
@ViewBuilder
var stampBack: some View {
Image("Seminar002StampBack")
.shadow(color: Color(.sRGB, red: 0, green: 0, blue: 0, opacity: 0.2), radius: 20, x: 0, y: 4) //TODO: 디자인 수정 사항이 있습니다.
.rotation3DEffect(Angle(degrees: frontDegree), axis: (x: 0, y: 1, z: 0))
}

@ViewBuilder
var stampFront: some View {
Image("Seminar002StampFront")
.shadow(color: Color(.sRGB, red: 0, green: 0, blue: 0, opacity: 0.2), radius: 20, x: 0, y: 4) //TODO: 디자인 수정 사항이 있습니다.
.rotation3DEffect(Angle(degrees: backDegree), axis: (x: 0, y: 1, z: 0))
}

@ViewBuilder
var notScannedView: some View {
ZStack {
RoundedRectangle(cornerRadius: 30)
.strokeBorder(Color(red: 0.78, green: 0.78, blue: 0.8), style: StrokeStyle(lineWidth: 2, dash: [10]))

Text("아직 참여한 행사가 없습니다.")
.foregroundColor(.gray)
}
}

//MARK: Flip Card Function
func flipCard () {
isFlipped.toggle()

if isFlipped { // 카드 회전 연속을 위해서 if문 분리
withAnimation(.linear(duration: durationAndDelay)) {
backDegree = 90
}
withAnimation(.linear(duration: durationAndDelay).delay(durationAndDelay)) {
frontDegree = 0
}
} else {
withAnimation(.linear(duration: durationAndDelay)) {
frontDegree = -90
}
withAnimation(.linear(duration: durationAndDelay).delay(durationAndDelay)) {
backDegree = 0
}
}
}
}

Expand Down