Giter Club home page Giter Club logo

gtsheet's Introduction

No Longer Maintained

GTSheet is no longer used internally at Gametime, as we've migrated our apps to React Native. As such, this repository is no logner maintained or supported.

GTSheet

GTSheet is a a simple, easy to integrate solution for presenting UIViewController in bottom sheet. We handle all the hard work for you-- transitions, gestures, taps and more are all automatically provided by the library. Styling, however, is intentionally left out, allowing you to integrate your own design language with ease.

Installation

Carthage compatible

Carthage

github "gametimesf/GTSheet" == 1.1

Getting Started

The example project included is a great way to try out the features of GTSheet and experiment with some of the more advanced functionality. You can explore integrations for regular a UIViewController, a UIViewController that includes a UIScrollView, such as a UITableViewController. You can also explore a more complex example, using functionality to present a UIViewController above the bottom sheet.

Simple Integration

Getting started is easy. You'll need to conform to at least one protocol on the presented UIViewController. An optional protocol for your presented UIViewController makes presenting a bottom sheet faster and easier.

Required: HalfSheetPresentableProtocol

Implement HalfSheetPresentableProtocol on the UIViewController that you will be presenting in a bottom sheet.

public protocol HalfSheetPresentableProtocol: class {
    weak var managedScrollView: UIScrollView? { get }
    var dismissMethod: [DismissMethod] { get }
    var sheetHeight: CGFloat? { get }
}
public extension HalfSheetPresentableProtocol where Self: UIViewController {
    func didUpdateSheetHeight()
}

1.) managedScrollView provides a scroll view that will be used to trigger dismissal transitions. For example, a UITableViewController should return it's tableView property here.

2.) dismissMethod provides an array of DismissMethod options, such as .swipe, .tap. You may return all, some, or none of these options. When returning an empty set, you will be responsible for dismissing your own UIViewController.

3.) sheetHeight provides the height you would like your bottom sheet to be. UIScrollView subviews will overflow and scroll as expected. On iOS 11, Safe Area insets are automatically respected for you, and added to the total height you return. All HalfSheetPresentableProtocol conforming UIViewControllers are extended with a didUpdateSheetHeight method, which should be called to let the library know that it needs to adjust the height of your bottom sheet.

Optional: HalfSheetPresentingProtocol

Although you can manually instantiate HalfSheetPresentationManager and assign it as your HalfSheetPresentableProtocol's transitioningDelegate, conforming to HalfSheetPresentingProtocol gives your presenting UIViewController several convenience methods for presenting UIViewControllers in a bottom sheet.

public protocol HalfSheetPresentingProtocol: class {
    var transitionManager: HalfSheetPresentationManager! { get set }
}

public extension HalfSheetPresentingProtocol where Self: UIViewController {
    func presentUsingHalfSheet(_ vc: UIViewController, animated: Bool = true)
    @discardableResult func presentUsingHalfSheetInNC(_ vc: UIViewController, animated: Bool = true) -> UINavigationController
}

Advanced Features

HalfSheetCompletionProtocol

Implement this on your presenting UIViewController to receive a callback when your bottom sheet is dismissed.

HalfSheetAppearanceProtocol

Although most styling can be accomplished by using UIAppearance, some advanced changes are simply not possible. This protocol exposes additional styling options that will be handled within the library.

HalfSheetTopVCProviderProtocol

By conforming to this protocol on your presented UIViewController, you are able to provide a UIViewController that will fill the unused space above your bottom sheet.

gtsheet's People

Contributors

mikesilvis avatar manjirimoghe avatar ss18 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.