Add the Library tab: reorderable routines pane and searchable grouped exercises pane

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
This commit is contained in:
2026-07-15 10:58:57 -04:00
parent 16b61946d5
commit 586804f771
6 changed files with 285 additions and 151 deletions
+48
View File
@@ -0,0 +1,48 @@
//
// 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)
}
}
}
}
}