-
-
Notifications
You must be signed in to change notification settings - Fork 531
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
Add "hidden" prop to Screen
to support iOS Picture-in-Picture
#1665
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jaredly 👋
I think thanks to this PR we've made a full circle in react-native-screens
development 😅
Screens where developed to fight a problem directly opposite to what you are facing - freeing resources of a screen that the user can't see.
In Stack, Drawer and Bottom Tabs navigators there's a prop to disable this optimisation (disabling screens) - detachInactiveScreens
. I think using a JS stack with screens
disabled should work well for your use-case.
Fair, there's no prop like this in native-stack because it always felt like a step back but maybe, as you've presented a valid use-case, we should consider adding it
Interesting! I think |
btw I put together a minimal react-native project illustrating the issue: https://github.com/jaredly/rnsdemo |
@kacperkapusciak for what it's worth, switching to the js-implemented stack didn't help with the "originating view needs to stick around for PIP to keep going" smol.mp4 |
@kkafar sorry to bump, but this feature is blocking our adoption of react-native-screens & react-navigation. Anything I can do to make this easier to review? |
Sorry for the delay! I'm recently a little bit buried in todo stuff. I'll try to take care of this PR soon. |
bump? 🙏 |
…ns into khan-rebase
@kkafar it would be really nice to get this merged in! Is there anything I can do on my end? I'd love to stop depending on a fork. |
Very good feature, seems like so many valid and good PRs are stale in RNS. @kkafar I don't want to sound harsh, but I went through quite a bit of PRs (including mine) and most of the "looking into it soon" answers been months already. Anything we can do to help here? |
Hey, @hirbod, @maksg is currently assigned to implementing API for As to the "stale PRs" I think you're absolutely right & I do remember about the PR of yours. Moreover we appreciate every PR. Currently in |
According to changes from this PR, I believe these changes have been superseded by checking if activityState from screen is inactive? |
Description
Thanks for making this wonderful library! I've really enjoyed using it with react-navigation. I'm transitioning a large app from custom native navigation code (written before we adopted react-native) to react-navigation, and the only thing I'm having trouble with is iOS Picture-In-Picture.
If you're unfamiilar, Picture-in-Picture (PIP) refers to popping a video out into an "overlay" that persists as you navigate around the app, until you either close it or "restore" it, which results in the originating screen being pushed back onto the stack, and the video sliding back into its original location.
Here's a little video of that in action, for context:
pip.mp4
There are two things needed to support PIP well:
onRestoreUserInterfaceForPictureInPictureStop
callback for react-native-video).Changes
The solution I've arrived at requires fairly minimal changes to react-native-screens, just adding a single
hidden
prop to theScreen
component, which instructs the ScreenStack to ignore that screen for the purposes of constructing the arrays of ViewControllers. Additionally, when the hidden prop is modified (for the case of "bringing back" a dismissed screen), I clear the_dismissed
flag.The above screen recording demonstrates this change, in concert with the react-navigation changes.
Test code and steps to reproduce
Here's a minimal repo illustrating the problem behavior: https://github.com/jaredly/rnsdemo
And a video:
https://user-images.githubusercontent.com/112170/207732805-7750c1e8-7276-4f51-9244-f86ec312092b.mp4
Checklist