I am a little confused, I try to display a pop-up in my View when my function is true otherwise continue but I do not understand how to do it I am lost between the different ways of doing. I tried several things but something escapes me.
Edit: The project is based on SwiftUI and the popup as to be displayed in a SwiftUI View, the function is in a class returning an ObservableObject. The function is called from a SwiftUI View from a button.
get_deliveries.swift -> into a class delivViewModel:ObservableObject
func cancelDeliv(delivID: String) {
let delivRef = db.collection("av_deliveries").document(delivID)
let isDemain = Date().dayAfter.toString()
delivRef.getDocument { (document, error) in
if let document = document, document.exists {
let property = document.get("when")
if isDemain == property as! String {
// Print a pop-up error
} else {
delivRef.updateData([
"taken": false,
"taken_by": ""
]) { err in
if let err = err {
print("Error updating document: \(err)")
} else {
print("Document successfully updated")
}
}
}
}
}
}