Giter Site home page Giter Site logo

sarojraut / sheeeeeeeeet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from danielsaidi/sheeeeeeeeet

0.0 1.0 0.0 15.95 MB

Sheeeeeeeeet is a Swift library for creating menus, custom action sheets, context menus etc.

License: MIT License

Swift 99.33% Ruby 0.67%

sheeeeeeeeet's Introduction

Version Platform Swift 5.1 License Twitter: @danielsaidi

About Sheeeeeeeeet

Sheeeeeeeeet lets you create menus. These menus can then be used as context menus, action sheets or in any way you like, in UIKit or in SwiftUI.

Sheeeeeeeeet comes with many item types (standard items, buttons, titles, toggles etc.) and can be extended with custom ones.

Sheeeeeeeeet's custom action sheets can be styled to look just like UIAlertControllers or completely different. You can also customize how they are presented and dismissed.

Installation

Swift Package Manager

The easiest way to add Sheeeeeeeeet to your project in Xcode 11 is to use Swift Package Manager:

https://github.com/danielsaidi/Sheeeeeeeeet.git

CocoaPods

pod "Sheeeeeeeeet"

Carthage

github "danielsaidi/Sheeeeeeeeet"

IMPORTANT There is currently problems with the Carthage installation, which cause Apple to reject apps that pull in Sheeeeeeeeeeet with Carthage. See this issue for more information. Until it's solved, use SPM or CocoaPods instead.

Manual installation

To add Sheeeeeeeeet to your app without a dependency manager, clone this repository, add Sheeeeeeeeet.xcodeproj to your project and Sheeeeeeeeet.framework as an embedded app binary and target dependency.

Creating a menu

With Sheeeeeeeeet, you start off by creating a menu, like this:

let item1 = MenuItem(title: "Int", value: 1)
let item2 = MenuItem(title: "Car", value: Car())
let button = OkButton(title: "OK")
let items = [item1, item2, button]
let menu = Menu(title: "Select a type", items: items)

There are many built-in menu item types, e.g. selectable items, links, buttons, titles, collections, custom items etc. A complete list can be found here.

Present the menu as an action sheet

You can then present the menu as a custom action sheet:

let sheet = menu.toActionSheet(...) { sheet, item in ... }
sheet.present(in: vc, from: view, ...)

You can find more information in this action sheet guide. You can also read more about styling the sheets in this appearance and styling guide.

Add the menu as a context menu

You can also apply the menu as an iOS 13 context menu to any view you like:

menu.addAsContextMenu(to: view, action: ...)

You can find more information in this context menu guide.

Present the menu as an alert controller

You can also present the menu as a UIAlertController:

let delegate = menu.presentAsAlertController(in: self, from: view, action: ...)

You can find more information in [this alert controller guide][Alert-Controllers].

Advanced example

When you have the basics under control, check out this advanced example to see how you can take things further.

Demo App

This repository contains a demo app that demonstrates different menus and menu items, including subclassing and appearance adjustments. To try it out, open and run the Sheeeeeeeeet.xcodeproj project.

Contact me

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 binarydennis avatar ullstrm avatar mohammadghk avatar senseiphonex avatar

Watchers

James Cloos 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.