|
@@ -10,22 +10,25 @@ import SwiftUI
|
|
|
struct TagBarView: View {
|
|
struct TagBarView: View {
|
|
|
@Binding var tags: [Tag]
|
|
@Binding var tags: [Tag]
|
|
|
@State private var active: String = ""
|
|
@State private var active: String = ""
|
|
|
|
|
+ @FocusState private var isFocused: Bool
|
|
|
|
|
|
|
|
- var body: some View {
|
|
|
|
|
- HStack {
|
|
|
|
|
- ForEach($tags) { tag in
|
|
|
|
|
- TextField("", text: tag.id)
|
|
|
|
|
- .onSubmit {
|
|
|
|
|
- tags.removeAll(where: { $0.id.isEmpty })
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- TextField("Tag", text: $active)
|
|
|
|
|
- .onSubmit {
|
|
|
|
|
- tags.append(Tag(id: active))
|
|
|
|
|
- active = ""
|
|
|
|
|
|
|
+ var body: some View {
|
|
|
|
|
+ HStack {
|
|
|
|
|
+ ForEach($tags) { tag in
|
|
|
|
|
+ TextField("", text: tag.id)
|
|
|
|
|
+ .focused($isFocused)
|
|
|
|
|
+ .onChange(of: isFocused) {
|
|
|
|
|
+ tags.removeAll(where: { $0.id.isEmpty })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ .scaledToFit()
|
|
|
|
|
+ TextField("Tag", text: $active)
|
|
|
|
|
+ .onSubmit {
|
|
|
|
|
+ tags.append(Tag(id: active))
|
|
|
|
|
+ active = ""
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#Preview {
|
|
#Preview {
|