## Slider with snapping detents

- Use case: A slider that snaps to marked stops (0 / 25 / 50 / 75 / 100) and clicks at each detent.
- Feel: Smooth glide between stops, a rigid micro-click when snapping into one — like a physical fader with notches.
- APIs: UIImpactFeedbackGenerator(style: .rigid), DragGesture
- Minimum OS: iOS 13+

### SwiftUI

```swift
import SwiftUI

struct DetentSlider: View {
    @State private var value: Double = 50
    @State private var lastDetent: Double? = nil
    let detents: [Double] = [0, 25, 50, 75, 100]
    private let click = UIImpactFeedbackGenerator(style: .rigid)

    var body: some View {
        Slider(value: $value, in: 0...100)
            .onChange(of: value) { _, newValue in
                // Which detent are we within snapping range of?
                let near = detents.first { abs($0 - newValue) < 2.5 }
                if let near, near != lastDetent {
                    lastDetent = near
                    value = near                       // snap
                    click.impactOccurred(intensity: 0.55)
                } else if near == nil {
                    lastDetent = nil                   // left the detent
                }
            }
    }
}
```

### Notes
- Guard with lastDetent so hovering inside the snap zone produces exactly one click, not a stream.
- For continuous (non-snapping) sliders, tick only at the min and max ends instead.
