feat(sidebar): add a Home row above the collections list
Home was only reachable via the toolbar house icon — added a pinned row at the top of the sidebar (matching a collection row's style, highlighted when active) so it's a first-class nav target alongside collections rather than toolbar-only.
This commit is contained in:
@@ -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<OutlineCollection?>,
|
||||
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 {
|
||||
|
||||
@@ -197,6 +197,8 @@ struct ContentView_macOS: View {
|
||||
selectedCollection: $selectedCollection,
|
||||
selectedDocumentID: documentPath.last?.id,
|
||||
externalRefreshToken: documentsChangedToken,
|
||||
isShowingHome: isShowingHome,
|
||||
onSelectHome: goHome,
|
||||
onSelectDocument: selectDocumentChain,
|
||||
onSearchInCollection: searchInCollection
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user