Skip to content

Display iOS 13 style banner with ease.

License

Notifications You must be signed in to change notification settings

gianpispi/Bauletto

Repository files navigation

Bauletto

Carthage Swift Package Manager iOS Twitter: @gianpispi

Lightweight iOS 13 badge like with ease.

Preview

Bauletto

Features

  • Highly customizable ✅
  • iPhone, iPhone X, & iPad Support ✅
  • Orientation change support ✅
  • Haptic feeback support ✅

Requirements

  • iOS 10.0+
  • Xcode 10.0+

Installation

Carthage

In order to use Bauletto via Carthage simply add this line to your Cartfile:

Swift 5

github "gianpispi/Bauletto"

Then add Bauletto.framework in your project.

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding Bauletto as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
.package(url: "https://github.com/gianpispi/Bauletto.git", from: "1.0.6")
]

Usage

Creating a Bauletto is simple as this:

let settings = BaulettoSettings(icon: UIImage(systemName: "checkmark.seal.fill", withConfiguration: UIImage.SymbolConfiguration(weight: .semibold)), title: "It works")
Bauletto.show(withSettings: settings)

If you want to change the tint color of the Bauletto, just use the tintColor value in the BaulettoSettings declaration as follows:

let settings = BaulettoSettings(icon: UIImage(systemName: "checkmark.seal.fill", withConfiguration: UIImage.SymbolConfiguration(weight: .semibold)), title: "It works", tintColor: .red)
Bauletto.show(withSettings: settings)

To change the background blur effect, add the backgroundStyle:

let settings = BaulettoSettings(icon: UIImage(systemName: "checkmark.seal.fill", withConfiguration: UIImage.SymbolConfiguration(weight: .semibold)), title: "It works", backgroundStyle: .dark)
Bauletto.show(withSettings: settings)

You can even change the dismissMode, which can be .never, automatic or .custom(seconds: 2). By default it uses the automatic.

let settings = BaulettoSettings(icon: UIImage(systemName: "checkmark.seal.fill", withConfiguration: UIImage.SymbolConfiguration(weight: .semibold)), title: "It works", dismissMode: .never)
Bauletto.show(withSettings: settings)

You can also change the duration of the show animation. By default it uses 1.0 second.

let settings = BaulettoSettings(icon: UIImage(systemName: "checkmark.seal.fill", withConfiguration: UIImage.SymbolConfiguration(weight: .semibold)), title: "It works", dismissMode: .never, fadeInDuration: 2.0)
Bauletto.show(withSettings: settings)

Bauletto has a personal queue for the banners that will show up. When you show a banner you can select where in the queue it will be put. By default it is .end.

public enum QueuePosition {
	case beginning, end
}

Bauletto.show(withSettings: settings, queuePosition: .beginning)

When you want to show up a new message immediately, add it by using the show() function, and then use:

Bauletto.shared.forceShowNext()

Do you have a bunch of settings in the queue and you want to remove them? No problem.

Bauletto.shared.removeBannersInQueue()

Bauletto can also have an action for a tap gesture. If you pass the action parameter, it will call the closure once the user tapped the banner.

let settings = BaulettoSettings(icon: UIImage(systemName: "checkmark.seal.fill", withConfiguration: UIImage.SymbolConfiguration(weight: .semibold)), title: "It works", dismissMode: .never, action: { 
    print("Hello, my name is Bauletto, and you tapped me!")
})
Bauletto.show(withSettings: settings)

Haptic Feedback Support

You can also set a haptic feedback when the Bauletto shows up. By default, no haptic feedback will be generated. The types of haptic feedback are as follows:

public enum HapticStyle {
    case notificationError
    case notificationWarning
    case notificationSuccess
    
    case light
    case medium
    case heavy
    case none
    
    case soft
    case rigid
}

To change the style of haptic feedback, simply declare it in the BaulettoSettings initialization:

let settings = BaulettoSettings(icon: UIImage(systemName: "checkmark.seal.fill"), title: "It works", backgroundStyle: .systemChromeMaterial, dismissMode: .automatic, hapticStyle: .notificationSuccess)

Feature Requests

I'd love to know improve Bauletto as much as I can. Feel free to open an issue and I'll do everything I can to accomodate that request if it is in the library's best interest. Or just create a pull request and I'll check it out.

Author

Gianpiero Spinelli, gianpiero@grspinelli.it

License

Bauletto is available under the MIT license. See the LICENSE file for more info.