Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

OlegKetrar/AlertDispatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AlertDispatcher

Carthage compatible

Features

  • Unified queue for all alerts
  • Alert.tintColor
  • Alert with custom actions
  • wait before & after alert
  • enqueue() & present()
  • ignored()
  • Alerts with conditions
  • several alerts queues
  • Action sheets

Usage

Simple alert:

Alert.alert(title: "Super popup", message: "Description")
  .addCompletion { /* alert disappers */ }
  .present()

Dialog with custom action:

Alert.dialog(
  title: "Are you sure you want delete it?",
  cancelTitle: "No"
  actionTitle: "Delete",
  isDestructive: true,
  actionClosure: { /* remove smth */ }).enqueue()

Dispatching

Every alert has isDispatchable property which can describe alert behaviour in case if other alert is already presented on screen. Dispatchable alert will be putten in queue and will presented on screen after all alerts before it. Not dispatchable alerts will just ignored if queue already has some alerts. You can configure alert dispatching with dispatchable(Bool) method and then call dispatch(). Or you can explicitly call enqueue() presentng alert now or later, or present for just presentng now or never.

  • you can set waitOnAppear(TimeInterval) and waitOnDisapper(TimeInterval) delay in seconds.
  • ignored() method just ignore this alert at all.
  • with addCondition(_ condition: @escaping () -> Bool) you can specify custom condition for alert. Will be asked before presenting.

Completions

  • You can add as many completion handlers as you want by addCompletion method. Your completion will be called by FIFO rule.
  • onCompletion method just rewrites all completion handlers with new one.

Requirements

  • Swift 4+
  • xCode 9+
  • iOS 8.0+

Installation

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate NumberPad into your Xcode project using Carthage, specify it in your Cartfile:

github "OlegKetrar/AlertDispatcher"

Run carthage update to build the framework and drag the built AlertDispatcher.framework into your Xcode project.

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but AlertDispatcher does support its use on supported platforms.

Once you have your Swift package set up, adding TaskKit as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
  .Package(url: "https://github.com/OlegKetrar/AlertDispatcher")
]

License

AlertDispatcher is released under the MIT license. See LICENSE for details.