feat: add GroupFilterViewModel and GroupFilterView sidebar
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WYqycDFsynHH9VnnK7LNSf
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import SwiftUI
|
||||
import MyPassCore
|
||||
|
||||
struct GroupFilterView: View {
|
||||
@ObservedObject var vm: GroupFilterViewModel
|
||||
let rootGroup: MyPassCore.Group
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
if !vm.selectedGroupIds.isEmpty {
|
||||
Button("Clear Filter", action: vm.clear)
|
||||
}
|
||||
GroupFilterNode(group: rootGroup, vm: vm)
|
||||
}
|
||||
.navigationTitle("Groups")
|
||||
}
|
||||
}
|
||||
|
||||
private struct GroupFilterNode: View {
|
||||
let group: MyPassCore.Group
|
||||
@ObservedObject var vm: GroupFilterViewModel
|
||||
|
||||
var body: some View {
|
||||
if group.subgroups.isEmpty {
|
||||
row
|
||||
} else {
|
||||
DisclosureGroup {
|
||||
ForEach(group.subgroups) { sub in
|
||||
GroupFilterNode(group: sub, vm: vm)
|
||||
}
|
||||
} label: {
|
||||
row
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var row: some View {
|
||||
Button {
|
||||
vm.toggle(group)
|
||||
} label: {
|
||||
HStack {
|
||||
Image(systemName: vm.isSelected(group) ? "checkmark.circle.fill" : "circle")
|
||||
.foregroundStyle(vm.isSelected(group) ? Color.accentColor : Color.secondary)
|
||||
Label(group.name, systemImage: "folder")
|
||||
}
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user