Skip to content

Lightweight Swift framework for presenting alerts and action sheets using a clean, reusable protocol-oriented API in UIKit.

License

Notifications You must be signed in to change notification settings

dsngeu/SwiftAlertKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SwiftActionSheet

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.


🚀 Features

  • ✅ Reusable alert & action sheet presenter via protocol
  • ✅ Enum-based AlertAction for 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+

📦 Installation

Just drop these files into your project:

UIKitUtils

No CocoaPods or SPM needed.

🧠 Usage

1. Conform to ActionSheetPresentable

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.

About

Lightweight Swift framework for presenting alerts and action sheets using a clean, reusable protocol-oriented API in UIKit.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages