-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support modal presentation on top of the drawer. #56
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,23 +23,15 @@ extension PresentationController { | |
|
||
switch panGesture.state { | ||
case .began: | ||
lastDrawerState = GeometryEvaluator.drawerState(for: currentDrawerY, | ||
drawerPartialHeight: drawerPartialHeight, | ||
containerViewHeight: containerViewHeight, | ||
configuration: configuration, | ||
clampToNearest: true) | ||
break | ||
|
||
case .changed: | ||
lastDrawerState = GeometryEvaluator.drawerState(for: currentDrawerY, | ||
drawerPartialHeight: drawerPartialHeight, | ||
containerViewHeight: containerViewHeight, | ||
configuration: configuration, | ||
clampToNearest: true) | ||
currentDrawerY += panGesture.translation(in: view).y | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
targetDrawerState = currentDrawerState | ||
currentDrawerCornerRadius = cornerRadius(at: currentDrawerState) | ||
panGesture.setTranslation(.zero, in: view) | ||
|
||
case .ended: | ||
case .ended, .cancelled: | ||
let drawerSpeedY = panGesture.velocity(in: view).y / containerViewHeight | ||
let endingState = GeometryEvaluator.nextStateFrom(currentState: currentDrawerState, | ||
speedY: drawerSpeedY, | ||
|
@@ -48,9 +40,6 @@ extension PresentationController { | |
configuration: configuration) | ||
animateTransition(to: endingState) | ||
|
||
case .cancelled: | ||
animateTransition(to: lastDrawerState) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And, likewise, I don't understand the reason for removing this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, if the user starts dragging the drawer up then changes his mind, the drawer continues up anyway? That doesn't sound right to me. |
||
|
||
default: | ||
break | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,10 @@ class PresentedViewController: UIViewController { | |
} | ||
} | ||
} | ||
|
||
@IBAction func unwindFromModal(with segue: UIStoryboardSegue) { | ||
print("Unwound from the modal.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this going to be removed at some point? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. It is the Storyboard unwind point for dismissing the modal in the demo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant the print statement. |
||
} | ||
} | ||
|
||
extension PresentedViewController: UIScrollViewDelegate { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why you're no longer setting
lastDrawerState
here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not necessary to update it during the course of the pan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lastDrawerState
is not really consumed by anything until this PR, by the way.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be, for the benefit of along-side animations performed by the presenting and/or presented view controllers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After looking into this,
changed
is actually updating thetargetDrawerState
(renamed fromlastDrawerState
).