Skip to content

Conversation

kkafar
Copy link
Member

@kkafar kkafar commented Feb 26, 2025

@kkafar kkafar marked this pull request as draft February 26, 2025 12:34
@hirbod
Copy link
Contributor

hirbod commented Mar 3, 2025

Just came here to say: amazing, exactly what I am looking for. Hopefully for both iOS and Android

@kkafar
Copy link
Member Author

kkafar commented May 5, 2025

Superseded by #2877

@kkafar kkafar closed this May 5, 2025
kligarski added a commit that referenced this pull request May 5, 2025
…#2877)

## Description

Allows `fitToContents` sheet's height to adapt to dynamic content on
iOS.

`contentWrapper:(RNSScreenContentWrapper *)contentWrapper
receivedReactFrame:(CGRect)reactFrame` receives many frames, some of
them contain the same dimensions. Calling `[self
setAllowedDetentsForSheet:sheetController to:detents animate:YES]`
mutliple times, even with the same `detents`, causes visual glitches
(dimming behing formSheet on iPhone/iPad and header on iPad have very
odd-looking animations).

Before, we would set `_didSetSheetAllowedDetentsOnController` to `YES`
after setting detents for the first time and then ignore all incoming
frames - including those with new height after content changed its
height. Now, we remember frame height we received, and when we receive a
new frame, we compare new height to the previous value. If it is
different, we update detents using `setAllowedDetentsForSheet`.

Supersedes
#2741.

Fixes
#2688.

## Changes

- replace boolean property `_didSetSheetAllowedDetentsOnController` with
float `_sheetFrameHeight`
- add `Test2877` test screen

## Screenshots / GIFs

| Before | After |
| ------ | ------ |
| <video
src="https://github.com/user-attachments/assets/52895e55-483d-4766-bca2-7550757f1868"
alt="before" /> | <video
src="https://github.com/user-attachments/assets/d3bf33c0-5186-40e5-9b41-77aa31936cec"
alt="after" /> |

## Test code and steps to reproduce

Enter `Test2877` screen and open form sheet. Its height should adapt to
displayed content every second.

## Checklist

- [x] Included code example that can be used to test this change
- [x] Ensured that CI passes

---------

Co-authored-by: Kacper Kafara <[email protected]>
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.

2 participants