Files
Outpost/Outpost/Features/Collections/CollectionListContent.swift
T
Puranjay Savar Mattas 6dd632bb97 feat(collections): add collections and documents browsing
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.
2026-08-14 00:24:07 +01:00

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