macOS: expandable/collapsible sidebar tree (collections.list, with nested documents.list per expanded collection) driving a detail pane. iOS: flat collection list pushing to a document list. Both share row views and per-platform ContentView selectors, matching the AuthView pattern.
43 lines
1.5 KiB
Swift
43 lines
1.5 KiB
Swift
import SwiftUI
|
|
import OutlineKit
|
|
|
|
struct CollectionListContent: View {
|
|
var viewModel: CollectionsViewModel
|
|
let onSelect: (OutlineCollection) -> Void
|
|
|
|
var body: some View {
|
|
Group {
|
|
if viewModel.isLoading && viewModel.collections.isEmpty {
|
|
ProgressView()
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
} else if let errorMessage = viewModel.errorMessage, viewModel.collections.isEmpty {
|
|
ContentUnavailableView {
|
|
Label("Couldn't Load Collections", systemImage: "exclamationmark.triangle")
|
|
} description: {
|
|
Text(errorMessage)
|
|
} actions: {
|
|
Button("Retry") {
|
|
Task { await viewModel.load() }
|
|
}
|
|
}
|
|
} else if viewModel.collections.isEmpty {
|
|
ContentUnavailableView(
|
|
"No Collections",
|
|
systemImage: "folder",
|
|
description: Text("Collections you have access to will appear here.")
|
|
)
|
|
} else {
|
|
List(viewModel.collections) { collection in
|
|
Button {
|
|
onSelect(collection)
|
|
} label: {
|
|
CollectionRowView(collection: collection)
|
|
}
|
|
.buttonStyle(.plain)
|
|
}
|
|
}
|
|
}
|
|
.task { await viewModel.load() }
|
|
}
|
|
}
|