Skip to content

Latest commit

 

History

History
33 lines (27 loc) · 1.06 KB

README.md

File metadata and controls

33 lines (27 loc) · 1.06 KB

ConfirmationDialog

Like an alertSheet from UIKit. Multibutton select at the bottom of the screen.

struct ContentView: View {
    @State private var showingConfirmation = false
    @State private var backgroundColor = Color.white

    var body: some View {
        Text("Hello, World!")
            .frame(width: 300, height: 300)
            .background(backgroundColor)
            .onTapGesture {
                showingConfirmation = true
            }
            .confirmationDialog("Change background", isPresented: $showingConfirmation) {
                Button("Red") { backgroundColor = .red }
                Button("Green") { backgroundColor = .green }
                Button("Blue") { backgroundColor = .blue }
                Button("Cancel", role: .cancel) { }
            } message: {
                Text("Select a new color")
            }
    }
}

Links that help