I am coming to a problem where I am trying to implement an alert view to show when the image is wrong or something and when the submit button is pressed to show an alert view. As you see in my code below that I am trying to implement an alert view inside my if condition? is it possible thanks for the help.
here is my code:
@State private var showsAlert = false
func uploadImage(image:UIImage){
if let imageData = image.jpegData(compressionQuality: 1){
let storage = Storage.storage()
f let imageName = "image1"
let folderName = "folder1"
let path = "\(folderName)/\(imageName)"
storage.reference(withPath: path).putData(imageData, metadata: nil){
(_, err) in
if let err = err {
print("an error has occurred - \(err.localizedDescription)")
// .alert(isPresented: $showsAlert) {
// Alert(title: Text("Photo Upload Error"), message: Text("an error has occurred - \(err.localizedDescription)"), dismissButton: .default(Text("OK")))
// }
} else {
print("Your photos have been successfully uploaded. Keep a lookout for your photos in our social media posts!")
// .alert(isPresented: $showsAlert) {
//
// Alert(title: Text("Success!"), message: Text("Your photos have been successfully uploaded. Keep a lookout for your photos in our social media posts!"), dismissButton: .default(Text("OK")))
//
// }
}
}
} else {
print("coldn't unwrap/case image to data")
}
}