diff --git a/Outpost/Features/Collections/CollectionsTreeView.swift b/Outpost/Features/Collections/CollectionsTreeView.swift index 941801a..013455d 100644 --- a/Outpost/Features/Collections/CollectionsTreeView.swift +++ b/Outpost/Features/Collections/CollectionsTreeView.swift @@ -11,6 +11,8 @@ struct CollectionsTreeView: View { /// somewhere with no direct handle on the sidebar row it belongs /// under — see the identical parameter on `CollectionDocumentsOutline`. let externalRefreshToken: Int + let isShowingHome: Bool + let onSelectHome: () -> Void let onSelectDocument: (OutlineCollection, [OutlineDocument]) -> Void let onSearchInCollection: (OutlineCollection) -> Void @@ -19,6 +21,8 @@ struct CollectionsTreeView: View { selectedCollection: Binding, selectedDocumentID: String?, externalRefreshToken: Int, + isShowingHome: Bool, + onSelectHome: @escaping () -> Void, onSelectDocument: @escaping (OutlineCollection, [OutlineDocument]) -> Void, onSearchInCollection: @escaping (OutlineCollection) -> Void ) { @@ -26,6 +30,8 @@ struct CollectionsTreeView: View { _selectedCollection = selectedCollection self.selectedDocumentID = selectedDocumentID self.externalRefreshToken = externalRefreshToken + self.isShowingHome = isShowingHome + self.onSelectHome = onSelectHome self.onSelectDocument = onSelectDocument self.onSearchInCollection = onSearchInCollection } @@ -37,6 +43,7 @@ struct CollectionsTreeView: View { Task { await viewModel.load() } } } + homeRow content } .task { @@ -48,6 +55,32 @@ struct CollectionsTreeView: View { } } + /// Pinned above the collections list, not inside the scroll region — + /// Home isn't a collection, so it doesn't belong in `viewModel.collections` + /// or compete with them for scroll space. + private var homeRow: some View { + Button(action: onSelectHome) { + HStack(spacing: 6) { + Image(systemName: "house.fill") + .font(.callout) + .foregroundStyle(.secondary) + Text("Home") + .font(.body) + Spacer(minLength: 0) + } + .padding(.vertical, 4) + .padding(.horizontal, 6) + .contentShape(Rectangle()) + .background( + isShowingHome ? Color.accentColor.opacity(0.15) : Color.clear, + in: RoundedRectangle(cornerRadius: 6) + ) + } + .buttonStyle(.plain) + .padding(.horizontal, 8) + .padding(.top, 4) + } + @ViewBuilder private var content: some View { Group { diff --git a/Outpost/Features/Collections/ContentView_macOS.swift b/Outpost/Features/Collections/ContentView_macOS.swift index 89595fe..676f2e4 100644 --- a/Outpost/Features/Collections/ContentView_macOS.swift +++ b/Outpost/Features/Collections/ContentView_macOS.swift @@ -197,6 +197,8 @@ struct ContentView_macOS: View { selectedCollection: $selectedCollection, selectedDocumentID: documentPath.last?.id, externalRefreshToken: documentsChangedToken, + isShowingHome: isShowingHome, + onSelectHome: goHome, onSelectDocument: selectDocumentChain, onSearchInCollection: searchInCollection )