Skip to content

devhplusn/Alerts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alerts

Swift Platforms GitHub license

Alerts is a library that handles UIAlertController using the Method Chain pattern.

Requirements

  • Swift 5
  • iOS 11.0+

Installation

Swift Package Manager

You can use The Swift Package Manager to install Alerts by adding the proper description to your Package.swift file:

import PackageDescription

let package = Package(
    name: "YOUR_PROJECT_NAME",
    targets: [],
    dependencies: [
        .package(url: "https://github.com/devhplusn/Alerts.git", from: "1.0.0")
    ]
)

Then run swift package update.

Cocoapods

Alerts is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Alerts', :tag => '1.0.0', :git => 'https://github.com/devhplusn/Alerts'

Usage

Alert Type

  • Basic
Alert(title: "Title", message: "Message", tintColor: .black)
    .addAction("OK", style: .default, isEnabled: true, titleColor: .black) { controller in
        // you can handle here when user tapped this UIAlertAction
    }.addAction("Cancel", style: .cancel)
    .present(at: self)
  • With textField
Alert(title: "Title", message: "Message", tintColor: .black)
    .addTextField { textField in
        // you can configuration textField.
    } textDidChange: { controller, textField in
        // you can handle it when the text of the textField changes.

    }.textFieldDidChange { controller, index in
        // you can handle it when the text of the textFields changes.

    }.addAction("OK", style: .default, isEnabled: true, titleColor: .black) { controller in
        // you can handle it when the user taps this UIAlertAction.

    }.addAction("Cancel", style: .cancel)
    .present(at: self)

ActionSheet Type

ActionSheet(title: "Title", message: "Message")
    .addAction("OK", isEnabled: false) { controller in
        // you can handle here when user tapped this UIAlertAction
    }.addAction("Cancel", style: .cancel)
    .present(at: self)

License

Alerts is available under the MIT license. See the LICENSE file for more info.

About

Alerts is a library that handles UIAlertController using the Method Chain pattern.

Resources

License

Stars

Watchers

Forks

Packages

No packages published