import SwiftUI
struct ContentView: View {
@State var isError = false
var body: some View {
Button {
isError = true
} label: {
Text("CHMO")
.background(Color.orange)
.cornerRadius(10)
}
.confirmationDialog("are you sure", isPresented: $isError) {
Alert(title: Text("Gooo"), message: Text("No More"), primaryButton: .default(Text("Yes")), secondaryButton: .cancel(Text("No")))
}
VStack {
Image(systemName: "globe")
.imageScale(.medium)
.foregroundStyle(.brown)
Text("Hello, world!")
}
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
in this part of the code it gives an error:
.confirmationDialog(“are you sure”, isPresented: $isError) {
Alert(title: Text(“Gooo”), message: Text(“No More”), primaryButton: .default(Text(“Yes”)), secondaryButton: .cancel(Text(“No”)))
}
Static method ‘buildExpression’ requires that ‘Alert’ conform to ‘View’
I need to understand how to work with .confirmationdialog
Fix this problem PLS
New contributor
Даниил Волошин is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.