-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathContentView.swift
165 lines (142 loc) · 4.2 KB
/
ContentView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//
// ContentView.swift
// DesignCode
//
// Created by Mithun x on 7/11/19.
// Copyright © 2019 Mithun. All rights reserved.
//
import SwiftUI
struct ContentView: View {
@State var show = false
@State var viewState = CGSize.zero
var body: some View {
ZStack {
BlurView(style: .systemMaterial)
TitleView()
.blur(radius: show ? 20 : 0)
.animation(.default)
CardBottomView()
.blur(radius: show ? 20 : 0)
.animation(.default)
CardView()
.background(show ? Color.red : Color("background9"))
.cornerRadius(10)
.shadow(radius: 20)
.offset(x: 0, y: show ? -400 : -40)
.scaleEffect(0.85)
.rotationEffect(Angle(degrees: show ? 15 : 0))
.blendMode(.hardLight)
.animation(.easeInOut(duration: 0.6))
.offset(x: viewState.width, y: viewState.height)
CardView()
.background(show ? Color("background5") : Color("background8"))
.cornerRadius(10)
.shadow(radius: 20)
.offset(x: 0, y: show ? -200 : -20)
.scaleEffect(0.9)
.rotationEffect(Angle(degrees: show ? 10 : 0))
.blendMode(.hardLight)
.animation(.easeInOut(duration: 0.4))
.offset(x: viewState.width, y: viewState.height)
CertificateView()
.offset(x: viewState.width, y: viewState.height)
.scaleEffect(0.95)
.rotationEffect(Angle(degrees: show ? 5 : 0))
.animation(.spring())
.tapAction {
self.show.toggle()
}
.gesture(
DragGesture()
.onChanged { value in
self.viewState = value.translation
self.show = true
}
.onEnded { _ in
self.viewState = CGSize.zero
self.show = false
}
)
}
}
}
#if DEBUG
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif
struct CardView: View {
var body: some View {
return VStack {
Text("Card Back")
}
.frame(width: 340.0, height: 220.0)
}
}
struct CertificateView: View {
var item = Certificate(title: "UI Design", image: "Certificate1", width: 340, height: 220)
var body: some View {
return VStack {
HStack {
VStack(alignment: .leading) {
Text(item.title)
.font(.headline)
.fontWeight(.bold)
.foregroundColor(Color("accent"))
.padding(.top)
Text("Certificate")
.foregroundColor(.white)
}
Spacer()
Image("Logo")
.resizable()
.frame(width: 30, height: 30)
}
.padding(.horizontal)
Spacer()
Image(item.image)
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.offset(y: 50)
}
.frame(width: CGFloat(item.width), height: CGFloat(item.height))
.background(Color.black)
.cornerRadius(10)
.shadow(radius: 10)
}
}
struct TitleView: View {
var body: some View {
return VStack {
HStack {
Text("Certificates")
.font(.largeTitle)
.fontWeight(.heavy)
Spacer()
}
Image("Illustration5")
Spacer()
}.padding()
}
}
struct CardBottomView: View {
var body: some View {
return VStack(spacing: 20.0) {
Rectangle()
.frame(width: 60, height: 6)
.cornerRadius(3.0)
.opacity(0.1)
Text("This certificate is proof that Mithun has achieved UI Design course with approval from a Design+Code instructor.")
.lineLimit(nil)
Spacer()
}
.frame(minWidth: 0, maxWidth: .infinity)
.padding()
.padding(.horizontal)
.background(BlurView(style: .systemMaterial))
.cornerRadius(30)
.shadow(radius: 20)
.offset(y: UIScreen.main.bounds.height - 215)
}
}