https://github.com/space-code/snacker
snacker is a lightweight Swift library for displaying snackbars in iOS applications.
https://github.com/space-code/snacker
snackbar swift uikit
Last synced: 20 days ago
JSON representation
snacker is a lightweight Swift library for displaying snackbars in iOS applications.
- Host: GitHub
- URL: https://github.com/space-code/snacker
- Owner: space-code
- License: mit
- Created: 2025-02-06T11:30:41.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-25T15:43:57.000Z (11 months ago)
- Last Synced: 2025-06-04T16:30:17.971Z (9 months ago)
- Topics: snackbar, swift, uikit
- Language: Swift
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
snacker
## Description
Snacker is a modern, lightweight Swift framework for displaying customizable snackbars and toast notifications in iOS applications. Designed with simplicity in mind, it allows developers to present any custom view as a non-intrusive notification with flexible positioning and smooth animations.
## Features
โจ Custom Views โ Display any UIView as a snackbar
๐ Flexible Positioning โ Support for top and bottom screen alignments
๐ฌ Smooth Animations โ Fully configurable transition durations
๐ฏ Simple API โ Single-line execution via a shared service
๐ฑ Modern Swift โ Built for Swift 6.0 and iOS 17.0+
โก Lightweight โ Minimal overhead with zero external dependencies
๐งช Well Tested โ Reliable performance for production environments
## Table of Contents
* [Requirements](#requirements)
* [Installation](#installation)
* [Quick Start](h#quick-start)
* [Usage](#usage)
* [Custom View Implementation](#custom-view-implementation)
* [Communication](#communication)
* [Contributing](#contributing)
* [Development Setup](#development-setup)
## Requirements
| Platform | Minimum Version |
| --- | --- |
| iOS | 17.0+ |
| Xcode | 16.0+ |
| Swift | 6.0+ |
## Installation
### Swift Package Manager
Add the following dependency to your `Package.swift`:
```swift
dependencies: [
.package(url: "https://github.com/space-code/snacker.git", from: "1.0.1")
]
```
Or add it through Xcode:
1. File > Add Package Dependencies
2. Enter package URL: `https://github.com/space-code/snacker.git`
3. Select version requirements
## Quick Start
```swift
import Snacker
let myView = MyCustomView() // Any UIView subclass
Snacker.shared.action(
.snack(
view: myView,
data: SnackbarData(
snackbarAlignment: .top(spacing: 20),
animationDuration: 0.25
)
),
container: window
)
```
## Usage
### Custom View Implementation
You can display any view as a snackbar. Here is a practical example of creating and presenting a simple information toast:
```swift
import UIKit
import Snacker
// 1. Define your custom notification view
final class InfoToastView: UIView {
private let messageLabel = UILabel()
init(text: String) {
super.init(frame: .zero)
backgroundColor = .secondarySystemBackground
layer.cornerRadius = 10
messageLabel.text = text
messageLabel.textAlignment = .center
messageLabel.translatesAutoresizingMaskIntoConstraints = false
addSubview(messageLabel)
NSLayoutConstraint.activate([
messageLabel.topAnchor.constraint(equalTo: topAnchor, constant: 12),
messageLabel.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -12),
messageLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 16),
messageLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -16)
])
}
required init?(coder: NSCoder) { fatalError() }
}
// 2. Present the snackbar
func notifyUser() {
let toast = InfoToastView(text: "New message received!")
let config = SnackbarData(
snackbarAlignment: .bottom(spacing: 50),
insets: UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20),
animationDuration: 0.3
)
Snacker.shared.action(
.snack(view: toast, data: config),
container: self.view.window
)
}
```
## Communication
- ๐ **Found a bug?** [Open an issue](https://github.com/space-code/typhoon/issues/new)
- ๐ก **Have a feature request?** [Open an issue](https://github.com/space-code/typhoon/issues/new)
- โ **Questions?** [Start a discussion](https://github.com/space-code/typhoon/discussions)
- ๐ **Security issue?** Email nv3212@gmail.com
## Contributing
We love contributions! Please feel free to help out with this project. If you see something that could be made better or want a new feature, open up an issue or send a Pull Request.
### Development Setup
Bootstrap the development environment:
```bash
mise install
```
## Author
**Nikita Vasilev**
- Email: nv3212@gmail.com
- GitHub: [@ns-vasilev](https://github.com/ns-vasilev)
## License
Snacker is released under the MIT license. See [LICENSE](https://github.com/space-code/snacker/blob/main/LICENSE) for details.
---
**[โฌ back to top](https://www.google.com/search?q=%23snacker)**
Made with โค๏ธ by [space-code](https://github.com/space-code)