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

Remove SCREEN from lightbox layout #6124

Merged
merged 12 commits into from
Nov 6, 2024
Merged

Remove SCREEN from lightbox layout #6124

merged 12 commits into from
Nov 6, 2024

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Nov 5, 2024

I want to get rid of these constants. They're subtly wrong in some cases, and it's very hard to think about the discrepancies due to safe insets. I want to change the code so that we rely on SafeAreaView and then everything is derived from its size.

I'm not entirely sure this approach is the way to go, but this constant just sucks so I think it's a step forward.

The approach is to use alternatives to hardcoding SCREEN:

  • On UI thread, use measure(safeAreaRef). This always gives the height matching the area where we draw the image.
    • Curiously this seems fine to do on every frame. So I'm just doing that unless proven wrong.
      • We might have to do something more fancy when adding orientation handling. But still better than before.
  • On JS thread, prefer to use <SafeAreaView> where possible.
    • This works well when we don't need to know the value in the actual JS code. The <SafeAreaView> code is native.
    • When we absolutely need to know the value in JS itself, fall back to useSafeAreaFrame().
      • Note it doesn't have the insets applied (which seems fine for the use case where we have it — measuring iOS width). We could always add useSafeAreaInsets if needed and subtract whichever ones we need manually.

Test Plan

This fixes incorrect positioning on Android device when double-tapping into an image. Verify that double-tapping on main shows a black bar beneath, but double-tapping in this branch does not. (This doesn't repro on emulator for me.)

Verify controls (header, footer) work like before. Verify buttons are clickable. With no alt text, short alt text, and very long alt text. Verify very long alt text expands on tap but the scroll view doesn't overlap the header controls. Verify that controls still work and display correctly when invoking them while zoomed in.

Verify you can pan and pinch into the image. Pinching into the image on device produces occasional flicker on Android, but this problem exists on main too. I'll need to look into that separately. (Fixed in #6126)

It would be good to check what happens with super tall images.

Copy link

github-actions bot commented Nov 5, 2024

Old size New size Diff
8.11 MB 8.11 MB 0 B (0.00%)

@arcalinea arcalinea temporarily deployed to lightbox-again-1 - social-app PR #6124 November 5, 2024 22:38 — with Render Destroyed
Copy link
Member

@mozzius mozzius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug confirmed fixed, could not see any regressions

@gaearon gaearon merged commit 206df2a into main Nov 6, 2024
6 checks passed
@gaearon gaearon deleted the lightbox-again-1 branch November 6, 2024 00:21
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.

3 participants