https://github.com/georgemihoc/toastframeworkswift
A configurable Swift framework for UI Toast components.
https://github.com/georgemihoc/toastframeworkswift
alert cocoapods framework ios swift toast
Last synced: 26 days ago
JSON representation
A configurable Swift framework for UI Toast components.
- Host: GitHub
- URL: https://github.com/georgemihoc/toastframeworkswift
- Owner: georgemihoc
- License: mit
- Created: 2022-03-14T09:11:15.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-20T08:44:00.000Z (almost 4 years ago)
- Last Synced: 2025-08-18T13:03:48.539Z (8 months ago)
- Topics: alert, cocoapods, framework, ios, swift, toast
- Language: Swift
- Homepage:
- Size: 68.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ToastFrameworkSwift
[](https://cocoapods.org/pods/ToastFrameworkSwift)
[](https://cocoapods.org/pods/ToastFrameworkSwift)
[](https://github.com/georgemihoc/ToastFrameworkSwift/blob/main/LICENSE)
A configurable Swift framework for UI Toast components.
## Installation
ToastFrameworkSwift is an open-source framework available through [CocoaPods](https://cocoapods.org).
First step is to install CocoaPods. Skip this step if you already have CocoaPods installed on your machine.
```ruby
sudo gem install cocoapods
```
Initialize your project with CocoaPods from your project directory:
```ruby
pod init
```
For installation, add the required pod within your `Podfile` as shown below:
```ruby
pod 'ToastFrameworkSwift'
```
After adding the pod, run the below command :
```ruby
pod install
```
## ToastFrameworkSwift Example
To run the example project, clone the repo, and run `pod install` within the ToastFrameworkExample directory, using `Terminal`.
Here you can see how different types of toasts look, both normal and CTA ones.
## Usage
After the installation step you should have generated the `.xcworkspace`. The next step now is to import `ToastFrameworkSwift` within your `ViewController`:
```swift
import ToastFrameworkSwift
```
### Configuration
The toast framework can be configured with the following properties:
```swift
// Enables or disables tap to dismiss behaviour for toasts.
// When `true`, toast views will dismiss when tapped. When `false`, tapping will have no effect.
ToastManager.shared.isTapToDismissEnabled = true
```
```swift
// Enables or disables wipe to dismiss behaviour for toasts.
// When `true`, toast views will dismiss when swiped. When `false`, swiping will have no effect.
ToastManager.shared.isSwipeToDismissEnabled = true
```
```swift
// Enables or disables queueing behaviour for toasts.
// When `true`, toast views will appear one after the other. When `false`, toast overlapping might happen
ToastManager.shared.isQueueEnabled = true
```
```swift
// The default duration for toasts. Default value is 1.0
ToastManager.shared.duration = 2
```
```swift
// This property sets up the haptic feedback type. The types can be found
// within `HapticFeedback` class. When `.none`, there won't be any haptic feedback.
ToastManager.shared.hapticFeedbackType = .impactLight
```
### Basic Toast
```swift
func presentBasicToast() {
view.showToast(message: "This is a Basic Toast.")
}
```
### Basic Toast with customizable background
```swift
func presentBasicGrayToast() {
view.showToast(message: "This is a Basic Gray Toast.", toastColor: .gray)
}
```
### Basic Toast with customizable background and text color
```swift
func presentBasicBlackTextToast() {
view.showToast(message: "This is a Black Text Toast.", toastColor: .gray, textColor: .black)
}
```
### CTA Toast that presents a follow-up Toast on action
```swift
func presentCTAToast() {
view.showCTAToast(message: "This is a CTA Toast.", actionTitle: "Press here") { [weak self] in
self?.view.showToast(message: "This is the follow-up Toast.", toastColor: .systemGreen)
}
}
```
## Author
George Mihoc, george.mihoc@gmail.com
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
## License
[MIT](https://github.com/georgemihoc/ToastFrameworkSwift/blob/main/LICENSE) @ 2022 George Mihoc