You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
4.4 KiB

  1. <p align="center">
  2. <img src="https://github.com/slackhq/PanModal/raw/master/Screenshots/panModal.gif" width="30%" height="30%" alt="Screenshot Preview" />
  3. </p>
  4. <p align="center">
  5. <img src="https://img.shields.io/badge/Platform-iOS_10+-green.svg" alt="Platform: iOS 10.0+" />
  6. <a href="https://developer.apple.com/swift" target="_blank"><img src="https://img.shields.io/badge/Language-Swift_4-blueviolet.svg" alt="Language: Swift 4" /></a>
  7. <a href="https://cocoapods.org/pods/PanModal" target="_blank"><img src="https://img.shields.io/badge/CocoaPods-v1.0-red.svg" alt="CocoaPods compatible" /></a>
  8. <a href="https://github.com/Carthage/Carthage" target="_blank"><img src="https://img.shields.io/badge/Carthage-compatible-blue.svg" alt="Carthage compatible" /></a>
  9. <img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License: MIT" />
  10. </p>
  11. <p align="center">
  12. <a href="#features">Features</a>
  13. <a href="#compatibility">Compatibility</a>
  14. <a href="#installation">Installation</a>
  15. <a href="#usage">Usage</a>
  16. <a href="#documentation">Documentation</a>
  17. <a href="#contributing">Contributing</a>
  18. <a href="#authors">Authors</a>
  19. <a href="#license">License</a>
  20. </p>
  21. ## Features
  22. * Supports any type of `UIViewController`
  23. * Seamless transition between modal and content
  24. * Maintains 60 fps performance
  25. ## Compatibility
  26. PanModal requires **iOS 10+** and is compatible with **Swift 4.2** projects.
  27. ## Installation
  28. * <a href="https://guides.cocoapods.org/using/using-cocoapods.html" target="_blank">CocoaPods</a>:
  29. ```ruby
  30. pod 'PanModal'
  31. ```
  32. * <a href="https://github.com/Carthage/Carthage" target="_blank">Carthage</a>:
  33. ```ruby
  34. github "slackhq/PanModal"
  35. ```
  36. ## Usage
  37. PanModal was designed to be used effortlessly. Simply call `presentPanModal` in the same way you would expect to present a `UIViewController`
  38. ```swift
  39. .presentPanModal(yourViewController)
  40. ```
  41. The presented view controller must conform to `PanModalPresentable` to take advantage of the customizable options
  42. ```swift
  43. extension YourViewController: PanModalPresentable {
  44. var panScrollable: UIScrollView? {
  45. return nil
  46. }
  47. }
  48. ```
  49. ### PanScrollable
  50. If the presented view controller has an embedded `UIScrollView` e.g. as is the case with `UITableViewController`, panModal will seamlessly transition pan gestures between the modal and the scroll view
  51. ```swift
  52. class TableViewController: UITableViewController, PanModalPresentable {
  53. var panScrollable: UIScrollView? {
  54. return tableView
  55. }
  56. }
  57. ```
  58. ### Adjusting Heights
  59. Height values of the panModal can be adjusted by overriding `shortFormHeight` or `longFormHeight`
  60. ```swift
  61. var shortFormHeight: PanModalHeight {
  62. return .contentHeight(300)
  63. }
  64. var longFormHeight: PanModalHeight {
  65. return .maxHeightWithTopInset(40)
  66. }
  67. ```
  68. ### Updates at Runtime
  69. Values are stored during presentation, so when adjusting at runtime you should call `panModalSetNeedsLayoutUpdate()`
  70. ```swift
  71. func viewDidLoad() {
  72. hasLoaded = true
  73. panModalSetNeedsLayoutUpdate()
  74. panModalTransition(to: .shortForm)
  75. }
  76. var shortFormHeight: PanModalHeight {
  77. if hasLoaded {
  78. return .contentHeight(200)
  79. }
  80. return .maxHeight
  81. }
  82. ```
  83. ### Sample App
  84. Check out the [Sample App](https://github.com/slackhq/PanModal/tree/master/Sample) for more complex configurations of `PanModalPresentable`, including navigation controllers and stacked modals.
  85. ## Documentation
  86. Option + click on any of PanModal's methods or notes for detailed documentation.
  87. <p align="left">
  88. <img src="https://github.com/slackhq/PanModal/blob/master/Screenshots/documentation.png" width="50%" height="50%" alt="Screenshot Preview" />
  89. </p>
  90. ## Contributing
  91. We're glad to be open sourcing this library. We use it in numerous places within the slack app and expect it to be easy to use as well as modify; we've added extensive documentation within the code to support that.
  92. We will only be fixing critical bugs, thus, for any non-critical issues or feature requests we hope to be able to rely on the community using the library to add what they need. For more information, please read the [contributing guidelines](https://github.com/slackhq/PanModal/blob/master/CONTRIBUTING.md).
  93. ## Authors
  94. [Stephen Sowole](https://github.com/tun57) • [Tosin Afolabi](https://github.com/tosinaf)
  95. ## License
  96. <b>PanModal</b> is released under a MIT License. See LICENSE file for details.