A fourth tab promotes routine and exercise management out of Settings. LibraryView switches between two segments on one navigation stack. The routines pane (RoutineListView reborn as RoutinesLibraryView) sorts by the user's order, gains drag-to-reorder writing only changed orders, swipe actions for duplicate/edit/delete, a Starter badge on bundled seeds, and a last-trained caption. The exercises pane groups the library into curated category sections searchable by name, category, or muscle. Claude-Session: https://claude.ai/code/session_01H8VxUX4ckjU3vRF5M4L5FV
49 lines
1.5 KiB
Swift
49 lines
1.5 KiB
Swift
//
|
|
// LibraryView.swift
|
|
// Workouts
|
|
//
|
|
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
/// The Library tab's root: a segmented switch between the Routines and Exercises
|
|
/// libraries, both pushing onto one shared `NavigationStack`. Kept as a single tab
|
|
/// with a segmented control (rather than two separate tabs) so both libraries read
|
|
/// as one destination with two views, sharing a nav bar; each segment's view
|
|
/// contributes its own toolbar items (+, EditButton) and `.searchable` so those only
|
|
/// appear while that segment is showing.
|
|
struct LibraryView: View {
|
|
private enum Segment: String, CaseIterable {
|
|
case routines = "Routines"
|
|
case exercises = "Exercises"
|
|
}
|
|
|
|
@State private var segment: Segment = .routines
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
Group {
|
|
switch segment {
|
|
case .routines:
|
|
RoutinesLibraryView()
|
|
case .exercises:
|
|
ExerciseLibraryView()
|
|
}
|
|
}
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbar {
|
|
ToolbarItem(placement: .principal) {
|
|
Picker("Library Section", selection: $segment) {
|
|
ForEach(Segment.allCases, id: \.self) { segment in
|
|
Text(segment.rawValue).tag(segment)
|
|
}
|
|
}
|
|
.pickerStyle(.segmented)
|
|
.frame(maxWidth: 240)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|