Restore list selection and improve sidebar header clicks
This commit is contained in:
parent
f6ab43833c
commit
5a2eea1a3d
@ -50,11 +50,8 @@ struct ItemListColumnView<MenuContent: View>: View {
|
||||
.onDrop(of: [UTType.fileURL.identifier], isTargeted: $isDropTargeted, perform: dropAction)
|
||||
} else {
|
||||
List(items, selection: $selectedItemID) { item in
|
||||
ContentRowView(item: item)
|
||||
ContentRowView(item: item, dragProvider: dragProvider)
|
||||
.tag(item.id)
|
||||
.onDrag {
|
||||
dragProvider(item)
|
||||
}
|
||||
.contextMenu {
|
||||
itemContextMenu(item)
|
||||
}
|
||||
@ -143,10 +140,14 @@ private struct ItemListHeaderView: View {
|
||||
|
||||
private struct ContentRowView: View {
|
||||
let item: MinecraftContentItem
|
||||
let dragProvider: (MinecraftContentItem) -> NSItemProvider
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .center, spacing: 10) {
|
||||
ItemThumbnailView(iconURL: item.iconURL)
|
||||
.onDrag {
|
||||
dragProvider(item)
|
||||
}
|
||||
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text(item.displayName)
|
||||
@ -164,6 +165,14 @@ private struct ContentRowView: View {
|
||||
ProgressView()
|
||||
.controlSize(.small)
|
||||
}
|
||||
|
||||
Image(systemName: "square.and.arrow.up")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.tertiary)
|
||||
.help("Drag Out as Minecraft Package")
|
||||
.onDrag {
|
||||
dragProvider(item)
|
||||
}
|
||||
}
|
||||
.padding(.vertical, 2)
|
||||
.contentShape(Rectangle())
|
||||
|
||||
@ -74,6 +74,8 @@ struct SourcesSidebarView: View {
|
||||
|
||||
@ViewBuilder
|
||||
private func sourceSectionRows(for source: MinecraftSource) -> some View {
|
||||
let sourceFilters = filters(source)
|
||||
|
||||
SourceHeaderRow(
|
||||
source: source,
|
||||
isSelected: selection == .source(sourceID: source.id),
|
||||
@ -96,7 +98,7 @@ struct SourcesSidebarView: View {
|
||||
}
|
||||
}
|
||||
|
||||
ForEach(filters(source)) { filter in
|
||||
ForEach(sourceFilters) { filter in
|
||||
SidebarFilterRow(filter: filter, isIndented: true)
|
||||
.tag(filter.selection as SidebarSelection?)
|
||||
}
|
||||
@ -154,6 +156,7 @@ private struct SourceHeaderRow: View {
|
||||
@State private var isHovering = false
|
||||
|
||||
var body: some View {
|
||||
Button(action: onSelect) {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: headerSymbolName)
|
||||
.font(.system(size: 14, weight: .semibold))
|
||||
@ -178,11 +181,12 @@ private struct SourceHeaderRow: View {
|
||||
.frame(width: 24, height: 24)
|
||||
}
|
||||
}
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 8)
|
||||
.appSidebarRowSurface(isHighlighted: isHovering && !isSelected)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture(perform: onSelect)
|
||||
.onHover { isHovering = $0 }
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user