All Projects → BastiaanJansen → toast-swift

BastiaanJansen / toast-swift

Licence: MIT License
A Swift Toast view - iOS 14 style and newer - built with UIKit. 🍞

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to toast-swift

Notiflix
Notiflix is a JavaScript library for client-side non-blocking notifications, popup boxes, loading indicators, and more that makes your web projects much better.
Stars: ✭ 172 (+102.35%)
Mutual labels:  toast, notification
Squawk
Quick & interactive iOS alerts in Swift.
Stars: ✭ 254 (+198.82%)
Mutual labels:  uikit, toast
Vue Toast Notification
Yet another toast notification plugin for Vue.js 🌷
Stars: ✭ 205 (+141.18%)
Mutual labels:  toast, notification
Nativescript Feedback
📢 Non-blocking textual feedback for your NativeScript app
Stars: ✭ 127 (+49.41%)
Mutual labels:  toast, notification
SimpleToast
SimpleToast is a simple, lightweight, flexible and easy to use library to show toasts / popup notifications inside iOS or MacOS applications in SwiftUI. Because of the flexibility to show any content it is also possible to use the library for showing simple modals.
Stars: ✭ 131 (+54.12%)
Mutual labels:  toast, notification
Noty
A simple library for creating animated warnings/dialogs/alerts for Android.
Stars: ✭ 136 (+60%)
Mutual labels:  toast, notification
JDToaster
🍞 Toasty iOS alerts
Stars: ✭ 25 (-70.59%)
Mutual labels:  uikit, toast
Notie
🔔 a clean and simple notification, input, and selection suite for javascript, with no dependencies
Stars: ✭ 6,170 (+7158.82%)
Mutual labels:  toast, notification
MaterialToast
A fully and highly customizable material designed Toast for Android.
Stars: ✭ 31 (-63.53%)
Mutual labels:  toast, notification
NotificationToast
Google toast the Apple way !
Stars: ✭ 132 (+55.29%)
Mutual labels:  uikit, toast
Vue Toastify
🔥 Simple, extendable, dependency free notification plugin. 🔥
Stars: ✭ 126 (+48.24%)
Mutual labels:  toast, notification
Loafjet
🚀 Loafjet is a lightweight custom framework used to add Loafs, Dash Board, Popup Card, and Loading indicator in your Swift project
Stars: ✭ 63 (-25.88%)
Mutual labels:  uikit, toast
Reapop
📮 A simple and customizable React notifications system
Stars: ✭ 1,155 (+1258.82%)
Mutual labels:  toast, notification
Vue Toasted
🖖 Responsive Touch Compatible Toast plugin for VueJS 2+
Stars: ✭ 2,091 (+2360%)
Mutual labels:  toast, notification
React Toastify
React notification made easy 🚀 !
Stars: ✭ 8,113 (+9444.71%)
Mutual labels:  toast, notification
iakit
无依赖 mini 组件库,只封装了 alert, toast, loading, actionSheet 等使用频率较高的组件。适用于类似 H5 活动页的简单移动端项目,不必为了使用这些组件而引入一个大而全的 UI 库和框架。
Stars: ✭ 38 (-55.29%)
Mutual labels:  uikit, toast
Fftoast
A very powerful iOS message notifications and AlertView extensions. It can be easily realized from the top of the screen, the bottom of the screen and the middle of the screen pops up a notification. You can easily customize the pop-up View.
Stars: ✭ 649 (+663.53%)
Mutual labels:  toast, notification
Anylayer
Android稳定高效的浮层创建管理框架
Stars: ✭ 745 (+776.47%)
Mutual labels:  toast, notification
mosha-vue-toastify
A light weight and fun Vue 3 toast or notification or snack bar or however you wanna call it library.
Stars: ✭ 185 (+117.65%)
Mutual labels:  toast, notification
denbun
Adjust showing frequency of Android app messages, and to be more user friendly 🐦
Stars: ✭ 17 (-80%)
Mutual labels:  toast, notification

Toast-Swift

Codacy Badge

A Swift Toast view - iOS 14 style - built with UIKit. 🍞

Installation

Swift Package Manager

You can use The Swift Package Manager to install Toast-Swift by adding the description to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/BastiaanJansen/toast-swift", from: "1.0.5")
]

CocoaPods

pod "ToastViewSwift"

Usage

To create a simple text based toast:

let toast = Toast.text("Safari pasted from Notes")
toast.show()

Or add a subtitle:

let toast = Toast.text("Safari pasted from Notes", subtitle: "A few seconds ago")
toast.show()

If you want to add an icon, use the default method to construct a toast:

let toast = Toast.default(
    image: UIImage(systemname: "airpodspro")!,
    title: "Airpods Pro",
    subtitle: "Connected"
)
toast.show()

Want to use a different layout, but still use the Apple style? Create your own view and inject it into the AppleToastView class when creating a custom toast:

let customView: UIView = // Custom view

let appleToastView = AppleToastView(child: customView)

let toast = Toast.custom(view: appleToastView)
toast.show()

The show method accepts several optional parameters. haptic of type UINotificationFeedbackGenerator.FeedbackType to use haptics and after of type TimeInterval to show the toast after a certain amount of time:

toast.show(haptic: .success, after: 1)

Configuration options

The text, default and custom methods support custom configuration options. The following options are available:

Name Description Type Default
autoHide When set to true, the toast will automatically close itself after display time has elapsed. Bool true
displayTime The duration the toast will be displayed before it will close when autoHide set to true in seconds. TimeInterval 4
animationTime Duration of the show and close animation in seconds. TimeInterval 0.2
attachTo The view which the toast view will be attached to. UIView nil
let config = ToastConfiguration(
    autoHide: true,
    displayTime: 5,
    animationTime: 0.2
)

let toast = toast.text("Safari pasted from Notes", config: config)

Custom toast view

Don't like the default Apple'ish style? No problem, it is also possible to use a custom toast view with the custom method. Firstly, create a class that confirms to the ToastView protocol:

class CustomToastView : UIView, ToastView {
    private let text: String

    public init(text: String) {
        self.text = text
    }

    func createView(for toast: Toast) {
        // View is added to superview, create and style layout and add constraints
    }
}

Use your custom view with the custom construct method on Toast:

let customToastView: ToastView = CustomToastView(text: "Safari pasted from Notes")

let toast = Toast.custom(view: customToastView)
toast.show()

Licence

Toast-Swift is available under the MIT licence. See the LICENCE for more info.

Stargazers repo roster for @BastiaanJansen/Toast-Swift

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].