-
Notifications
You must be signed in to change notification settings - Fork 780
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
When device orientation change reset the modal dialog context frame Fix #515 #516
When device orientation change reset the modal dialog context frame Fix #515 #516
Conversation
Generated by 🚫 Danger |
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.
Thanks for fixing that 👍
@@ -179,4 +179,10 @@ open class AnimatableModalViewController: UIViewController, PresentationDesignab | |||
super.viewDidAppear(animated) | |||
configureDismissalTransition() | |||
} | |||
|
|||
open override func viewDidLayoutSubviews() { |
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 that's safe to use viewDidLayoutSubviews
, it will update the UI when any UI has been changed. Another way would be viewWillTransitionToSize:withTransitionCoordinator:
for size class. But I think viewDidLayoutSubviews
is fine.
Remove trailing whitespace
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.
Looks good!
@@ -103,12 +103,17 @@ public extension PresentationDesignable where Self: UIViewController { | |||
} | |||
} | |||
|
|||
public func configurePresenterFrameForPresentation() { | |||
presenter?.presentationConfiguration?.contextFrameForPresentation = contextFrameForPresentation?() | |||
print("presenter \( presenter?.presentationConfiguration?.contextFrameForPresentation)") |
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.
Could you remove this print?
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.
oups, I forgot to remove this one
I am not sure that this is the best solution but I try to fix it.
To detect device orientation change I override
AnimatableModalViewController. viewDidLayoutSubviews
When device orientation change I call the same code launched when updating
AnimatableModalViewController.contextFrameForPresentation
(I make a method for that
configurePresenterFrameForPresentation
)But how to update the frame without knowing the source, the segue, the parent view, ...?
I replace
contextFrameForPresentation
type fromCGRect
to closure to execute exactly the same code inPresentOverCurrentContextSegue
Maybe we can do better, find element in view hierarchy, make constraint, ...?
Then I see an issue, updating the
contextFrameForPresentation
in thepresenter
(configurePresenterFrameForPresentation
) do nothing.And I understand why. The
PresentationConfiguration
passed to the presentation controller is astruct
, so a copy and no update in presentation controller.By changing type to
class
, the object is shared.