8 Commits

Author SHA1 Message Date
Tosin Afolabi b012aecb6b bump version number. 2020-03-30 12:33:24 -07:00
Stephen Sowole 22b4ddd47e [PanModal] Track all dismiss events through panModalPresentable callbacks (#91) 2020-03-25 00:34:58 -07:00
Stephen Sowole 17a8231f20 Update README.md 2020-03-24 17:10:08 -07:00
Stephen Sowole 1819113e97 [ReadMe] Add link to Swift Package Manager 2020-02-27 09:10:21 -08:00
Stephen Sowole 208640e03e [PanModal] Round frame positions for comparison (#83) 2020-02-24 15:20:26 -08:00
Stephen Sowole f02439dc0c [PanModal] Fix issue with incorrect returned bottom offset value (#84) 2020-02-24 15:20:14 -08:00
Kyohei Ito 047415090a Fix Background dimming animation broken (#77) 2020-02-24 14:02:45 -08:00
Abdullah Selek 1e7c0534fc Use keyPath to read UIApplication.shared. (#81) 2020-02-12 13:02:33 -06:00
4 changed files with 38 additions and 24 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
Pod::Spec.new do |s|
s.name = 'PanModal'
s.version = '1.2.5'
s.version = '1.2.7'
s.summary = 'PanModal is an elegant and highly customizable presentation API for constructing bottom sheet modals on iOS.'
# This description is used to generate tags and improve search results.
@@ -113,7 +113,7 @@ open class PanModalPresentationController: UIPresentationController {
}
view.didTap = { [weak self] _ in
if self?.presentable?.allowsTapToDismiss == true {
self?.dismissPresentedViewController()
self?.presentedViewController.dismiss(animated: true)
}
}
return view
@@ -192,7 +192,14 @@ open class PanModalPresentationController: UIPresentationController {
})
}
override public func presentationTransitionDidEnd(_ completed: Bool) {
if completed { return }
backgroundView.removeFromSuperview()
}
override public func dismissalTransitionWillBegin() {
presentable?.panModalWillDismiss()
guard let coordinator = presentedViewController.transitionCoordinator else {
backgroundView.dimState = .off
@@ -210,10 +217,10 @@ open class PanModalPresentationController: UIPresentationController {
})
}
override public func presentationTransitionDidEnd(_ completed: Bool) {
if completed { return }
backgroundView.removeFromSuperview()
override public func dismissalTransitionDidEnd(_ completed: Bool) {
if !completed { return }
presentable?.panModalDidDismiss()
}
/**
@@ -311,7 +318,7 @@ private extension PanModalPresentationController {
var isPresentedViewAnchored: Bool {
if !isPresentedViewAnimating
&& extendsPanScrolling
&& presentedView.frame.minY <= anchoredYPosition {
&& presentedView.frame.minY.rounded() <= anchoredYPosition.rounded() {
return true
}
@@ -367,7 +374,8 @@ private extension PanModalPresentationController {
if ![shortFormYPosition, longFormYPosition].contains(panFrame.origin.y) {
// if the container is already in the correct position, no need to adjust positioning
// (rotations & size changes cause positioning to be out of sync)
adjust(toYPosition: panFrame.origin.y - panFrame.height + frame.height)
let yPosition = panFrame.origin.y - panFrame.height + frame.height
presentedView.frame.origin.y = max(yPosition, anchoredYPosition)
}
panContainerView.frame.origin.x = frame.origin.x
presentedViewController.view.frame = CGRect(origin: .zero, size: adjustedSize)
@@ -515,7 +523,7 @@ private extension PanModalPresentationController {
transition(to: .shortForm)
} else {
dismissPresentedViewController()
presentedViewController.dismiss(animated: true)
}
} else {
@@ -533,7 +541,7 @@ private extension PanModalPresentationController {
transition(to: .shortForm)
} else {
dismissPresentedViewController()
presentedViewController.dismiss(animated: true)
}
}
}
@@ -672,16 +680,6 @@ private extension PanModalPresentationController {
else { return number }
return nearestVal
}
/**
Dismiss presented view
*/
func dismissPresentedViewController() {
presentable?.panModalWillDismiss()
presentedViewController.dismiss(animated: true) { [weak self] in
self?.presentable?.panModalDidDismiss()
}
}
}
// MARK: - UIScrollView Observer
@@ -27,7 +27,11 @@ extension PanModalPresentable where Self: UIViewController {
Gives us the safe area inset from the top.
*/
var topLayoutOffset: CGFloat {
return UIApplication.shared.keyWindow?.rootViewController?.topLayoutGuide.length ?? 0
guard let rootVC = rootViewController
else { return 0}
if #available(iOS 11.0, *) { return rootVC.view.safeAreaInsets.top } else { return rootVC.topLayoutGuide.length }
}
/**
@@ -35,7 +39,11 @@ extension PanModalPresentable where Self: UIViewController {
Gives us the safe area inset from the bottom.
*/
var bottomLayoutOffset: CGFloat {
return UIApplication.shared.keyWindow?.rootViewController?.bottomLayoutGuide.length ?? 0
guard let rootVC = rootViewController
else { return 0}
if #available(iOS 11.0, *) { return rootVC.view.safeAreaInsets.bottom } else { return rootVC.bottomLayoutGuide.length }
}
/**
@@ -100,5 +108,13 @@ extension PanModalPresentable where Self: UIViewController {
}
}
private var rootViewController: UIViewController? {
guard let application = UIApplication.value(forKeyPath: #keyPath(UIApplication.shared)) as? UIApplication
else { return nil }
return application.keyWindow?.rootViewController
}
}
#endif
+2 -2
View File
@@ -54,7 +54,7 @@ pod 'PanModal'
github "slackhq/PanModal"
```
* Swift Package Manager, add the following line to your Package.swift:
* <a href="https://swift.org/package-manager/" target="_blank">Swift Package Manager</a>:
```swift
dependencies: [
@@ -147,7 +147,7 @@ We will only be fixing critical bugs, thus, for any non-critical issues or featu
## Authors
[Stephen Sowole](https://github.com/tun57) • [Tosin Afolabi](https://github.com/tosinaf)
[Stephen Sowole](https://github.com/ste57) • [Tosin Afolabi](https://github.com/tosinaf)
## License