Highlight selected source rows

This commit is contained in:
John Burwell 2026-06-03 11:42:14 -05:00
parent f5dfec00a3
commit 0e52db80df

View File

@ -124,13 +124,14 @@ struct SourcesSidebarView: View {
SourceHeaderRow( SourceHeaderRow(
source: source, source: source,
isSelected: selection == .source(sourceID: source.id),
onSelect: { onSelect: {
selection = .source(sourceID: source.id) selection = .source(sourceID: source.id)
} }
) )
.tag(SidebarSelection.source(sourceID: source.id) as SidebarSelection?) .tag(SidebarSelection.source(sourceID: source.id) as SidebarSelection?)
.listRowSeparator(.hidden) .listRowSeparator(.hidden)
.listRowInsets(EdgeInsets(top: 6, leading: 0, bottom: 0, trailing: 0)) .listRowInsets(EdgeInsets(top: 4, leading: 8, bottom: 4, trailing: 8))
.contextMenu { .contextMenu {
Button("Rescan \"\(source.displayName)\"") { Button("Rescan \"\(source.displayName)\"") {
rescanSourceAction(source) rescanSourceAction(source)
@ -246,6 +247,7 @@ private struct SidebarSourcesSectionHeaderView: View {
private struct SourceHeaderRow: View { private struct SourceHeaderRow: View {
let source: MinecraftSource let source: MinecraftSource
let isSelected: Bool
let onSelect: () -> Void let onSelect: () -> Void
var body: some View { var body: some View {
@ -273,8 +275,14 @@ private struct SourceHeaderRow: View {
} }
} }
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
.padding(.leading, 5) .padding(.horizontal, 8)
.padding(.vertical, 6) .padding(.vertical, 5)
.background {
if isSelected {
RoundedRectangle(cornerRadius: 6, style: .continuous)
.fill(Color.accentColor.opacity(0.18))
}
}
.contentShape(Rectangle()) .contentShape(Rectangle())
.onTapGesture(perform: onSelect) .onTapGesture(perform: onSelect)
} }