|
|
@@ -8,20 +8,20 @@
|
|
|
import SwiftUI
|
|
|
|
|
|
struct TagBarView: View {
|
|
|
- @Binding var tags: [String]
|
|
|
+ @Binding var tags: [Tag]
|
|
|
@State private var active: String = ""
|
|
|
|
|
|
var body: some View {
|
|
|
HStack {
|
|
|
- ForEach($tags, id: \.self) { tag in
|
|
|
- TextField("", text: tag)
|
|
|
+ ForEach($tags) { tag in
|
|
|
+ TextField("", text: tag.id)
|
|
|
.onSubmit {
|
|
|
- tags.removeAll(where: { $0.isEmpty })
|
|
|
+ tags.removeAll(where: { $0.id.isEmpty })
|
|
|
}
|
|
|
}
|
|
|
TextField("Tag", text: $active)
|
|
|
.onSubmit {
|
|
|
- tags.append(active)
|
|
|
+ tags.append(Tag(id: active))
|
|
|
active = ""
|
|
|
}
|
|
|
}
|
|
|
@@ -29,6 +29,6 @@ struct TagBarView: View {
|
|
|
}
|
|
|
|
|
|
#Preview {
|
|
|
- @Previewable @State var tags = Array<String>()
|
|
|
+ @Previewable @State var tags = Array<Tag>()
|
|
|
TagBarView(tags: $tags)
|
|
|
}
|