Swift Package Index


A Maps like drawer for iOS.


  • The latest stable release is 0.9.0. Released 8 months ago.
  • The last commit to master was 8 months ago.

Swift Version Compatibility

  • 0.9.0 and master
    5.3
    5.2
    5.1
    5.0
    4.2
Full build results

Platform Compatibility

  • 0.9.0 and master
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
Full build results

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-2019 Johan Kool

Licensed under the MIT license