Giter Site home page Giter Site logo

trendingtechnology / sheeeeeeeeet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from danielsaidi/sheeeeeeeeet

0.0 2.0 0.0 14.84 MB

Sheeeeeeeeet is a Swift library for custom action sheets.

License: MIT License

Ruby 0.84% Swift 98.93% Objective-C 0.23%

sheeeeeeeeet's Introduction

Version Build Status CocoaPods Carthage Platform Swift 4.2 License Twitter: @danielsaidi

About Sheeeeeeeeet

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.

Sheeeeeeeeet's action sheets can be styled to look like a UIAlertController or a lot different. You can also customize how they are presented and dismissed.

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. The one above is just a start. When you have the basics under control, check out this example to see how you can take things one step further.

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. For a complete list of item types, click here.

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. For a complete guide, click here.

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.

Example App

This project contains an example app that demonstrates basic and advanced action sheet, as well as how to handle subclassing, appearances etc. Before you can run it you must install Carthage and run carthage update --platform iOS. You can then open the project and try out the different sheets and item types.

Contact me

I hope you like this library. Feel free to reach out if you have questions or if you want to contribute in any way:

License

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

sheeeeeeeeet's People

Contributors

danielsaidi avatar sebbo176 avatar senseiphonex avatar ullstrm avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.