/ Action Sheet

A Swift library for custom action sheets

A Swift library for custom action sheets

Sheeeeeeeeet

Sheeeeeeeeet is a Swift library for custom action sheets.

Sheeeeeeeeet is a Swift library for creating custom action sheets. It comes with many built-in components and can be extended with your own custom components.

Demo

Installation

CocoaPods

To install Sheeeeeeeeet with CocoaPods, add this to your Podfile:

pod 'Sheeeeeeeeet'

Carthage

To install Sheeeeeeeeet with Carthage, add this to your Cartfile:

github "danielsaidi/Sheeeeeeeeet"

Manual installation

To add Sheeeeeeeeet to your app without Carthage or CocoaPods, clone this repo
and place it somewhere on disk, then add Sheeeeeeeeet.xcodeproj to the project
and add Sheeeeeeeeet.framework as an embedded app binary and target dependency.

Basic example

The most basic way to create an action sheet, is to specify items and the select
action, like this:

let title = ActionSheetTitle(title: "Select a value type")
let item1 = ActionSheetItem(title: "Int", value: 1)
let item2 = ActionSheetItem(title: "String", value: "Hi!")
let item3 = ActionSheetItem(title: "Car", value: Car())
let button = ActionSheetOkButton(title: "OK")
let items = [title, item1, item2, item3, button]
let sheet = ActionSheet(items: items) { sheet, item in
    if let value = item.value as? Int { print("You selected an int: \(value)") }
    if let value = item.value as? String { print("You selected a string: \(value)") }
    if let value = item.value as? Car { print("You selected a car") }
    if item.isOkButton { print("You tapped the OK button") }
}

To present the action sheet, just call any of its present functions, like this:

sheet.present(in: self, from: view, completion: ...)   // or
sheet.present(in: self, from: barButtonItem, completion: ...)

The from view is optional and is only used if the action sheet it presented in
a popover.

Advanced example

You can use Sheeeeeeeeet to create really basic action sheets like the one above,
as well as very competent and self-contained ones.

Item Types

Sheeeeeeeeet comes with many built-in item types, e.g. regular items, single and
multi-select items, links, collection-based items, custom items, buttons, titles
etc.

Appearance

Sheeeeeeeeet lets you fully customize the appearances of action sheets and their
views and items. You can change fonts, colors and images as well as item heights
and even more stuff.

Specifying items after initialization

If you require a created action sheet instance to resolve which items to present
(very common when you subclass ActionSheet), just create a sheet with no items
then call setup(with:) once its created.

GitHub