TapGestures.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. extension BackendFeatures {
  2. /// Backend methods for tap gesture handling.
  3. ///
  4. /// These are used by ``View/onTapGesture(gesture:perform:)``.
  5. @MainActor
  6. public protocol TapGestures: Core {
  7. /// Wraps a view in a container that can receive tap gesture events.
  8. ///
  9. /// Some backends may not have to wrap the child, in which case they may
  10. /// just return the child as is.
  11. ///
  12. /// - Parameters:
  13. /// - child: The child to wrap.
  14. /// - gesture: The gesture to listen for.
  15. /// - Returns: A widget that can receive tap gesture events.
  16. func createTapGestureTarget(
  17. wrapping child: Widget,
  18. gesture: TapGesture
  19. ) -> Widget
  20. /// Update the tap gesture target with a new action.
  21. ///
  22. /// The new action replaces the old action.
  23. ///
  24. /// - Parameters:
  25. /// - tapGestureTarget: The tap gesture target to update.
  26. /// - gesture: The gesture to listen for.
  27. /// - environment: The current environment.
  28. /// - action: The action to perform when a tap gesture occurs.
  29. func updateTapGestureTarget(
  30. _ tapGestureTarget: Widget,
  31. gesture: TapGesture,
  32. environment: EnvironmentValues,
  33. action: @escaping () -> Void
  34. )
  35. }
  36. }