File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import SwiftUI
1111struct ContentView : View {
1212
1313 @State var show = false
14+ @State var viewState = CGSize . zero
1415
1516 var body : some View {
1617 ZStack {
@@ -31,24 +32,38 @@ struct ContentView: View {
3132 . rotationEffect ( Angle ( degrees: show ? 15 : 0 ) )
3233 . blendMode ( . hardLight)
3334 . animation ( . basic( duration: 0.7 , curve: . easeInOut) )
35+ . offset ( x: viewState. width, y: viewState. height)
3436
3537 CardView ( )
36- . background ( show ? Color . red : Color ( " background8 " ) )
38+ . background ( show ? Color ( " background5 " ) : Color ( " background8 " ) )
3739 . cornerRadius ( 10 )
3840 . shadow ( radius: 20 )
3941 . offset ( x: 0 , y: show ? - 200 : - 20 )
4042 . scaleEffect ( 0.9 )
4143 . rotationEffect ( Angle ( degrees: show ? 10 : 0 ) )
4244 . blendMode ( . hardLight)
4345 . animation ( . basic( duration: 0.5 , curve: . easeInOut) )
46+ . offset ( x: viewState. width, y: viewState. height)
4447
4548 CertificateView ( )
49+ . offset ( x: viewState. width, y: viewState. height)
4650 . scaleEffect ( 0.95 )
4751 . rotationEffect ( Angle ( degrees: show ? 5 : 0 ) )
4852 . animation ( . spring( ) )
4953 . tapAction {
5054 self . show. toggle ( )
5155 }
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+ )
5267 }
5368 }
5469}
You can’t perform that action at this time.
0 commit comments