@@ -208,9 +208,13 @@ struct _AnyGesture: ParseableModifierValue {
208208 case . onEnded( let onEnded) :
209209 return AnyGesture < Any > ( gesture. onEnded ( { value in
210210 Task {
211- var eventValue : [ String : Any ]
211+ func sendEventValue( _ eventValue: [ String : Any ] ) async throws {
212+ let eventValue = eventValue. merging ( element. buildPhxValuePayload ( ) , uniquingKeysWith: { $1 } )
213+ try await onEnded. action ( value: eventValue, in: context)
214+ }
215+ #if os(iOS) || os(macOS) || os(watchOS) || os(visionOS)
212216 if let drag = value as? DragGesture . Value {
213- eventValue = [
217+ return try await sendEventValue ( [
214218 " translation " : [
215219 " width " : drag. translation. width,
216220 " height " : drag. translation. height
@@ -235,44 +239,46 @@ struct _AnyGesture: ParseableModifierValue {
235239 " width " : drag. velocity. width,
236240 " height " : drag. velocity. height
237241 ]
238- ]
239- } else if let spatialTap = value as? SpatialTapGesture . Value {
240- eventValue = [
242+ ] )
243+ }
244+ #endif
245+ #if os(iOS) || os(macOS) || os(watchOS) || os(visionOS)
246+ if let spatialTap = value as? SpatialTapGesture . Value {
247+ return try await sendEventValue ( [
241248 " location " : [
242249 " x " : spatialTap. location. x,
243250 " y " : spatialTap. location. y
244251 ]
245- ]
246- } else {
247- eventValue = [ : ]
248- #if os(iOS) || os(macOS) || os(visionOS)
249- if #available( iOS 17 , macOS 14 , * ) ,
250- let magnify = value as? MagnifyGesture . Value
251- {
252- eventValue = [
253- " magnification " : magnify. magnification,
254- " startLocation " : [
255- " x " : magnify. startLocation. x,
256- " y " : magnify. startLocation. y
257- ] ,
258- " velocity " : magnify. velocity
259- ]
260- } else if #available( iOS 17 , macOS 14 , * ) ,
261- let rotate = value as? RotateGesture . Value
262- {
263- eventValue = [
264- " rotation " : rotate. rotation. radians,
265- " startLocation " : [
266- " x " : rotate. startLocation. x,
267- " y " : rotate. startLocation. y
268- ] ,
269- " velocity " : rotate. velocity
270- ]
271- }
272- #endif
252+ ] )
253+ }
254+ #endif
255+
256+ #if os(iOS) || os(macOS) || os(visionOS)
257+ if #available( iOS 17 , macOS 14 , * ) ,
258+ let magnify = value as? MagnifyGesture . Value
259+ {
260+ return try await sendEventValue ( [
261+ " magnification " : magnify. magnification,
262+ " startLocation " : [
263+ " x " : magnify. startLocation. x,
264+ " y " : magnify. startLocation. y
265+ ] ,
266+ " velocity " : magnify. velocity
267+ ] )
268+ } else if #available( iOS 17 , macOS 14 , * ) ,
269+ let rotate = value as? RotateGesture . Value
270+ {
271+ return try await sendEventValue ( [
272+ " rotation " : rotate. rotation. radians,
273+ " startLocation " : [
274+ " x " : rotate. startLocation. x,
275+ " y " : rotate. startLocation. y
276+ ] ,
277+ " velocity " : rotate. velocity
278+ ] )
273279 }
274- eventValue . merge ( element . buildPhxValuePayload ( ) , uniquingKeysWith : { $1 } )
275- try await onEnded . action ( value : eventValue , in : context )
280+ #endif
281+ return try await sendEventValue ( [ : ] )
276282 }
277283 } ) . map ( { $0 as Any } ) )
278284 case . exclusively( let exclusively) :
0 commit comments