Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sanzaru/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.
https://github.com/sanzaru/SimpleToast

ios macos notification popup swift swift-package swift5 swiftui toast toast-notifications

Last synced: about 2 months ago
JSON representation

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.

Awesome Lists containing this project

README

        

# SimpleToast for SwiftUI

[![](https://travis-ci.com/sanzaru/SimpleToast.svg?branch=develop)](https://travis-ci.com/sanzaru/SimpleToast)
[![](https://tinyurl.com/3e9pprjv)](https://swiftpackageindex.com/sanzaru/SimpleToast)
[![](https://tinyurl.com/mtkte8as)](https://swiftpackageindex.com/sanzaru/SimpleToast)
[![Swift](https://github.com/sanzaru/SimpleToast/actions/workflows/swift.yml/badge.svg?branch=master)](https://github.com/sanzaru/SimpleToast/actions/workflows/swift.yml)

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.

You decide the content, the library takes care about the rest.

> [!IMPORTANT]
> The current version is still in development. There can and will be breaking changes in version updates until version 1.0.

## Features:

* Custom toast content support: You can show whatever you want inside the toast.
* Custom positioning: Place the toast where you want it to be.
* Timeout functionality: You decide if and when the toast should disappear.
* Callback functionality: Run code when the toast disappeared.
* Multiple, customizable animations

> [!CAUTION]
> 🚨 Breaking changes:
> * **0.6.0:**
> * The options struct is modified and the parameters `showBackdrop` and `backdropColor` are replaced by a single optional Color definition `backdrop`. See [Options](#options) for more information

## Demo

| Modifier | Demo |
| -------- | ---- |
| *.slide* | |
| *.fade* | |
| *.scale* | |
| *.skew* | |

## Installation

### Swift Package Manager
```swift
dependencies: [
.package(url: "https://github.com/sanzaru/SimpleToast.git", from: "0.0.1")
]
```

### Cocoapods

> [!CAUTION]
> CocoaPods support will be dropped with version 1.0. Prior to that, support will be minimal. Using SPM is highly recommended.

Add the following line to your Podfile:

```
pod 'SwiftUI-SimpleToast', '~> 0.6.2'
```

and run

```
pod install
```

or

```
pod update
```

## Usage

📚 For more information on how to use SimpleToast, see the [documentation on usage](/Documentation/Usage.md).

## Options

The toast can be configured via an optional SimpleToastOptions object. You can simply pass an empty object to configure the toast with default values.

>  

> 📌 All parameters inside the options are optional. If not set, the default value will be taken.
>
 

| Option | Type | Description | Default |
| -------- | ---- | ------------- | -------- |
| **alignment** | [Alignment](https://developer.apple.com/documentation/swiftui/alignment) | Defines the alignment of the toast. | .top |
| **hideAfter** | [TimeInterval?](https://developer.apple.com/documentation/foundation/timeinterval) | Defines when the toast disappears. If nil is given the toast won't disappear. | nil |
| **backdrop** | [Color?](https://developer.apple.com/documentation/swiftui/color) | Defines the backdrop color | nil |
| **animation** | [Animation](https://developer.apple.com/documentation/swiftui/animation) | Defines the animation type. | .linear |
| **modifierType** | [ModifierType](#Demo) | Defines the type of toast animation. Possible values: .slide, .fade | .fade |
| **dismissOnTap** | [Bool?](https://developer.apple.com/documentation/swift/bool) | Defines if the toast closes on tap. Possible values: true, false | true |
| **disableDragGesture** | [Bool](https://developer.apple.com/documentation/swift/bool) | Defines if the toast reacts to drag gestures. Possible values: true, false | false |