Skip to content

Partial sheet expansion support#2149

Merged
lukas-cap merged 7 commits intomicrosoft:mainfrom
lukas-cap:genericDetentResolver
May 8, 2025
Merged

Partial sheet expansion support#2149
lukas-cap merged 7 commits intomicrosoft:mainfrom
lukas-cap:genericDetentResolver

Conversation

@lukas-cap
Copy link
Copy Markdown
Contributor

@lukas-cap lukas-cap commented May 7, 2025

Platforms Impacted

  • iOS
  • visionOS
  • macOS

Description of changes

Adds support for a new partial expansion state to bottom sheet. Most of the diff is fairly simple, the main behavioral change is that on pan end, we don't just determine the target state based on direction + velocity, but also position to see if we go towards .partial, .expanded, or .collapsed.

The other bigger change is the addition of the partialHeightResolver, which is needed to pull fresh height from the client. It follows design of the existing collapsedHeightResolver. I chose to cache them together, because we usually pull them together as well.

Some semantic choices had to be made, like isExpanded still maps to .expanded, which also means tapping the resizing handle while in .partial state takes the sheet to .expanded. That choice is fairly arbitrary, given that .partial is in-between by definition.

To enable the partial state, we don't have a distinct bool - it's just inferred from the existence of the partialHeightResolver.

Verification

Various manual testing in the demo app + sanity check with client team to early integrate and test E2E. Restricted height scenarios, landscape / portrait changes - verifying sheet frame recalculates to correct new calue.

Visual Verification
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-05-07.at.17.55.31.mp4

Pull request checklist

This PR has considered:

  • Light and Dark appearances
  • iOS supported versions (all major versions greater than or equal current target deployment version)
  • VoiceOver and Keyboard Accessibility
  • Internationalization and Right to Left layouts
  • Different resolutions (1x, 2x, 3x)
  • Size classes and window sizes (iPhone vs iPad, notched devices, multitasking, different window sizes, etc)
  • iPad Pointer interaction
  • SwiftUI consumption (validation or new demo scenarios needed)
  • Objective-C exposure (provide it only if needed)
Microsoft Reviewers: Open in CodeFlow

Lukas Capkovic added 2 commits May 6, 2025 18:08
@lukas-cap
Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Microsoft"

@lukas-cap lukas-cap marked this pull request as ready for review May 8, 2025 00:58
@lukas-cap lukas-cap requested a review from a team as a code owner May 8, 2025 00:58
@lukas-cap lukas-cap changed the title Draft: Partial sheet expansion support Partial sheet expansion support May 8, 2025
@amoggo
Copy link
Copy Markdown
Contributor

amoggo commented May 8, 2025

Don't we care to add some default value for the partial height if the client doesn't provide it in the partialHeightResolver? In which case, we'd probably need a bool opt in to supportsPartialHeight

@lukas-cap
Copy link
Copy Markdown
Contributor Author

Don't we care to add some default value for the partial height if the client doesn't provide it in the partialHeightResolver? In which case, we'd probably need a bool opt in to supportsPartialHeight

The way it's designed now, it's a fully opt-in feature, so we shouldn't have cases where we're trying to resolve a height and the resolver isn't there. And if it's there but doesn't return a valid value - that's a client side bug.

We could have a separate bool and a default, but I'm leaning towards not adding that unless this becomes a heavily used feature. My expectation is that this will be used rarely, and often it's straight up not good UX to have that many detents.

@lukas-cap lukas-cap merged commit c50d02e into microsoft:main May 8, 2025
7 checks passed
lukas-cap added a commit that referenced this pull request May 12, 2025
Co-authored-by: Lukas Capkovic <3610850+lukas-cap@users.noreply.github.com>
@mischreiber mischreiber mentioned this pull request Jun 13, 2025
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants