Skip to content

lcaxgg/ToastKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ToastKit 🚀🔥

A customizable 🍞 toast notification library for iOS, built with Swift!


✨ Features

  • Show beautiful toast messages in your app!
  • Highly customizable: colors, fonts, padding, corner radius, button, and more 🎨
  • Supports positioning: top, center, or bottom 🧭
  • Add a button for user interaction (optional) 🖱️
  • Easy animation and auto-dismissal ⏰
  • Built with UIKit, supports iOS 15+ 📱

⚡️ Installation

Add ToastKit to your project using Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/lcaxgg/ToastKit.git", from: "1.0.0")
]

Or use Xcode:

  1. Go to File > Add Packages...
  2. Enter: https://github.com/lcaxgg/ToastKit
  3. Add the package to your project!

🛠️ Usage

You can easily extend ToastAttributes to create your own custom initializer for more streamlined usage!

import ToastKit

extension ToastAttributes {
    static func customInit(
        contentInsets: UIEdgeInsets = .zero,
        containerInsets: UIEdgeInsets = .zero,
        cornerRadius: CGFloat = 0,
        backgroundColor: UIColor = .black,
        foregroundColor: UIColor = .white,
        titleMessageSpacing: CGFloat = 0,
        title: String? = nil,
        message: String,
        showButton: Bool = false,
        titleFont: UIFont = UIFont.systemFont(ofSize: 0, weight: .bold),
        messageFont: UIFont = UIFont.systemFont(ofSize: 0),
        buttonText: String = "Button",
        buttonTextFont: UIFont = UIFont.systemFont(ofSize: 0),
        position: ToastPosition = .bottom,
        positionOffset: CGFloat = 0,
        duration: TimeInterval = 0,
        deadline: CGFloat = 0
    ) -> ToastAttributes {
        return ToastAttributes(
            contentInsets: contentInsets,
            containerInsets: containerInsets,
            cornerRadius: cornerRadius,
            backgroundColor: backgroundColor,
            foregroundColor: foregroundColor,
            title: title,
            message: message,
            titleFont: titleFont,
            messageFont: messageFont,
            titleMessageSpacing: titleMessageSpacing,
            buttonText: buttonText,
            buttonTextFont: buttonTextFont,
            showButton: showButton,
            position: position,
            positionOffset: positionOffset,
            duration: duration,
            deadline: deadline
        )
    }
}

Here’s how you can use your custom initializer to show a toast:

let attributes = ToastAttributes.customInit(
    title: "Title here",
    message: "message here",
    showButton: true
)

view.showToastMessage(with: attributes, onButtonTap: {
    print("Button tapped!")
})

🖼️ Sample Screenshots

Simple Toast Toast with Button
Screenshot 2025-07-09 at 5 05 03 PM Screenshot 2025-07-09 at 5 05 26 PM

🤝 Contributing

Contributions, issues, and feature requests are welcome!
Feel free to check issues page.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages