@@ -39,7 +39,7 @@ extension Effect where Error == Never {
39
39
40
40
struct AnimationsState : Equatable {
41
41
var alert : AlertState < AnimationsAction > ?
42
- var circleCenter = CGPoint ( x : 175 , y : 300 )
42
+ var circleCenter : CGPoint ?
43
43
var circleColor = Color . black
44
44
var isCircleScaled = false
45
45
}
@@ -110,48 +110,48 @@ struct AnimationsView: View {
110
110
111
111
var body : some View {
112
112
WithViewStore ( self . store) { viewStore in
113
- GeometryReader { proxy in
114
- VStack ( alignment: . leading) {
115
- ZStack ( alignment: . center) {
116
- Text ( template: readMe, . body)
117
- . padding ( )
118
-
119
- Circle ( )
120
- . fill ( viewStore. circleColor)
121
- . colorInvert ( )
122
- . blendMode ( . difference)
123
- . frame ( width: 50 , height: 50 )
124
- . scaleEffect ( viewStore. isCircleScaled ? 2 : 1 )
125
- . offset (
126
- x: viewStore. circleCenter. x - proxy. size. width / 2 ,
127
- y: viewStore. circleCenter. y - proxy. size. height / 2
128
- )
129
- }
130
- . frame ( maxWidth: . infinity, maxHeight: . infinity)
131
- . background ( self . colorScheme == . dark ? Color . black : . white)
132
- . simultaneousGesture (
113
+ VStack ( alignment: . leading) {
114
+ Text ( template: readMe, . body)
115
+ . padding ( )
116
+ . gesture (
133
117
DragGesture ( minimumDistance: 0 ) . onChanged { gesture in
134
118
viewStore. send (
135
119
. tapped( gesture. location) ,
136
120
animation: . interactiveSpring( response: 0.25 , dampingFraction: 0.1 )
137
121
)
138
122
}
139
123
)
140
- Toggle (
141
- " Big mode " ,
142
- isOn:
143
- viewStore
144
- . binding ( get: \. isCircleScaled, send: AnimationsAction . circleScaleToggleChanged)
145
- . animation ( . interactiveSpring( response: 0.25 , dampingFraction: 0.1 ) )
146
- )
147
- . padding ( )
148
- Button ( " Rainbow " ) { viewStore. send ( . rainbowButtonTapped, animation: . linear) }
149
- . padding ( [ . horizontal, . bottom] )
150
- Button ( " Reset " ) { viewStore. send ( . resetButtonTapped) }
151
- . padding ( [ . horizontal, . bottom] )
152
- }
153
- . alert ( self . store. scope ( state: \. alert) , dismiss: . dismissAlert)
124
+ . overlay {
125
+ GeometryReader { proxy in
126
+ Circle ( )
127
+ . fill ( viewStore. circleColor)
128
+ . colorInvert ( )
129
+ . blendMode ( . difference)
130
+ . frame ( width: 50 , height: 50 )
131
+ . scaleEffect ( viewStore. isCircleScaled ? 2 : 1 )
132
+ . position (
133
+ x: viewStore. circleCenter? . x ?? proxy. size. width / 2 ,
134
+ y: viewStore. circleCenter? . y ?? proxy. size. height / 2
135
+ )
136
+ . offset ( y: viewStore. circleCenter == nil ? 0 : - 44 )
137
+ }
138
+ . allowsHitTesting ( false )
139
+ }
140
+ Toggle (
141
+ " Big mode " ,
142
+ isOn:
143
+ viewStore
144
+ . binding ( get: \. isCircleScaled, send: AnimationsAction . circleScaleToggleChanged)
145
+ . animation ( . interactiveSpring( response: 0.25 , dampingFraction: 0.1 ) )
146
+ )
147
+ . padding ( )
148
+ Button ( " Rainbow " ) { viewStore. send ( . rainbowButtonTapped, animation: . linear) }
149
+ . padding ( [ . horizontal, . bottom] )
150
+ Button ( " Reset " ) { viewStore. send ( . resetButtonTapped) }
151
+ . padding ( [ . horizontal, . bottom] )
154
152
}
153
+ . background ( self . colorScheme == . dark ? Color . black : . white)
154
+ . alert ( self . store. scope ( state: \. alert) , dismiss: . dismissAlert)
155
155
. navigationBarTitleDisplayMode ( . inline)
156
156
}
157
157
}
0 commit comments