DoublePinch adds double-pinch support to SwiftUI Buttons on watchOS.
On supported Apple Watch models running watchOS 11 or newer, it uses the system hand gesture shortcut for the primary action. On earlier supported devices, it falls back to an accessibility quick action so the same button can still participate in a double-pinch driven flow.
- watchOS 9.0+
- Xcode 16+
- Swift 6
Add the package from the repository URL:
dependencies: [
.package(url: "https://github.com/superturboryan/DoublePinch.git", from: "1.0.0"),
]Then add DoublePinch to your target dependencies:
.target(
name: "MyWatchApp",
dependencies: [
.product(name: "DoublePinch", package: "DoublePinch"),
]
)Import the package and apply .doublePinch() to a SwiftUI Button:
import DoublePinch
import SwiftUI
struct ContentView: View {
var body: some View {
Button("Start Workout") {
startWorkout()
}
.doublePinch()
}
private func startWorkout() {
// Trigger your primary action here.
}
}DoublePinch exposes these configuration options through DoublePinchMode:
.automatic.accessibilityQuickAction.doubleTapGestureon watchOS 11+
On watchOS 11 and newer, .automatic upgrades to the system double-tap gesture when the hardware supports it. Otherwise it uses the accessibility quick action fallback.
In most cases, .automatic is the right default.
If you want to force the fallback behavior:
Button("Confirm") {
confirm()
}
.doublePinch(.accessibilityQuickAction)If you specifically want to choose the mode yourself, provide an explicit fallback:
if #available(watchOS 11.0, *) {
Button("Pay") {
submitPayment()
}
.doublePinch(.doubleTapGesture)
} else {
Button("Pay") {
submitPayment()
}
.doublePinch(.accessibilityQuickAction)
}Button.doublePinch()attaches the package's gesture-aware view modifier..automaticchooses betweenhandGestureShortcut(.primaryAction)andaccessibilityQuickAction(style: .outline)based on OS support and device capability.- Explicit modes do exactly what you request, so use
.doubleTapGestureonly when you want the watchOS 11 gesture path. - The current implementation reuses the button's primary action by introspecting the underlying
Button, so it is worth validating on the watchOS versions and button styles you ship.
DoublePinch is available under the MIT license. See LICENSE.txt.