Skip to content

Commit

Permalink
修复点击目录无法展开子项问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ming1016 committed Nov 19, 2024
1 parent f6a2e1e commit 139a11d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion SwiftPamphletApp/Guide/View/GuideListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ struct GuideListView: View {
}
} label: {
ItemRow(item: item, bookmarks: bookmarks)
.tag(item)
.contentShape(Rectangle())
.onTapGesture {
// 点击目录时只切换展开状态
expandedItems.toggle(item.t)
}
}
} else {
// 只有非目录项才可选择
ItemRow(item: item, bookmarks: bookmarks)
.tag(item)
}
Expand Down Expand Up @@ -218,3 +223,13 @@ struct L: Hashable, Identifiable {
var icon: String = ""
var sub: [L]?
}

extension Set {
mutating func toggle(_ element: Element) {
if contains(element) {
remove(element)
} else {
insert(element)
}
}
}

0 comments on commit 139a11d

Please sign in to comment.