Skip to content

A mechanism for chaining UIAlertController's to each other

License

Notifications You must be signed in to change notification settings

s/ChainedAlertController

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChainedAlertController

A mechanism for chaining UIAlertController's to each other

A small iOS code snippet to create dynamically chained UIAlerts. Example usage:

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:

showChainedAlert(alert: firstAction)

About

A mechanism for chaining UIAlertController's to each other

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages