/PLAlert

Primary LanguageSwiftMIT LicenseMIT

PLAlert

Highly customizable and interactive transtionable alert controller with simple usage.

Installation

Cocoapods

pod 'PLAlert'

Swift Package Manager

  1. File > Swift Packages > Add Package Dependency
  2. Add https://github.com/baris-cakmak/PLAlert.git

OR

Update dependencies in Package.swift

dependencies: [
    .package(url: "https://github.com/baris-cakmak/PLAlert.git", .upToNextMajor(from: "1.0.0"))
]

Screenshots

Usage

import UIKit
import PLAlert

final class ViewController: UIViewController, AlertPresentable {
    // MARK: - Minimum Usaget with AlertPresentable Protocol
    func someFunc() {
        // this is the minimum usage of the current api.
        showAlert(type: PLAlertController.self, message: "message")
    }
    // MARK: - Minimum Usage with AlertPresentable Protocol
    func someFunc() {
        // default view properties with custom parameters
        showAlert(type: PLAlertController.self, title: "custom", message: "custom", buttonText: "custom", animationConfiguration: .init(animationStartPosition: .bottomRight, animationEndPosition: .bottomLeft, animationPresentDuration: 3, animationDismissalDuration: 2, dimmingViewAlpha: 0.7))
    }
    // MARK: - Usage with Inherited PLAlertController
    func someFunc() {
        // Use Inheritance to Achieve this. Check Example App
        showAlert(type: InheritedAlertController.self, message: "message")
    }
    // MARK: - Direct usage by calling the Controller - You do not need AlertPresentable Protocol
    func someFunc() {
        let alertController = PLAlertController(title: "title", text: "message", buttonText: "Cancel", animationConfiguration: .init(animationStartPosition: .top, animationEndPosition: .bottomRight))
        // some property injection
        alertController.messageBackgroundColor = .red
        alertController.containerWidthRatio = 0.6
        // some property injection
        present(alertController, animated: true)
    }
}

Authors

License

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