https://github.com/mezhevikin/alertcontroller
💬 A tiny extension for UIAlertController that makes working with it very simple. Only 150 lines of code.
https://github.com/mezhevikin/alertcontroller
actionsheet alert alertview cocoapods extension ios lightweight modal notification popover popup spm swift swift-package-manager syntactic-sugar uialertcontroller uikit wrapper
Last synced: 6 months ago
JSON representation
💬 A tiny extension for UIAlertController that makes working with it very simple. Only 150 lines of code.
- Host: GitHub
- URL: https://github.com/mezhevikin/alertcontroller
- Owner: mezhevikin
- License: mit
- Created: 2022-09-11T11:10:48.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-06-24T09:19:08.000Z (almost 2 years ago)
- Last Synced: 2024-10-30T17:17:04.574Z (7 months ago)
- Topics: actionsheet, alert, alertview, cocoapods, extension, ios, lightweight, modal, notification, popover, popup, spm, swift, swift-package-manager, syntactic-sugar, uialertcontroller, uikit, wrapper
- Language: Swift
- Homepage:
- Size: 14.6 KB
- Stars: 18
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AlertController
💬 A tiny extension for UIAlertController that makes working with it very simple. Only 150 lines of code.
### Alert
```swift
let alert = UIAlertController.alert()
alert.setTitle("✅ Success", color: .darkGreen)
alert.setMessage("Your message has been sent")
alert.addAction(
title: "Send more",
systemIcon: "envelope.fill",
color: .darkGreen,
leftAligment: true
) {}
alert.addAction(
title: "Delete message",
systemIcon: "trash.fill",
color: .red,
leftAligment: true
) {}
alert.addOkAction()
present(alert, animated: true)
```
![]()
### Sheet
```swift
let sheet = UIAlertController.sheet("👨🏻 Mezhevikin Alexey")
sheet.addAction(
title: "Edit profile",
systemIcon: "person.fill",
color: .darkGreen,
leftAligment: true
) {}
sheet.addAction(
title: "Delete account",
systemIcon: "trash.fill",
color: .red,
leftAligment: true
) {}
sheet.addAction(
title: "Log out",
systemIcon: "square.and.arrow.down.fill",
leftAligment: true
) {}
sheet.addCancelAction()
present(sheet, sourceView: cell)
```
![]()
### Choice
```swift
let sheet = UIAlertController.sheet("Choose your favorite animal")
let animals = ["🐈 Cat", "🐕 Dog", "🐎 Horse", "🐫 Camel"]
for (i, animal) in animals.enumerated() {
sheet.addAction(
title: animal,
checked: favoriteAnimal == i,
leftAligment: true
) {
self.favoriteAnimal = i
}
}
sheet.addCancelAction()
present(sheet, sourceView: cell)
```
![]()
### TextField
```swift
let alert = UIAlertController.alert("🔓 Login")
alert.addTextField {
$0.placeholder = "✉️ Mail"
}
alert.addTextField {
$0.placeholder = "🔑 Password"
$0.isSecureTextEntry = true
}
alert.addAction(title: "OK") {
if let mail = alert.textFields?[0].text,
let password = alert.textFields?[1].text
{
print("✉️ \(mail), 🔑 \(password)")
}
}
present(alert)
```
![]()
### Present
```swift
// Alert
present(alert)
// Sheet from cell with iPad support
present(sheet, sourceView: cell)
// Sheet from BarButton with iPad support
present(sheet, barButtonItem: navigationItem.leftBarButtonItem)
```### Swift Package Manager
```
https://github.com/mezhevikin/AlertController.git
```### CocoaPods
```
pod 'AlertController', :git => 'https://github.com/mezhevikin/AlertController.git'
```