-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathContentView.swift
75 lines (63 loc) · 2.63 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
import SwiftUI
struct ContentView: View {
@State private var flag = true
@State private var mass = 1.0
@State private var stiffness = 104.0
@State private var damping = 10.0
@State private var initialVelocity = 5.0
var body: some View {
ZStack {
Color(.black).ignoresSafeArea()
VStack {
ZStack {
Color.white.opacity(0.2)
ZStack {
Color(.white)
}
.frame(width: 100, height: 100)
.clipShape(RoundedRectangle(cornerRadius: 33, style: .continuous))
.offset(x: 0, y: flag ? -100 : 100)
}.onTapGesture() {
withAnimation(.interpolatingSpring(mass: mass, stiffness: stiffness, damping: damping, initialVelocity: initialVelocity)) {
flag.toggle()
}
}.clipShape(RoundedRectangle(cornerRadius: 24, style: .continuous))
.padding()
VStack() {
VStack(alignment: .leading) {
Text("Mass: \(Int(mass))")
.foregroundColor(.white)
Slider(
value: $mass,
in: 0...20
)
}
VStack(alignment: .leading) {
Text("Stiffness: \(Int(stiffness))")
.foregroundColor(.white)
Slider(
value: $stiffness,
in: 0...1000
)
}
VStack(alignment: .leading) {
Text("Damping \(Int(damping))")
.foregroundColor(.white)
Slider(
value: $damping,
in: 0...100
)
}
VStack(alignment: .leading) {
Text("Initial Velocity \(Int(initialVelocity))")
.foregroundColor(.white)
Slider(
value: $initialVelocity,
in: 0...100
)
}
}.padding(20)
}
}
}
}