// // 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) } } } } }