Open jrz-afs opened 4 years ago
It's not supported. You could try adding a gesture recognizer or looking at the drawer position changes.
I am search that functionality too. I thought that it works that way out of the box. But not. Looking at the drawer position don't work (in 'PulleyViewController .drawerChangedDistanceFromBottom'), because it wont move or bounce below "closed" state. So change position delegate method did not called. Thanks, will add gesture recognizer manually. Hope it will help.
Sadly, but "UISwipeGestureRecognizer.direction = .down" don't work too. I have tried 'PulleyViewController.addDrawerGestureRecognizer'method, and also tried to add it on inner view. Gesture Handle function not called. Tap, Swipe Left, Swipe Right - works perfect. Swipe Up, Swipe Down - not.
So, seems "Swipe down to close" is not possible. It should be handled from Pulley, not externally.
Found solution to close from bottom position without gesture:
extension OfficeDetailsVC: PulleyDrawerViewControllerDelegate {
func drawerChangedDistanceFromBottom(drawer: PulleyViewController, distance: CGFloat, bottomSafeArea: CGFloat) {
previousPosition = nil
}
func partialRevealDrawerHeight(bottomSafeArea: CGFloat) -> CGFloat {
return bottomSafeArea + (UIScreen.main.bounds.height - bottomSafeArea) / 2
}
func collapsedDrawerHeight(bottomSafeArea: CGFloat) -> CGFloat {
let collapsedSize: CGFloat = 55.0
return bottomSafeArea + collapsedSize
}
func drawerPositionDidChange(drawer: Pulley.PulleyViewController, bottomSafeArea: CGFloat) {
if (drawer.drawerPosition.rawValue == PulleyPosition.collapsed.rawValue) && (previousPosition == drawer.drawerPosition.rawValue) {
drawer.setDrawerPosition(position: .closed, animated: true)
}
previousPosition = drawer.drawerPosition.rawValue
}
}
+1 for this, I'm not sure why this is not supported because sounds like a common feature to allow user to swipe down to dismiss the drawer For my case I'm using supportedDrawerPositions of [.partiallyRevealed, .closed] for a lot of the dialogs to replace popups and user can pull down to dismiss the drawer
Maybe somebody will find it useful. With ARGAMX workaround when drawer in .collapsed state it no longer moves down with finger. You can achieve closing with swipe even in this position, but it looks and feels unnatural. As workaround for this problem I've decided to sacrifice one of possible drawer positions and redefine heights, so .collapsed state is now 0 pixels height, and .partiallyRevealed is equal to previous .collapsed. Now I don't have .partiallyRevealed state at all, but have smooth transitions between any states and swipe to close imitation looking natural. If you don't want to sacrifice positions, you can add one more, but it can be pretty complicated task.
By default, you cannot swipe down from a "collapsed" state to a "closed" state. Is this supported out of the box via some property? If not, what is the best way to achieve this?
Thanks.