File tree 1 file changed +16
-1
lines changed
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import SwiftUI
11
11
struct ContentView : View {
12
12
13
13
@State var show = false
14
+ @State var viewState = CGSize . zero
14
15
15
16
var body : some View {
16
17
ZStack {
@@ -31,24 +32,38 @@ struct ContentView: View {
31
32
. rotationEffect ( Angle ( degrees: show ? 15 : 0 ) )
32
33
. blendMode ( . hardLight)
33
34
. animation ( . basic( duration: 0.7 , curve: . easeInOut) )
35
+ . offset ( x: viewState. width, y: viewState. height)
34
36
35
37
CardView ( )
36
- . background ( show ? Color . red : Color ( " background8 " ) )
38
+ . background ( show ? Color ( " background5 " ) : Color ( " background8 " ) )
37
39
. cornerRadius ( 10 )
38
40
. shadow ( radius: 20 )
39
41
. offset ( x: 0 , y: show ? - 200 : - 20 )
40
42
. scaleEffect ( 0.9 )
41
43
. rotationEffect ( Angle ( degrees: show ? 10 : 0 ) )
42
44
. blendMode ( . hardLight)
43
45
. animation ( . basic( duration: 0.5 , curve: . easeInOut) )
46
+ . offset ( x: viewState. width, y: viewState. height)
44
47
45
48
CertificateView ( )
49
+ . offset ( x: viewState. width, y: viewState. height)
46
50
. scaleEffect ( 0.95 )
47
51
. rotationEffect ( Angle ( degrees: show ? 5 : 0 ) )
48
52
. animation ( . spring( ) )
49
53
. tapAction {
50
54
self . show. toggle ( )
51
55
}
56
+ . gesture (
57
+ DragGesture ( )
58
+ . onChanged { value in
59
+ self . viewState = value. translation
60
+ self . show = true
61
+ }
62
+ . onEnded { _ in
63
+ self . viewState = CGSize . zero
64
+ self . show = false
65
+ }
66
+ )
52
67
}
53
68
}
54
69
}
You can’t perform that action at this time.
0 commit comments