import FoldFormat import Models import SwiftUI /// The shipped models by title. Choosing one opens it at step 1. struct ModelListView: View { private let models: [FoldFile] @State private var path: [Int] init() { let models = (try? ModelLibrary.all()) ?? [] self.models = models let cup = ScreenshotScene.requested?.pose == nil ? nil : models.firstIndex { $0.fileTitle == "Cup" } _path = State(initialValue: cup.map { [$0] } ?? []) } var body: some View { NavigationStack(path: $path) { Group { if models.isEmpty { ContentUnavailableView("No Models", systemImage: "square.dashed") } else { List(models.indices, id: \.self) { i in NavigationLink(models[i].fileTitle ?? "Untitled", value: i) } } } .navigationTitle("Models") .navigationDestination(for: Int.self) { i in StepView(model: models[i], step: ScreenshotScene.requested?.pose?.step ?? 1) } } } }