Skip to content
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

Add ability to trigger sheet to update its size #29

Open
mpospese opened this issue May 5, 2023 · 0 comments
Open

Add ability to trigger sheet to update its size #29

mpospese opened this issue May 5, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@mpospese
Copy link
Contributor

mpospese commented May 5, 2023

The Challenge

We recently added the LayoutSizable protocol so that both views and view controllers can report their layout size to the bottom sheet controller and the sheet can be the correct height when presented.

But what happens if that view (or view controller) changes size? e.g. new data arrives and the table view now has 6 rows instead of 4? How can the table view let the sheet know that it should recalculate its ideal size?

A Suggestion

  1. Add an overridable method invalidatesLayoutSize() to UIViewController. A table view controller could call this when its data changes.
  2. The default implementation of this method on UIViewController is to call the same method on its parent, thus moving it up the view controller chain until it finds a suitable responder (or reaches the top-level view controller).
  3. BottomSheetController override this method and instead of calling to its parent, it just calls updateChildView() which will then adjust the idealContentHeightAnchor by re-evaluating layoutSize on the child.
@mpospese mpospese added the enhancement New feature or request label May 5, 2023
@devkaranCT devkaranCT self-assigned this Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants