https://github.com/imhdi/isnackbar
An iOS implementation of the Snackbar concept, as used extensively in Android as well as many Google iOS apps such as Gmail
https://github.com/imhdi/isnackbar
objective-c snackbar toast tools ui-components
Last synced: 6 months ago
JSON representation
An iOS implementation of the Snackbar concept, as used extensively in Android as well as many Google iOS apps such as Gmail
- Host: GitHub
- URL: https://github.com/imhdi/isnackbar
- Owner: iMhdi
- License: mit
- Created: 2017-12-13T19:52:46.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-26T13:23:45.000Z (over 7 years ago)
- Last Synced: 2025-03-20T09:41:14.138Z (7 months ago)
- Topics: objective-c, snackbar, toast, tools, ui-components
- Language: Objective-C
- Homepage:
- Size: 828 KB
- Stars: 10
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# iSnackBar
[](http://cocoapods.org/pods/iSnackBar)
[](http://cocoapods.org/pods/iSnackBar)
[](http://cocoapods.org/pods/iSnackBar)## Author
El Mahdi BOUKHRIS, m.boukhris@gmail.com
## About
[Snackbars are a Android UI component](https://material.io/guidelines/components/snackbars-toasts.html#) which present a stylish, actionable alert to the user. Google also uses their own iOS snackbar implementation in some of their iOS apps, such as Gmail.Snackbar's are useful for presenting a brief message to the user which they can then act on. A common usage pattern is to display a snackbar after a user has performed some destructive action, providing the user with a grace period during which they can undo this action.
## Example Project
The included example project provides a demonstration of iSnackBar. It displays a tableView containing differents usecases for different iSnackBar styles. When an item is selected from the list, the corresponding snackbar is presented.The list is divided into two sections:
* Notification SnackBar : seleting an item from this sections displays a SnackBar that's meant for notifications only displaying a message.
* Action SnackBar : seleting an item from this sections displays a SnackBar meant to notify and at the same time give the user the option to perform an action by adding a button to the SnackBarTo run the example project, clone the repo, and run `pod install` from the Example directory first.

## Installation
This project is available via CocoaPods. In order to install, simply add `"iSnackbar"` to your Podfile.
You can also integrate iSnackbar manually by downloading iSnackbar.h and iSnackbar.m and adding them to your project.
## Usage
This project contains a single class: `iSnackbar`.
`iSnackbar` objects cannot be "stacked" on-screen. If you display a snackbar while another is on-screen, the currently shown snackbar will be replaced, and it will act as though it had been dismissed after being on-screen for its configured length of time.
All messages sent to `iSnackbar` objects should be sent from the main thread.
### Creating instances of `iSnackbar`
New snackbar objects can be created using the following methods:
```objective-c
+ (void) snackBarWithMessage:(NSString*) message
+ (void) snackBarWithMessage:(NSString*) message
font:(UIFont*) font
backgroundColor:(UIColor*) bgColor
textColor:(UIColor*) textColor
duration:(float) duration
+ (void) snackBarWithMessage:(NSString*) message
action:(NSString*) actionName
delegate:(id) delegate
+ (void) snackBarWithMessage:(NSString*) message
font:(UIFont*) font
backgroundColor:(UIColor*) bgColor
textColor:(UIColor*) textColor
action:(NSString*) action
delegate:(id) delegate
duration:(float) duration
```
* `message` is the text to be displayed on the snackbar's text label.
* `font` is the font that would be used on the snackbar's text label.
* `bgColor` is the snackbar's background color.
* `textColor` is the color that would be used on the snackbar's text label.
* `duration` is the length of time for which the snackbar should remain on the screen before it is dismissed.
* `actionName` is the text to be displayed on the snackbar's button.
* `delegate` is the delegate that would receive the callback if/when the snackbar's button is clicked.