
Slide To Confirm
Drag the knob to confirm: the track morphs into a circle, spins while your async work runs, then draws a checkmark. Rubber-band resistance and haptics included.
- control
- gesture
- success
snippet.swift219 lines
6 files • Scroll to see all →
/// The mobile-native confirm: drag the knob to the end and the whole track/// morphs into a circle, spins while your async work runs, then draws a/// checkmark. Releasing early springs the knob back with a rubber-band feel.public struct SlideToConfirm: View { let title: String var tint: Color var resetsAfterSuccess: Bool let onConfirm: () async -> Void private enum Phase: Equatable { case idle, loading, done } @State private var phase: Phase = .idle @State private var drag: CGFloat = 0 @State private var width: CGFloat = 0 private let height: CGFloat = 64 private let inset: CGFloat = 5 private let threshold: CGFloat = 0.9 public init(// ... (click "Show full code" to see more)Viewing: SlideToConfirm.swift•1 of 6