Highly customizable and interactive transtionable alert controller with simple usage.
pod 'PLAlert'
- File > Swift Packages > Add Package Dependency
- 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"))
]
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)
}
}
PLAlert is available under the MIT license. See the LICENSE file for more info.