SwiftUI hold-to-confirm button: onLongPressGesture plus an accessibility action
A press-and-hold primary button needs no timers: put .onLongPressGesture(minimumDuration: d, maximumDistance: 60) { commit() } onPressingChanged: { isHolding = $0 } on the label, and draw progress as an overlay with .scaleEffect(x: isHolding ? 1 : 0, anchor: .leading) animated .linear(duration: d) while holding and a short ease-out on release, clipped to the button's shape. A plain tap then does nothing and letting go early cancels by itself. Holding is impossible with VoiceOver and Switch Control, so add .accessibilityAddTraits(.isButton) and .accessibilityAction { commit() } so activating it acts at once. When driving it from simulator automation, a tap with a duration longer than d triggers it; taps sent while a sheet is still dismissing are silently dropped, so wait about a second and a half after closing a sheet before the next tap.