-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29991 from margelo/perf/native-stack-navigation
Perf/native stack navigation
- Loading branch information
Showing
18 changed files
with
173 additions
and
36 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
diff --git a/node_modules/@react-navigation/native-stack/src/types.tsx b/node_modules/@react-navigation/native-stack/src/types.tsx | ||
index 206fb0b..7a34a8e 100644 | ||
--- a/node_modules/@react-navigation/native-stack/src/types.tsx | ||
+++ b/node_modules/@react-navigation/native-stack/src/types.tsx | ||
@@ -490,6 +490,14 @@ export type NativeStackNavigationOptions = { | ||
* Only supported on iOS and Android. | ||
*/ | ||
freezeOnBlur?: boolean; | ||
+ // partial changes from https://github.com/react-navigation/react-navigation/commit/90cfbf23bcc5259f3262691a9eec6c5b906e5262 | ||
+ // patch can be removed when new version of `native-stack` will be released | ||
+ /** | ||
+ * Whether the keyboard should hide when swiping to the previous screen. Defaults to `false`. | ||
+ * | ||
+ * Only supported on iOS | ||
+ */ | ||
+ keyboardHandlingEnabled?: boolean; | ||
}; | ||
|
||
export type NativeStackNavigatorProps = DefaultNavigatorOptions< | ||
diff --git a/node_modules/@react-navigation/native-stack/src/views/NativeStackView.native.tsx b/node_modules/@react-navigation/native-stack/src/views/NativeStackView.native.tsx | ||
index a005c43..03d8b50 100644 | ||
--- a/node_modules/@react-navigation/native-stack/src/views/NativeStackView.native.tsx | ||
+++ b/node_modules/@react-navigation/native-stack/src/views/NativeStackView.native.tsx | ||
@@ -161,6 +161,7 @@ const SceneView = ({ | ||
statusBarTranslucent, | ||
statusBarColor, | ||
freezeOnBlur, | ||
+ keyboardHandlingEnabled, | ||
} = options; | ||
|
||
let { | ||
@@ -289,6 +290,7 @@ const SceneView = ({ | ||
onNativeDismissCancelled={onNativeDismissCancelled} | ||
// this prop is available since rn-screens 3.16 | ||
freezeOnBlur={freezeOnBlur} | ||
+ hideKeyboardOnSwipe={keyboardHandlingEnabled} | ||
> | ||
<NavigationContext.Provider value={navigation}> | ||
<NavigationRouteContext.Provider value={route}> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/libs/Navigation/AppNavigator/Navigators/Overlay/index.native.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function Overlay() { | ||
return null; | ||
} | ||
|
||
Overlay.displayName = 'Overlay'; | ||
|
||
export default Overlay; |
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/libs/Navigation/AppNavigator/defaultScreenOptions/index.native.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const defaultScreenOptions = { | ||
contentStyle: { | ||
overflow: 'visible', | ||
flex: 1, | ||
}, | ||
headerShown: false, | ||
animationTypeForReplace: 'push', | ||
animation: 'slide_from_right', | ||
}; | ||
|
||
export default defaultScreenOptions; |
12 changes: 12 additions & 0 deletions
12
src/libs/Navigation/AppNavigator/defaultScreenOptions/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type {StackNavigationOptions} from '@react-navigation/stack'; | ||
|
||
const defaultScreenOptions: StackNavigationOptions = { | ||
cardStyle: { | ||
overflow: 'visible', | ||
flex: 1, | ||
}, | ||
headerShown: false, | ||
animationTypeForReplace: 'push', | ||
}; | ||
|
||
export default defaultScreenOptions; |
8 changes: 8 additions & 0 deletions
8
src/libs/Navigation/AppNavigator/getRightModalNavigatorOptions/index.native.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type {NativeStackNavigationOptions} from '@react-navigation/native-stack'; | ||
|
||
const rightModalNavigatorOptions = (): NativeStackNavigationOptions => ({ | ||
presentation: 'card', | ||
animation: 'slide_from_right', | ||
}); | ||
|
||
export default rightModalNavigatorOptions; |
20 changes: 20 additions & 0 deletions
20
src/libs/Navigation/AppNavigator/getRightModalNavigatorOptions/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type {StackNavigationOptions} from '@react-navigation/stack'; | ||
// eslint-disable-next-line no-restricted-imports | ||
import getNavigationModalCardStyle from '@styles/utils/getNavigationModalCardStyles'; | ||
|
||
const rightModalNavigatorOptions = (isSmallScreenWidth: boolean): StackNavigationOptions => ({ | ||
presentation: 'transparentModal', | ||
|
||
// We want pop in RHP since there are some flows that would work weird otherwise | ||
animationTypeForReplace: 'pop', | ||
cardStyle: { | ||
...getNavigationModalCardStyle(), | ||
|
||
// This is necessary to cover translated sidebar with overlay. | ||
width: isSmallScreenWidth ? '100%' : '200%', | ||
// Excess space should be on the left so we need to position from right. | ||
right: 0, | ||
}, | ||
}); | ||
|
||
export default rightModalNavigatorOptions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/libs/Navigation/AppNavigator/modalStackNavigatorOptions/index.native.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type {NativeStackNavigationOptions} from '@react-navigation/native-stack'; | ||
|
||
const defaultSubRouteOptions: NativeStackNavigationOptions = { | ||
headerShown: false, | ||
animation: 'slide_from_right', | ||
}; | ||
|
||
export default defaultSubRouteOptions; |
9 changes: 9 additions & 0 deletions
9
src/libs/Navigation/AppNavigator/modalStackNavigatorOptions/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type {StackNavigationOptions} from '@react-navigation/stack'; | ||
import {CardStyleInterpolators} from '@react-navigation/stack'; | ||
|
||
const defaultSubRouteOptions: StackNavigationOptions = { | ||
headerShown: false, | ||
cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS, | ||
}; | ||
|
||
export default defaultSubRouteOptions; |
7 changes: 7 additions & 0 deletions
7
src/libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator.native.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {createNativeStackNavigator} from '@react-navigation/native-stack'; | ||
|
||
function createPlatformStackNavigator() { | ||
return createNativeStackNavigator(); | ||
} | ||
|
||
export default createPlatformStackNavigator; |
5 changes: 5 additions & 0 deletions
5
src/libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {createStackNavigator} from '@react-navigation/stack'; | ||
|
||
const createPlatformStackNavigator: typeof createStackNavigator = () => createStackNavigator(); | ||
|
||
export default createPlatformStackNavigator; |