Adjust rest time with a 1-second stepper instead of the wheel

The wheel row lands back on a Stepper (shared SecondsStepperRow), but
keeps the fine 1-second step; holding a stepper button auto-repeats
with acceleration, so the 10-180s range still traverses quickly.
This commit is contained in:
2026-07-16 20:10:30 -04:00
parent cbdf02bca7
commit 62ca446136
5 changed files with 33 additions and 50 deletions
@@ -0,0 +1,30 @@
//
// SecondsStepperRow.swift
// Workouts
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import SwiftUI
/// A Form row for adjusting a seconds value with a stepper in 1-second steps
/// fine-grained (the old 5-second step overshot), and holding a stepper button
/// auto-repeats with acceleration, so the 10180s range still traverses quickly.
/// Used for the rest-time settings in Settings and the routine editor.
struct SecondsStepperRow: View {
let title: String
let range: ClosedRange<Int>
@Binding var seconds: Int
var body: some View {
Stepper(value: $seconds, in: range, step: 1) {
HStack {
Text(title)
Spacer()
Text("\(seconds)s")
.monospacedDigit()
.foregroundStyle(.secondary)
}
}
}
}
@@ -1,47 +0,0 @@
//
// SecondsWheelRow.swift
// Workouts
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//
import SwiftUI
/// A Form row for picking a seconds value on an inline wheel: the row shows the
/// current value; tapping it expands (or collapses) a wheel beneath with 1-second
/// steps. Used for the rest-time settings, where the old 5-second stepper was too
/// coarse and too slow to traverse a 10180s range.
struct SecondsWheelRow: View {
let title: String
let range: ClosedRange<Int>
@Binding var seconds: Int
@State private var expanded = false
var body: some View {
Button {
withAnimation { expanded.toggle() }
} label: {
HStack {
Text(title)
.foregroundStyle(.primary)
Spacer()
Text("\(seconds)s")
.monospacedDigit()
.foregroundStyle(expanded ? AnyShapeStyle(.tint) : AnyShapeStyle(.secondary))
}
.contentShape(Rectangle())
}
.buttonStyle(.plain)
if expanded {
Picker(title, selection: $seconds) {
ForEach(range, id: \.self) { s in
Text("\(s)s").tag(s)
}
}
.pickerStyle(.wheel)
.labelsHidden()
}
}
}