Git Product home page Git Product logo

drawer's Introduction

JKDrawer

A Maps like drawer for iOS.

Features:

  • control drawer size
  • snap to preferred sizes
  • multiple stacked drawers
  • dragging and closing using gestures
  • handling nested scroll views
  • subtle animations
  • no need to subclass view controllers

CocoaPods Compatible Carthage Compatible Swift Package Manager Compatible

Requirements

  • iOS 10.0+
  • Xcode 10.2+
  • Swift 4+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate JKDrawer into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'JKDrawer', '~> 0.6.0'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate JKDrawer into your Xcode project using Carthage, specify it in your Cartfile:

github "johankool/Drawer" ~> 0.6.0

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is included with Xcode 11+. To integrate JKDrawer into your Xcode project using Swift Package Manager, paste this URL into Xcode via File > Swift Packages > Add Package Dependency:

https://github.com/johankool/Drawer.git

Usage

To be able to present a view controller as a drawer it must conform to the DrawerPresentable protocol. This protocol requires that configuration variable is present. This is a DrawerConfiguration struct specifying certain aspects like initial offset and allowed range.

class DrawerViewController: UIViewController, DrawerPresentable {

    var configuration = DrawerConfiguration(offset: 300, isDraggable: true, isClosable: false)

}

The presenting view controller must conform to the DrawerPresenting protocol. Some methods have default implementations, others are callbacks for your convenience.

class HostViewController: UIViewController, DrawerPresenting {

    func someAction() {
        let drawerViewController = DrawerViewController()
        openDrawer(drawerViewController, animated: true)
    }

    func willOpenDrawer(_ drawer: DrawerPresentable) {

    }

    func didOpenDrawer(_ drawer: DrawerPresentable) {

    }

    func willCloseDrawer(_ drawer: DrawerPresentable) {

    }

    func didCloseDrawer(_ drawer: DrawerPresentable) {

    }

    func didChangeSizeOfDrawer(_ drawer: DrawerPresentable, to size: CGFloat) {

    }

}

Navigation Controllers

Since you can't open a drawer over a UINavigationController, consider using a custom view controller wrapping the UINavigationController instead or use DrawerNavigationController.

License

Copyright (c) 2018-2021 Johan Kool

Licensed under the MIT license

drawer's People

Contributors

7hommay avatar johankool avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.