https://github.com/johankool/drawer
A Maps like drawer for iOS.
https://github.com/johankool/drawer
cocoa drawer ios iphone maps sheet swift
Last synced: 8 months ago
JSON representation
A Maps like drawer for iOS.
- Host: GitHub
- URL: https://github.com/johankool/drawer
- Owner: johankool
- License: mit
- Created: 2018-11-10T00:34:29.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-11-04T12:19:38.000Z (over 4 years ago)
- Last Synced: 2025-10-21T10:50:36.678Z (8 months ago)
- Topics: cocoa, drawer, ios, iphone, maps, sheet, swift
- Language: Swift
- Homepage:
- Size: 63.5 KB
- Stars: 9
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# 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
[](https://cocoapods.org/pods/JKDrawer)
[](https://github.com/Carthage/Carthage)
[](https://github.com/Carthage/Carthage)
## Requirements
- iOS 10.0+
- Xcode 10.2+
- Swift 4+
## Installation
### CocoaPods
[CocoaPods](https://cocoapods.org) 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`:
```ruby
pod 'JKDrawer', '~> 0.6.0'
```
### Carthage
[Carthage](https://github.com/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`:
```ogdl
github "johankool/Drawer" ~> 0.6.0
```
### Swift Package Manager
The [Swift Package Manager](https://swift.org/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.
```swift
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.
```swift
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](LICENSE.md)