Your Name (name)
Your ID for Card (id)
QR Code or Barcode? (qrcode Toggle)
Card Name (cname)
Code Block import SwiftUI struct Card: Identifiable { let id = UUID() let title: String } struct CardsView: View { @State private var editMode = EditMode.inactive @State private var cards: [Card] = [] private static var count = 0 var body: some View { NavigationView { List { ForEach(cards) { cards in NavigationLink(destination: CardFullView(cname: "Moore Lunch")) { CardRow(cname: "Lunch", name: "John Doe", id: "123456") } } .onDelete(perform: onDelete) .onMove(perform: onMove) } .navigationTitle("Cards") .toolbar { ToolbarItem(placement: .navigationBarLeading) { EditButton() } ToolbarItem(placement: .navigationBarTrailing) { NavigationLink( destination: AddView(), label: { Image(systemName: "plus") }) } } .environment(\.editMode, $editMode) } } private var addButton: some View { switch editMode { case .inactive: return AnyView(Button(action: onAdd) { Image(systemName: "plus") }) default: return AnyView(EmptyView()) } } func onAdd() { cards.append(Card(title: "Card #\(Self.count)")) Self.count += 1 } private func onDelete(offsets: IndexSet) { cards.remove(atOffsets: offsets) } private func onMove(source: IndexSet, destination: Int) { cards.move(fromOffsets: source, toOffset: destination) } } struct CardsView_Previews: PreviewProvider { static var previews: some View { CardsView() } }
...and my AddView:
Code Block import SwiftUI struct CardFullView: View { let cname: String var body: some View { NavigationView { CardView(name: "John Doe", id: "123456") .navigationTitle(cname) .navigationBarTitleDisplayMode(.inline) } } } struct CardFullView_Previews: PreviewProvider { static var previews: some View { CardFullView(cname: "Lunch") } }
CardRow shows an HStack, consisting of a generated QR Code or Barcode, a VStack with a title showing cname, a headline showing name, and a subheadline showing id.
I want to pass the value of the TextFields into the CardRows.
Thanks for clarifying and sorry for missing the reply.Sorry for the late reply.
Most parts get cleared, but it seems you have touched your code since then.
There's another bug happening and I do not understand what this means or why you do not want it.
I think it's time for you to start your new thread to solve such another thing.I figured out a way to show the cardInfo data in the list, but it's not the way I want it
Please do not forget to include all the latest code when starting a new thread.