https://github.com/s/chainedalertcontroller
A mechanism for chaining UIAlertController's to each other
https://github.com/s/chainedalertcontroller
Last synced: about 1 year ago
JSON representation
A mechanism for chaining UIAlertController's to each other
- Host: GitHub
- URL: https://github.com/s/chainedalertcontroller
- Owner: s
- License: mit
- Created: 2018-06-13T19:55:16.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-13T20:38:51.000Z (about 8 years ago)
- Last Synced: 2025-03-17T23:44:34.771Z (over 1 year ago)
- Language: Swift
- Size: 12.7 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ChainedAlertController
A mechanism for chaining UIAlertController's to each other
A small iOS code snippet to create dynamically chained UIAlerts. Example usage:
```swift
fileprivate lazy var firstAction: ChainedAlertTree = {
let cancelAction = ChainedAlertAction(title: "Cancel", style: .cancel, shouldTriggerNextAlert: false, handler: nil)
let triggerNextAction = ChainedAlertAction(title: "Trigger next", style: .default, shouldTriggerNextAlert: true, handler: nil)
let alert = ChainedAlert(title: "First alert title", message: "First alert message", actions: [cancelAction, triggerNextAction])
return ChainedAlertTree.alert(alert: alert, nextAlert: secondAction)
}()
fileprivate lazy var secondAction: ChainedAlertTree = {
let cancelAction = ChainedAlertAction(title: "Cancel", style: .cancel, shouldTriggerNextAlert: false, handler: nil)
let triggerNextAction = ChainedAlertAction(title: "Trigger next", style: .default, shouldTriggerNextAlert: true, handler: nil)
let alert = ChainedAlert(title: "Second action title", message: "Second action message", actions: [cancelAction, triggerNextAction])
return ChainedAlertTree.alert(alert: alert, nextAlert: thirdAction)
}()
fileprivate lazy var thirdAction: ChainedAlertTree = {
let cancelAction = ChainedAlertAction(title: "It's enough.", style: .cancel, shouldTriggerNextAlert: false, handler: nil)
let alert = ChainedAlert(title: "Third action title", message: "Third action message", actions: [cancelAction])
return ChainedAlertTree.alert(alert: alert, nextAlert: nil)
}()
```
And then:
```swift
showChainedAlert(alert: firstAction)
```