Skip to content

Add ability to trigger sheet to update its size #29

@mpospese

Description

@mpospese

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions