-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[NoQA] Perf: PlatormStackNavigation
- Use @react-navigation/native-stack
on mobile platforms
#37891
Conversation
This comment has been minimized.
This comment has been minimized.
e178a2d
to
73870c2
Compare
@cubuspl42 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@mountiny I think this PR is ready for review 👀 And from my testing experience - the second version feels much more stable than initial implementation 💪 |
@kirillzyusko for easier QA could you please list the test scenarios from the regressions in the PR body? QA will then have easier life once this hits staging |
@cubuspl42 Createing a new build, will you be able to test this one tomorrow? |
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪
|
src/libs/Navigation/AppNavigator/getRootNavigatorScreenOptions.ts
Outdated
Show resolved
Hide resolved
A tough one to review meaningfully. I left one minor comment. |
@kirillzyusko I would also appreciate some summary of the testing steps! Especially if you redacted them for clarity. |
@mountiny @cubuspl42 I update test steps 🙌 But you also can test any scenarios that you would like to test 👀 |
What I observe: on iOS Native it's right-to-left, on Android Native it's left-to-right. Is this expected? If so, the testing steps should specify it. |
@cubuspl42 I created a patch for that functionality on iOS, so you'll need to reinstall |
My bad! I did as you said, works as expected now in that aspect. |
Interestingly, on Android I'm able to go back using a gesture from both sides of the screen. Is it expected? native-stack-v2-android-compressed.mp4Actually, always takes two tries. Doesn't feel right. |
@cubuspl42 Yes. Actually this is system UI and yes, it can be triggered from any horizontal side of the app (i. e. left or right). And it's simply simulation of hardware/software button press (these buttons were widely adopted in Android < 10), but in Android 11 they decided to make navigation bar smaller and replace all buttons (back button/recent apps/home) with gestures. So when you perform gesture one time - it'll close a keyboard. When you do it a second time - it'll close a screen. So this is handled on OS level and it's not something that we can prevent (though we can override an action on the gesture and prevent screen from being hidden, but I wouldn't recommend to do that because many android users are using these system gestures to do a quick navigation in the app). |
I understand! Makes sense. |
Thanks for chugging along, @cubuspl42 what is your ETA on this one? |
I'm resuming the testing, ETA should be < 4h unless something bad is found |
You wrote "Not affected" in the Screenshots/Videos on non-Native platforms. Please don't do so in the future in cases like this. Your intention was not to affect these platforms, it's not clear from the change itself that they are not affected. On a related, but separate topic, the "Tests" sections should be written according to Expensify's "cross-platform 99% of the time" philosophy. Pragmatically speaking, you should note which steps are platform-specfic and you should cover all platforms. Even when it's something as simple as "Ensure that this and this and this interaction (still) works". |
Asking about this PR specifcially now: from which side should the search panel enter the screen on mobile web, by design and intention? |
On iOS Web, the automatic keyboard opening doesn't work for me. It's not clear if this is a regression or an unrelated known issue. Would you please clarify it? native-stack-v2-ios-web-compressed.mp4 |
I reviewed the PR and I haven't found any change request candidates. Great job! 💪 |
Reviewer Checklist
Screenshots/VideosAndroid: NativeWhatsApp.Video.2024-10-09.at.1.03.21.AM.mp4Android: mWeb ChromeiOS: NativeScreenRecording_10-09-2024.00-27-42_1.MP4iOS: mWeb SafariScreen.Recording.2024-10-08.at.11.46.24.PM.movMacOS: Chrome / SafariScreen.Recording.2024-10-08.at.11.01.55.PM-1.movMacOS: DesktopScreen.Recording.2024-10-09.at.12.53.38.AM-1.mov |
src/libs/Navigation/PlatformStackNavigation/types/NavigationOptions.ts
Outdated
Show resolved
Hide resolved
src/libs/Navigation/PlatformStackNavigation/types/NavigationOptions.ts
Outdated
Show resolved
Hide resolved
native?: NativeOnlyNavigationOptions; | ||
|
||
keyboardHandlingEnabled?: boolean; | ||
animation?: 'slide_from_left' | 'slide_from_right' | 'modal' | 'none'; |
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.
we have more transition animantions in src/libs/Navigation/PlatformStackNavigation/navigationOptions/animation/index.ts
we dont need it here ?
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.
@ishpaul777 I think this type is used only inside withAnimation
function and these 4 types acts as preset (for them we return animation + gesture-direction for example)
So I think they are kind of independent and I didn't refactor this part. Does it make sense?
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.
okay makes sense, Thanks for clarifying!
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.
these options for animation
is what the user/developer used in order for the PlatformStackNavigation to translate into platform specific navigation options.
We must keep these props in the type (animations
, presentation
)
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪 |
src/libs/Navigation/AppNavigator/createCustomPlatformStackBottomTabNavigator/BottomTabBar.tsx
Outdated
Show resolved
Hide resolved
src/libs/Navigation/AppNavigator/createCustomPlatformStackBottomTabNavigator/BottomTabBar.tsx
Outdated
Show resolved
Hide resolved
src/libs/Navigation/AppNavigator/createCustomPlatformStackBottomTabNavigator/BottomTabBar.tsx
Outdated
Show resolved
Hide resolved
if (selectedTab === SCREENS.HOME) { | ||
return; | ||
} | ||
const route = activeWorkspaceID ? (`/w/${activeWorkspaceID}/${ROUTES.HOME}` as Route) : ROUTES.HOME; |
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.
Is possible to put /w/${activeWorkspaceID}/${ROUTES.HOME}
on ROUTES.ts?
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.
@fabioh8010 again, I think it's copied/pasted code, so not sure if we need to do that 🙈
And additionally - is it possible to create dynamic routes in ROUTES.ts
? Or we want to add two routes and use ternary operator in BottomTabBar.tsx
and choose between two routes?
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.
Answered here
// There should always be WORKSPACE.INITIAL screen in the state to make sure go back works properly if we deeplinkg to a subpage of settings. | ||
if (!isAtLeastOneInState(state, SCREENS.WORKSPACE.INITIAL)) { | ||
// @ts-expect-error Updating read only property | ||
// noinspection JSConstantReassignment |
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.
What's the purpose of // noinspection JSConstantReassignment
?
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.
@fabioh8010 I think it's a copy-past of another code that was already present in the codebase.
We copied it, so now we have kind of two copies of this code, but I wouldn't worry too much, because in the second PR we will remove the original code 👀
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.
Answered here
...ibs/Navigation/PlatformStackNavigation/navigationOptions/convertToNativeNavigationOptions.ts
Outdated
Show resolved
Hide resolved
src/libs/Navigation/PlatformStackNavigation/navigationOptions/convertToWebNavigationOptions.ts
Outdated
Show resolved
Hide resolved
...ibs/Navigation/PlatformStackNavigation/navigationOptions/convertToNativeNavigationOptions.ts
Outdated
Show resolved
Hide resolved
src/libs/Navigation/PlatformStackNavigation/navigationOptions/convertToWebNavigationOptions.ts
Outdated
Show resolved
Hide resolved
i agree with @kirillzyusko that we shouldn't add extra types for the animations defined in |
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.
Approved from TS side
@mountiny do we wait a review from someone else? 👀 |
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.
LGTM!
return slideFromLeft as PlatformSpecificNavigationOptions; | ||
case Animations.SLIDE_FROM_RIGHT: | ||
return slideFromRight as PlatformSpecificNavigationOptions; | ||
case 'modal': |
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.
Would be nice to have this as const too
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.
Nice, code LGTM. Great work here. Im hype for the performance gains with this 🙂
Gonna proceed and merge to keep this moving. Vit left a minor comment but we can address it in the follow up PR. |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/chiragsalian in version: 9.0.47-1 🚀
|
PlatormStackNavigation
- Use @react-navigation/native-stack
on mobile platformsPlatormStackNavigation
- Use @react-navigation/native-stack
on mobile platforms
🚀 Deployed to production by https://github.com/thienlnam in version: 9.0.47-4 🚀
|
Details
Implements a components and types for a
PlatformStackNavigation
, which uses Stack Navigator on web/desktop/mWeb and Native Stack Navigator on mobile.There is another PR which migrates the App to use the PlatformStackNavigation API: #49937
Native Stack Navigator provides a way for your app to transition between screens where each new screen is placed on top of a stack. This creates a more natural feel on mobile platforms and improves performance, since native screen transitions don't get blocked if the JS thread is blocked.
This was discussed here: #vip-newdot-performance
Warning
This is a second revision of the implementation. The first one caused a lot of issues, especially when it comes to keyboard appearance on iOS, transition events detection on Android. A successor of #29991
The main difference comparing to the first version of implementation is the fact that now we use
native-stack
everywhere on mobile. Before, on different stack navigators level we were using different navigators.Some libraries had to be patched in order for this PR to work:
@react-navigation/core
: Exposed types by exporting them and added/adapted some of the generic parameters, so that we can forward navigator'sParamList
s@react-navigation/native-stack
: Add thekeyboardHandlingEnabled
prop onnative-stack
react-native-screens
: Add theios_from_left
animation <- This is already merged upstream but not in any stable release yetFixed Issues
$ #37923
$ #29948
PROPOSAL: #29948
Tests
No specific tests steps as this PR is not putting the new navigator in use yet. The testing will be done here #49937
Offline tests
Not needed.
QA Steps
No specific tests steps as this PR is not putting the new navigator in use yet. The testing will be done here #49937
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
telegram-cloud-document-2-5442872807086113148.mp4
Android: mWeb Chrome
telegram-cloud-document-2-5449560084050887588.mp4
iOS: Native
76cd68bb-6ef8-46d7-9609-cf0ad3964289.mp4
iOS: mWeb Safari
5aa0fca4-72a3-4441-a56f-57da3d095883.mp4
MacOS: Chrome / Safari
a8d30d7e-8aad-4ac0-affe-83ab19584109.mp4
MacOS: Desktop
f6fe3999-d45a-49a2-9e6a-cc5c8e5764d3.mp4
MacOS Chrome (Arc) screen recording attached.