HomeiOS Developmentios - Why the icons can not change instantly?

ios – Why the icons can not change instantly?


These are the three views in my to do listing mission.
I need to save knowledge, so customers’ to do listing will nonetheless be there after they launch the app.
However every time I click on on the icon “examine.circle’ or “circle”, they can not change instantly. They are going to change after I launch the app once more.
I do not know the way to let icon switched instantly.
Thanks upfront!!!

@EnvironmentObject var listViewModel: ListViewModel

@State var newText: String = ""

@State var detents: PresentationDetent = .medium

@State var showSheet: Bool = false

static var item1 = ItemModel(title: "First", isCompleted: false)

var physique: some View {    

    NavigationView {
            Checklist {
                ForEach(listViewModel.objects) { merchandise in
                    ListRowView(merchandise: merchandise)
                        .onTapGesture {
                            listViewModel.updateItem(merchandise: merchandise). -> *
                        }
                }
                .onDelete(carry out: listViewModel.delete)
                .onMove(carry out: listViewModel.moveItem)
            }
            .navigationTitle("To Do Checklist")
            .navigationBarItems(
                main: EditButton(),
                trailing: Button(
                    motion: {
                        showSheet.toggle()
                    }, label: {
                    Textual content("Add")
                })
                .sheet(
                    isPresented: $showSheet,
                    content material: {
                        SecondScreen()
                            .presentationDetents([.height(500)])
                }
            ))
            }
    }  



func saveItems() {
   if let encodedData = attempt? JSONEncoder().encode(objects) {
        UserDefaults.commonplace.set(encodedData, forKey: itemsKey)
    }





let id: String
let title: String
var isCompleted: Bool

init(id: String = UUID().uuidString, title: String, isCompleted: Bool) {
    self.id = id
    self.title = title
    self.isCompleted = isCompleted
}

func updateCompletion() -> ItemModel {.  -> *
    return ItemModel(id: id, title: title, isCompleted: !isCompleted)
}

After I click on on the icon, I need to let the icon change instantly.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments