Files
Outpost/Outpost/Features/Collections/CollectionTreeRow.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

50 lines
1.5 KiB
Swift

#if os(macOS)
import SwiftUI
import OutlineKit
struct CollectionTreeRow: View {
let apiClient: OutlineAPIClient
let collection: OutlineCollection
let isExpanded: Bool
let isSelected: Bool
let onToggle: () -> Void
let onSelectDocument: (OutlineDocument) -> Void
var body: some View {
VStack(alignment: .leading, spacing: 0) {
Button(action: onToggle) {
HStack(spacing: 6) {
Image(systemName: "chevron.right")
.font(.caption2.weight(.semibold))
.foregroundStyle(.secondary)
.rotationEffect(.degrees(isExpanded ? 90 : 0))
.frame(width: 12)
CollectionRowView(collection: collection)
Spacer(minLength: 0)
}
.padding(.vertical, 4)
.padding(.horizontal, 6)
.contentShape(Rectangle())
.background(
isSelected ? Color.accentColor.opacity(0.15) : Color.clear,
in: RoundedRectangle(cornerRadius: 6)
)
}
.buttonStyle(.plain)
.animation(.easeInOut(duration: 0.15), value: isExpanded)
if isExpanded {
CollectionDocumentsOutline(
apiClient: apiClient,
collection: collection,
onSelectDocument: onSelectDocument
)
.padding(.leading, 18)
}
}
}
}
#endif