Swiftpack.co - aliaslab-1984/ALToast as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by aliaslab-1984.
aliaslab-1984/ALToast 1.0.8
A tiny library to display toast messages on iOS apps.
⭐️ 0
🕓 18 weeks ago
.package(url: "https://github.com/aliaslab-1984/ALToast.git", from: "1.0.8")


Toast Example Image

ALToast is a simple swift package that helps you to display small toast messages on your application with minimum effort!

This is the simplest way of showing a toast:

let infoMessage = ALMessage.info(message: "Logged in", iconName: "chekmark")
ALToast.info(with: infoMessage, on: self)

Easy right!? It gets even easier. If you want to avoid where to show the toast message, you can simply force to show each toast message on top of your app's main window. To do that:

  1. Jump into your SceneDelegate class;
  2. On sceneWillEnterForeground(_ scene: UIScene) assign your application's main window to this property:

// ..

func sceneWillEnterForeground(_ scene: UIScene) {
    ALToast.rootPresentable = UIApplication.shared.windows.first

And you're done! Now you can avoid to call on: self on each of your view controllers.


ALToast is super cuastomizable, from the dismiss time interval to the colors. Using the ALMessage struct, you can provide images, text and the toast duration, or change the default duration to the one you prefer. If you provide a nil duration to the timeInterval property, the toast will never be removed from the view, to remove it you must remove it manually, by keeping a reference of the shown toast. It's easy to keep a reference of a toast:

var myToastMessage: ALToastMessageView?

// ..

myToastMessage = ALToast.info(with: .info("Example", hideAfter: nil)) // passing nil will persist the toast message.

myToastMessage.hide(animated: true)


Stars: 0
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Improved Toast sizing + fixes progress not showing
1 year ago

As the title says, this release aims to fix some annoying bugs with Progress Toasts. Specifically, now all the accessories are placed on the left side of the toast, and if a message is shorter the toast will reflect the message size. Many thanks to @asclepix for the contribution!

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics