Repository navigation
DON-3911: BPKBottomSheet's modal style as a native sheet - #2694
Draft
Soheil Novinfard (novinfard) wants to merge 5 commits into
Draft
Soheil Novinfard (novinfard) wants to merge 5 commits into
Soheil Novinfard (novinfard) wants to merge 5 commits into
Conversation
The modal style is now a UISheetPresentationController page sheet, so UIKit sizes and places it for the window and lays it out again when the window changes, for example when a foldable folds or unfolds. The half and full positions map to custom detents, a sheet without a scroll view fits its content, the tracked scroll view drives the sheet, and the bottom section stays pinned. The public API is unchanged. The persistent style isn't presented, so it keeps the floating panel. Co-authored-by: OpenCode <noreply@opencode.ai>
…ve-bottom-sheet-poc Co-authored-by: OpenCode <noreply@opencode.ai>
Three differences showed up when the native sheet replaced the floating panel for the modal style: - The content and bottom section views were loaded when the sheet was presented, not when the bottom sheet was created. State set on them straight after creation could be lost. They are loaded on creation again. - A full position with no top inset was a custom height, so tall sheets came out shorter and detached from the screen edges. It now uses the system's large height, and a half height that reaches the tallest height leaves only the full position. - The sheet stayed attached to the edges in a compact-height window, so on a wide, short window it ran the full width. It now follows the system's default and is a centred card there. Co-authored-by: OpenCode <noreply@opencode.ai>
The modal style only uses the half inset. Its full position took the full inset off the tallest height, so a sheet whose half height already reached the top came out shorter than with the floating panel. The full position is now always the system's large height. Co-authored-by: OpenCode <noreply@opencode.ai>
The modal bottom sheet keeps the floating panel by default. The native sheet is used when BpkConfiguration is set with the new nativeBottomSheet config, so the two can be compared in an experiment. The config is not part of `all`, which stays the visual refresh set. Co-authored-by: OpenCode <noreply@opencode.ai>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BPKBottomSheet's modal style can now be presented as a nativeUISheetPresentationControllerpage sheet. It's behind a newBpkConfigurationconfig,.nativeBottomSheet, and off by default, so nothing changes until an app turns it on. The persistent style keeps the floating panel, because it sits inside its parent rather than being presented.Draft until design agrees the look.
Remember to include the following changes:
README.md: new section "Native sheet (behind configuration)"Backpack.hheader file: not needed, since the public API of the bottom sheet doesn't changeWhy
The floating panel draws its own surface, grabber and backdrop, and works out its own size, so it misses the window adaptation UIKit gives a native sheet. Every new window shape needs code here.
On a foldable, a sheet opened unfolded keeps its unfolded width after folding, centred on the smaller display, so its content is cut off on the left. Rotating a phone resizes it correctly; only the fold shows it. #2687 works around the panel's size with a readable-width cap (672 pt) and a 60% cap on the half and tip positions, and the 60% cap drops tall sheets when the text size changes with a sheet open.
A native sheet is laid out again by UIKit whenever the window changes, and on a wide window it's a centred card, with no code here.
The switch
.all, so it can be tested on its own.How the API maps
BPKBottomSheethalfpositionhalfinset's height (386 pt by default). Left out when it reaches the tallest heightfullpositionfullandtipinsets aren't usedscrollViewToTracksetContentScrollView(_:for:), so dragging the list at its top grows or shrinks the sheetbottomSectionViewControllermove(to:).hiddendismissesupdateLayout()invalidateDetents()onDismisseddelegate.bottomSheetDidChangePositionBPKCornerRadiusLgcorners,surfaceElevatedColorbackgroundThe sheet keeps its
BPKBottomSheetalive until it's dismissed, because callers that only presentviewControllerToPresentoften don't hold on to it. The content and bottom section views are loaded when the bottom sheet is created, as the floating panel did, because callers set state on them straight after.Differences to agree
tip. A modal sheet has no tip detent, somove(to: .tip)goes to half.Checked
Not checked yet