Just add a state to your view like this:
@State var alertData: AlertData? = nil
and add the modifier to your top view like this:
.customAlert(data: $alertData)
Whenever you want to show an alert, you can do it like this:
self.alertData = AlertData(
title: "Some Title",
message: "Some important but optional message",
actions: [
AlertButton(title: "Say Yes!") {
// do what to do here.
},
AlertButton(title: "Say No!", style: .cancel) {
// do what to do here.
}
]
)