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.
48 lines
1.3 KiB
Swift
48 lines
1.3 KiB
Swift
//
|
||
// 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 10–180s 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()
|
||
}
|
||
}
|
||
}
|