A lightweight Swift utility for presenting alerts and action sheets in a clean, reusable, and protocol-oriented way. Designed for UIKit projects to reduce boilerplate and improve UX consistency.
- ✅ Reusable alert & action sheet presenter via protocol
- ✅ Enum-based
AlertActionfor safer, cleaner APIs - ✅ Optional callbacks for all actions
- ✅ Minimal setup — drop it into any
UIViewController - ✅ Prebuilt support for common cases: delete, cancel, sign out, etc.
- ✅ Compatible with iOS 13+
Just drop these files into your project:
No CocoaPods or SPM needed.
class LoginViewController: UIViewController, ActionSheetPresentable { }
2. Show an alert with multiple buttons
showAlert(
title: "Sign Out",
message: "Are you sure you want to sign out?",
actions: [.cancel, .signOut]
) { action in
if action == .signOut {
// Handle logout
}
}
3. Show an action sheet
showActionSheet(
title: "Options",
message: "Choose one",
actions: [.custom(title: "Edit"), .delete, .cancel],
sourceView: senderButton,
sourceRect: senderButton.bounds
) { action in
switch action {
case .delete:
// Handle deletion
case .custom(let title, _):
print("Tapped: \(title)")
default:
break
}
}
4. Show a simple message
showMessage(message: "Welcome back!") {
print("Dismissed")
}
5. Show a generic network error
showNetworkError()
✅ Requirements
• iOS 13.0+
• Swift 5+
• UIKit
✨ Author
Created by @dsngeu - Deepak Singh
💬 Feedback & Contributions
Feel free to submit issues, PRs, or ideas. This utility is kept intentionally light and open for expansion.