Files
workouts/Workouts/Views/Common/SecondsWheelRow.swift
T
rzen 9741b7d834 Pick rest time on a 1-second wheel
Replaces the 5-second Steppers in Settings and the routine editor's
custom-rest row with a shared SecondsWheelRow: the row shows the value
and tapping it expands an inline wheel (10-180s, 1s steps) beneath.
2026-07-16 19:44:22 -04:00

48 lines
1.3 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// 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()
}
}
}