| 1234567891011121314151617181920212223242526272829303132333435 |
- //
- // TagBarView.swift
- // Todos
- //
- // Created by Sam Jaffe on 2/28/26.
- //
- import SwiftUI
- struct TagBarView: View {
- @Binding var tags: [String]
- @State private var active: String = ""
- var body: some View {
- HStack {
- TextField("Tag", text: $active)
- .onSubmit {
- tags.append(active)
- active = ""
- }
- ForEach($tags, id: \.self) { tag in
- TextField("", text: tag)
- .onSubmit {
- tags.removeAll(where: { $0.isEmpty })
- }
- .scaledToFit()
- }
- }
- }
- }
- #Preview {
- @Previewable @State var tags = Array<String>()
- TagBarView(tags: $tags)
- }
|