Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/slackhq/PanModal
An elegant and highly customizable presentation API for constructing bottom sheet modals on iOS.
https://github.com/slackhq/PanModal
Last synced: about 2 months ago
JSON representation
An elegant and highly customizable presentation API for constructing bottom sheet modals on iOS.
- Host: GitHub
- URL: https://github.com/slackhq/PanModal
- Owner: slackhq
- License: mit
- Created: 2019-02-26T01:15:57.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-14T12:12:47.000Z (10 months ago)
- Last Synced: 2024-10-24T17:48:58.952Z (3 months ago)
- Language: Swift
- Homepage:
- Size: 32 MB
- Stars: 3,678
- Watchers: 46
- Forks: 530
- Open Issues: 93
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cocoa - PanModal
- awesome - PanModal - An elegant and highly customizable presentation API for constructing bottom sheet modals on iOS.【 [Preview](https://github.com/slackhq/PanModal/raw/master/Screenshots/panModal.gif) 】 (iOS / FloatingPanel)
- awesome - PanModal - An elegant and highly customizable presentation API for constructing bottom sheet modals on iOS.【 [Preview](https://github.com/slackhq/PanModal/raw/master/Screenshots/panModal.gif) 】 (iOS / FloatingPanel)
README
### PanModal is an elegant and highly customizable presentation API for constructing bottom sheet modals on iOS.
Features
• Compatibility
• Installation
• Usage
• Documentation
• Contributing
• Authors
• License
Read our blog on how Slack is getting more :thumbsup: with PanModalSwift 4.2 support can be found on the `Swift4.2` branch.
## Features
* Supports any type of `UIViewController`
* Seamless transition between modal and content
* Maintains 60 fps performance## Compatibility
PanModal requires **iOS 10+** and is compatible with **Swift 4.2** projects.
## Installation
* CocoaPods:
```ruby
pod 'PanModal'
```* Carthage:
```ruby
github "slackhq/PanModal"
``````swift
dependencies: [
.package(url: "https://github.com/slackhq/PanModal.git", .exact("1.2.6")),
],
```## Usage
PanModal was designed to be used effortlessly. Simply call `presentPanModal` in the same way you would expect to present a `UIViewController`
```swift
.presentPanModal(yourViewController)
```The presented view controller must conform to `PanModalPresentable` to take advantage of the customizable options
```swift
extension YourViewController: PanModalPresentable {var panScrollable: UIScrollView? {
return nil
}
}
```### PanScrollable
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
```swift
class TableViewController: UITableViewController, PanModalPresentable {var panScrollable: UIScrollView? {
return tableView
}
}
```### Adjusting Heights
Height values of the panModal can be adjusted by overriding `shortFormHeight` or `longFormHeight`
```swift
var shortFormHeight: PanModalHeight {
return .contentHeight(300)
}var longFormHeight: PanModalHeight {
return .maxHeightWithTopInset(40)
}
```### Updates at Runtime
Values are stored during presentation, so when adjusting at runtime you should call `panModalSetNeedsLayoutUpdate()`
```swift
func viewDidLoad() {
hasLoaded = truepanModalSetNeedsLayoutUpdate()
panModalTransition(to: .shortForm)
}var shortFormHeight: PanModalHeight {
if hasLoaded {
return .contentHeight(200)
}
return .maxHeight
}
```### Sample App
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.
## Documentation
Option + click on any of PanModal's methods or notes for detailed documentation.
## Contributing
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.
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).
## Authors
[Stephen Sowole](https://github.com/ste57) • [Tosin Afolabi](https://github.com/tosinaf)
## License
PanModal is released under a MIT License. See LICENSE file for details.