Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
devpolant committed Aug 15, 2020
1 parent cb5eb3c commit 55df13c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,21 @@ See [Alert.swift](https://github.com/AntonPoltoratskyi/NativeUI/blob/master/Nati
When you need to present few alerts in a row you should set `shouldDismissAutomatically` flag to `false` and add action AFTER view controller initialization to be able to capture alert instance in action handler's closure.

```swift
let cancelAction = Alert.Action(title: "Cancel", style: .primary)

let viewModel = Alert(
title: "Your Title",
message: "Your Message",
actions: [cancelAction]
message: "Your Message"
)
let alert = AlertViewController(viewModel: viewModel)
alert.shouldDismissAutomatically = false

let cancelAction = Alert.Action(title: "Cancel", style: .primary) { [weak alert] _ in
alert?.dismiss(animated: true) {
// present something else
}
}
alert.addAction(cancelAction)

let confirmAction = Alert.Action(title: "Confirm", style: .default) { [weak alert] _ in
alert?.dismiss(animated: true) {
// present something else
Expand Down

0 comments on commit 55df13c

Please sign in to comment.