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

RFC + WIP: FullWindowOverlay on android #2421

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mfazekas
Copy link
Contributor

@mfazekas mfazekas commented Oct 20, 2024

Description

FullWindowOverlay implementation for android

TODO:

  • EventHandling

Changes

  • Added FullWindowOverlay implementation for android

The implementation is adding a FullWindowOverlayRootView to the window for every FullWindowOverlay, FullWindowOverlay on native side is just a placeholder.

image

Screenshots / GIFs

Android iOS
android android

Test code and steps to reproduce

See:
https://github.com/mfazekas/react-native-screens/blob/6f081fc33f1b8165df194eb3dd9ee42504c0d415/apps/src/tests/TestFullWindowOverlay.tsx#L1C1-L30C2

Checklist

@maciekstosio
Copy link
Contributor

maciekstosio commented Oct 21, 2024

Hi, thanks for this PR! The problem is a little bit more complex, I started to work on it but needed to switch focus to something else. Correct me if I'm wrong:

  • If you click in the overlay the the app will crash
  • Overlay is not edge to edge
  • Opening RN Modal after overlay will cover the overlay

We need to try to tackle those problems because in this state it doesn't give us any advantage over RN Modal. I've created a draft with my changes - the PR #2425 is messy, but it may give you some insights - I was able to solve some of the problems:

As far as I remember crashes can be solved by hardcoding the ID for the view:

Passing events could be solved by dispatching the event to RootView of the FullWinowOverlay (the placeholder):

⚠️ Sometimes touches were translated in the underlying view (I think just in RN modals) or didn't work (depending on LayoutParams). The translation might be related to changes in the shadow tree for top Header:

void RNSScreenShadowNode::applyFrameCorrections() {

To go edge to edge I used different LayoutParams and setting width height in ShadowNode:


Being on top of everything:

⚠️ This was the closest to the desired outcome, but it requires granting "draw over other apps" permission, which we can't force users to enable - so we'll probably put it behind some flag for devs to decide. So, probably, the best for us will be to not support RN models and opt-in support for the permission behind the flag. We could try to reopen the window after each modal, but there isn't a clean way of observing if the RN modal is open: facebook/react-native#45534, software-mansion/react-native-reanimated#5916 (comment)

Btw. I'm not saying any of those solutions are the best approaches to tackle the issues - I'm open for discussion. Once again thanks for spending the time, and I'd be thrilled to work with you on getting it done.

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