35 lines
1.0 KiB
Swift
35 lines
1.0 KiB
Swift
import SwiftUI
|
|
|
|
struct FilterChip: Identifiable {
|
|
let id = UUID()
|
|
let label: String
|
|
var isSelected: Bool = false
|
|
}
|
|
|
|
struct FilterChipsView: View {
|
|
@Binding var chips: [FilterChip]
|
|
|
|
var body: some View {
|
|
ScrollView(.horizontal, showsIndicators: false) {
|
|
HStack(spacing: 8) {
|
|
ForEach($chips) { $chip in
|
|
Button {
|
|
chip.isSelected.toggle()
|
|
} label: {
|
|
Text(chip.label)
|
|
.font(.caption.weight(.medium))
|
|
.padding(.horizontal, 12)
|
|
.padding(.vertical, 6)
|
|
.background(
|
|
chip.isSelected ? Color.accentColor : Color(.systemGray5),
|
|
in: Capsule()
|
|
)
|
|
.foregroundStyle(chip.isSelected ? .white : .primary)
|
|
}
|
|
}
|
|
}
|
|
.padding(.horizontal)
|
|
}
|
|
}
|
|
}
|