Swiftpack.co - jknlsn/SwiftUIToast as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by jknlsn.
jknlsn/SwiftUIToast v0.0.2
A simple Toast view in SwiftUI, like the AirPods toast
⭐️ 2
🕓 2 years ago
iOS
.package(url: "https://github.com/jknlsn/SwiftUIToast.git", from: "v0.0.2")

SwiftUIToast

A simple Toast view in SwiftUI.

Key features:

  • single wrapper over primary view
  • global state, call from anywhere as function rather than wrapper and binding

Usage

import SwiftUIToast
// Wrap your content in a ToastContainerView so that the toast can always appear on top.
// A good spot to put this is in your ContentView file.
SwiftUIToast.ToastContainerView {
    // Your content goes here
    ZStack{
        Color.green
            Button(action: {
                // Show a toast by calling the show function anywhere
                SwiftUIToast.show(
                    image: "airpodsmax",
                    text: "Playing music"
                )
            }) {
                Text("Toggle")
            }
    }
    .onAppear{
        // You can set the defaults any time to affect every Toast
        Toast.setDefaults(duration: 2.0, shadow: 0.0, position: .bottom)
    }

}

GitHub

link
Stars: 2
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Related Packages

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