
Hold to Confirm
A press-and-hold button that sweeps a gradient and progress ring across the pill with rising haptic ticks, rewinds smoothly if you let go early and morphs into a success state when complete. Includes a destructive Hold to delete preset.
- button
- progress
- interaction
snippet.swift292 lines
4 files • Scroll to see all →
/// A press-and-hold button for actions that deserve a moment of intent.////// While your finger is down a gradient sweeps across the pill (and a ring/// fills around the icon) with haptic ticks that get stronger as it nears/// the end. Let go early and it rewinds smoothly from exactly where it was;/// hold to the end and it morphs into a success state.public struct HoldToConfirmButton: View { let title: String let systemImage: String var holdingTitle: String var successTitle: String var successImage: String var colors: [Color] var duration: Double var resetsAfterSuccess: Bool let action: () -> Void private enum Phase: Equatable { case idle, holding, rewinding, done } @State private var phase: Phase = .idle// ... (click "Show full code" to see more)Viewing: HoldToConfirm.swift•1 of 4