Skip to content

Commit 43428a6

Browse files
author
Mithun
committed
Animations and States
1 parent cb1e145 commit 43428a6

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

DesignCode/ContentView.swift

+24-10
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,47 @@
99
import SwiftUI
1010

1111
struct ContentView: View {
12+
13+
@State var show = false
14+
1215
var body: some View {
1316
ZStack {
1417

1518
TitleView()
16-
.blur(radius: 20)
19+
.blur(radius: show ? 20 : 0)
20+
.animation(.default)
1721

1822
CardBottomView()
19-
.blur(radius: 20)
23+
.blur(radius: show ? 20 : 0)
24+
.animation(.default)
2025

2126
CardView()
22-
.offset(x: 0, y: -40)
27+
.background(show ? Color.red : Color("background9"))
28+
.cornerRadius(10)
29+
.shadow(radius: 20)
30+
.offset(x: 0, y: show ? -400 : -40)
2331
.scaleEffect(0.85)
24-
.rotationEffect(Angle(degrees: 15))
32+
.rotationEffect(Angle(degrees: show ? 15 : 0))
2533
.blendMode(.hardLight)
34+
.animation(.basic(duration: 0.7, curve: .easeInOut))
2635

2736
CardView()
28-
.offset(x: 0, y: -20)
37+
.background(show ? Color.red : Color("background8"))
38+
.cornerRadius(10)
39+
.shadow(radius: 20)
40+
.offset(x: 0, y: show ? -200 : -20)
2941
.scaleEffect(0.9)
30-
.rotationEffect(Angle(degrees: 10))
42+
.rotationEffect(Angle(degrees: show ? 10 : 0))
3143
.blendMode(.hardLight)
44+
.animation(.basic(duration: 0.5, curve: .easeInOut))
3245

3346
CertificateView()
3447
.scaleEffect(0.95)
35-
.rotationEffect(Angle(degrees: 5))
48+
.rotationEffect(Angle(degrees: show ? 5 : 0))
49+
.animation(.spring())
50+
.tapAction {
51+
self.show.toggle()
52+
}
3653
}
3754
}
3855
}
@@ -51,9 +68,6 @@ struct CardView: View {
5168
Text("Card Back")
5269
}
5370
.frame(width: 340.0, height: 220.0)
54-
.background(Color.blue)
55-
.cornerRadius(10)
56-
.shadow(radius: 20)
5771
}
5872
}
5973

0 commit comments

Comments
 (0)