import SwiftUI struct CollectionsView: View { @Bindable var viewModel: BookmarksViewModel @Environment(\.dismiss) private var dismiss var body: some View { NavigationStack { Group { if viewModel.isGeneratingCollections { VStack(spacing: 16) { ProgressView() Text("Building smart collections…") .font(PaperType.meta) .foregroundStyle(Paper.secondary) } .frame(maxWidth: .infinity, maxHeight: .infinity) } else if viewModel.smartCollections.isEmpty { PaperEmptyState( title: "No Collections Yet", systemImage: "sparkles", message: "Tap \"Smart Collections\" to group your bookmarks by topic." ) } else { List(viewModel.smartCollections) { collection in Section { let items = viewModel.bookmarks.filter { collection.bookmarkIds.contains($0.id) } ForEach(items) { bookmark in LibraryListRow(bookmark: bookmark) .listRowInsets(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20)) .listRowBackground(Paper.sheet) .listRowSeparatorTint(Paper.rule.opacity(0.5)) } } header: { VStack(alignment: .leading, spacing: 2) { Text(collection.name) .font(PaperType.heading) .foregroundStyle(Paper.ink) if !collection.description.isEmpty { Text(collection.description) .font(PaperType.meta) .foregroundStyle(Paper.tertiary) } } .padding(.vertical, 4) } } .listStyle(.plain) } } .paperSurface() .navigationTitle("Smart Collections") .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .topBarLeading) { Button { Task { await viewModel.generateSmartCollections() } } label: { Image(systemName: "arrow.clockwise") } .disabled(viewModel.isGeneratingCollections) } ToolbarItem(placement: .topBarTrailing) { Button("Done") { dismiss() } .font(PaperType.label) .tint(Paper.accent) } } } } }