react-native-screens 3.10.1 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +13 -7
  3. package/RNScreens.podspec +36 -6
  4. package/android/build.gradle +74 -3
  5. package/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +49 -0
  6. package/android/src/fabric/java/com/swmansion/rnscreens/RNScreensComponentsRegistry.java +28 -0
  7. package/android/src/main/java/com/swmansion/rnscreens/RNScreensPackage.kt +11 -2
  8. package/android/src/main/java/com/swmansion/rnscreens/Screen.kt +52 -21
  9. package/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt +1 -1
  10. package/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt +64 -33
  11. package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +9 -31
  12. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt +0 -30
  13. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt +12 -5
  14. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt +83 -18
  15. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubviewManager.kt +17 -5
  16. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackViewManager.kt +14 -1
  17. package/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +41 -14
  18. package/android/src/main/java/com/swmansion/rnscreens/ScreenWindowTraits.kt +72 -11
  19. package/android/src/main/java/com/swmansion/rnscreens/SearchBarManager.kt +18 -1
  20. package/android/src/main/java/com/swmansion/rnscreens/SearchBarView.kt +7 -2
  21. package/android/src/main/java/com/swmansion/rnscreens/SearchViewFormatter.kt +29 -2
  22. package/android/src/main/jni/Android.mk +45 -0
  23. package/android/src/main/jni/OnLoad.cpp +9 -0
  24. package/android/src/main/jni/RNScreensComponentsRegistry.cpp +66 -0
  25. package/android/src/main/jni/RNScreensComponentsRegistry.h +34 -0
  26. package/android/src/main/res/anim/rns_default_enter_in.xml +18 -0
  27. package/android/src/main/res/anim/rns_default_enter_out.xml +19 -0
  28. package/android/src/main/res/anim/rns_default_exit_in.xml +17 -0
  29. package/android/src/main/res/anim/rns_default_exit_out.xml +18 -0
  30. package/android/src/main/res/anim/rns_fade_in.xml +7 -0
  31. package/android/src/main/res/anim/rns_fade_out.xml +7 -0
  32. package/android/src/main/res/anim/rns_no_animation_20.xml +6 -0
  33. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenManagerDelegate.java +71 -0
  34. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenManagerInterface.java +30 -0
  35. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerDelegate.java +104 -0
  36. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerInterface.java +41 -0
  37. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderSubviewManagerDelegate.java +31 -0
  38. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderSubviewManagerInterface.java +17 -0
  39. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackManagerDelegate.java +25 -0
  40. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackManagerInterface.java +16 -0
  41. package/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +16 -0
  42. package/common/cpp/Android.mk +38 -0
  43. package/common/cpp/rnscreens/RNSScreenComponentDescriptor.h +41 -0
  44. package/common/cpp/rnscreens/RNSScreenShadowNode.cpp +9 -0
  45. package/common/cpp/rnscreens/RNSScreenShadowNode.h +29 -0
  46. package/common/cpp/rnscreens/RNSScreenState.cpp +14 -0
  47. package/common/cpp/rnscreens/RNSScreenState.h +46 -0
  48. package/createNativeStackNavigator/README.md +12 -0
  49. package/ios/RNSScreen.h +10 -0
  50. package/ios/RNSScreen.m +34 -0
  51. package/ios/RNSScreenComponentView.h +23 -0
  52. package/ios/RNSScreenComponentView.mm +159 -0
  53. package/ios/RNSScreenContainer.m +5 -0
  54. package/ios/RNSScreenController.h +10 -0
  55. package/ios/RNSScreenController.mm +79 -0
  56. package/ios/RNSScreenStack.m +22 -7
  57. package/ios/RNSScreenStackAnimator.m +45 -14
  58. package/ios/RNSScreenStackComponentView.h +15 -0
  59. package/ios/RNSScreenStackComponentView.mm +295 -0
  60. package/ios/RNSScreenStackHeaderConfig.m +4 -1
  61. package/ios/RNSScreenStackHeaderConfigComponentView.h +42 -0
  62. package/ios/RNSScreenStackHeaderConfigComponentView.mm +662 -0
  63. package/ios/RNSScreenStackHeaderSubviewComponentView.h +14 -0
  64. package/ios/RNSScreenStackHeaderSubviewComponentView.mm +77 -0
  65. package/ios/RNSScreenWindowTraits.h +1 -0
  66. package/ios/RNSScreenWindowTraits.m +20 -0
  67. package/ios/UIViewController+RNScreens.m +10 -0
  68. package/ios/utils/RNSUIBarButtonItem.h +5 -0
  69. package/ios/utils/RNSUIBarButtonItem.mm +22 -0
  70. package/lib/commonjs/fabric/Screen.js +27 -0
  71. package/lib/commonjs/fabric/Screen.js.map +1 -0
  72. package/lib/commonjs/fabric/ScreenNativeComponent.js +23 -0
  73. package/lib/commonjs/fabric/ScreenNativeComponent.js.map +1 -0
  74. package/lib/commonjs/fabric/ScreenStack.js +27 -0
  75. package/lib/commonjs/fabric/ScreenStack.js.map +1 -0
  76. package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js +27 -0
  77. package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -0
  78. package/lib/commonjs/fabric/ScreenStackHeaderSubview.js +34 -0
  79. package/lib/commonjs/fabric/ScreenStackHeaderSubview.js.map +1 -0
  80. package/lib/commonjs/fabric/ScreenStackHeaderSubviewNativeComponent.js +27 -0
  81. package/lib/commonjs/fabric/ScreenStackHeaderSubviewNativeComponent.js.map +1 -0
  82. package/lib/commonjs/fabric/ScreenStackNativeComponent.js +21 -0
  83. package/lib/commonjs/fabric/ScreenStackNativeComponent.js.map +1 -0
  84. package/lib/commonjs/fabric/index.js +40 -0
  85. package/lib/commonjs/fabric/index.js.map +1 -0
  86. package/lib/commonjs/index.native.js +32 -15
  87. package/lib/commonjs/index.native.js.map +1 -1
  88. package/lib/commonjs/native-stack/views/NativeStackView.js +33 -4
  89. package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
  90. package/lib/module/fabric/Screen.js +11 -0
  91. package/lib/module/fabric/Screen.js.map +1 -0
  92. package/lib/module/fabric/ScreenNativeComponent.js +11 -0
  93. package/lib/module/fabric/ScreenNativeComponent.js.map +1 -0
  94. package/lib/module/fabric/ScreenStack.js +12 -0
  95. package/lib/module/fabric/ScreenStack.js.map +1 -0
  96. package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js +10 -0
  97. package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -0
  98. package/lib/module/fabric/ScreenStackHeaderSubview.js +21 -0
  99. package/lib/module/fabric/ScreenStackHeaderSubview.js.map +1 -0
  100. package/lib/module/fabric/ScreenStackHeaderSubviewNativeComponent.js +10 -0
  101. package/lib/module/fabric/ScreenStackHeaderSubviewNativeComponent.js.map +1 -0
  102. package/lib/module/fabric/ScreenStackNativeComponent.js +9 -0
  103. package/lib/module/fabric/ScreenStackNativeComponent.js.map +1 -0
  104. package/lib/module/fabric/index.js +6 -0
  105. package/lib/module/fabric/index.js.map +1 -0
  106. package/lib/module/index.native.js +32 -15
  107. package/lib/module/index.native.js.map +1 -1
  108. package/lib/module/native-stack/views/NativeStackView.js +33 -4
  109. package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
  110. package/lib/typescript/native-stack/types.d.ts +34 -0
  111. package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts +1 -1
  112. package/lib/typescript/reanimated/ReanimatedScreen.d.ts +1 -1
  113. package/lib/typescript/types.d.ts +60 -5
  114. package/native-stack/README.md +39 -3
  115. package/package.json +17 -3
  116. package/reanimated/package.json +6 -0
  117. package/src/fabric/Screen.js +12 -0
  118. package/src/fabric/ScreenNativeComponent.js +64 -0
  119. package/src/fabric/ScreenStack.js +8 -0
  120. package/src/fabric/ScreenStackHeaderConfigNativeComponent.js +54 -0
  121. package/src/fabric/ScreenStackHeaderSubview.js +20 -0
  122. package/src/fabric/ScreenStackHeaderSubviewNativeComponent.js +31 -0
  123. package/src/fabric/ScreenStackNativeComponent.js +19 -0
  124. package/src/fabric/index.js +11 -0
  125. package/src/index.native.tsx +35 -14
  126. package/src/native-stack/types.tsx +34 -0
  127. package/src/native-stack/views/NativeStackView.tsx +33 -4
  128. package/src/types.tsx +60 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-screens",
3
- "version": "3.10.1",
3
+ "version": "3.12.0",
4
4
  "description": "Native navigation primitives for your React Native app.",
5
5
  "scripts": {
6
6
  "check-types": "tsc --noEmit",
@@ -8,7 +8,7 @@
8
8
  "test:unit": "jest --passWithNoTests",
9
9
  "format-js": "prettier --write --list-different './{src,Example}/**/*.{js,ts,tsx}'",
10
10
  "format-android": "node ./scripts/format-android.js",
11
- "format-ios": "find ios/ -iname *.h -o -iname *.m -o -iname *.cpp | xargs clang-format -i",
11
+ "format-ios": "find ios/ -iname *.h -o -iname *.m -o -iname *.cpp -o -iname *.mm | xargs clang-format -i",
12
12
  "format": "yarn format-js && yarn format-android && yarn format-ios",
13
13
  "lint-js": "eslint --ext '.js,.ts,.tsx' --fix src",
14
14
  "lint-android": "./android/gradlew -p android spotlessCheck -q",
@@ -23,13 +23,17 @@
23
23
  "types": "lib/typescript/index",
24
24
  "files": [
25
25
  "src/",
26
+ "common/",
26
27
  "lib/",
27
28
  "native-stack/",
28
29
  "createNativeStackNavigator/",
29
30
  "reanimated/",
30
31
  "android/src/main/AndroidManifest.xml",
31
32
  "android/src/main/java/",
33
+ "android/src/main/jni/",
32
34
  "android/src/main/res",
35
+ "android/src/fabric/",
36
+ "android/src/paper/",
33
37
  "android/build.gradle",
34
38
  "ios/",
35
39
  "windows/",
@@ -54,6 +58,7 @@
54
58
  "homepage": "https://github.com/software-mansion/react-native-screens#readme",
55
59
  "dependencies": {
56
60
  "react-freeze": "^1.0.0",
61
+ "react-native-gradle-plugin": "^0.0.3",
57
62
  "warn-once": "^0.1.0"
58
63
  },
59
64
  "peerDependencies": {
@@ -126,5 +131,14 @@
126
131
  "eslintIgnore": [
127
132
  "node_modules/",
128
133
  "lib/"
129
- ]
134
+ ],
135
+ "codegenConfig": {
136
+ "libraries": [
137
+ {
138
+ "name": "rnscreens",
139
+ "type": "components",
140
+ "jsSrcsDir": "./src/fabric"
141
+ }
142
+ ]
143
+ }
130
144
  }
@@ -0,0 +1,6 @@
1
+ {
2
+ "main": "../lib/commonjs/reanimated/index",
3
+ "module": "../lib/module/reanimated/index",
4
+ "react-native": "../src/reanimated/index",
5
+ "types": "../lib/typescript/reanimated/index"
6
+ }
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import ScreenNativeComponent from './ScreenNativeComponent';
3
+ import { StyleSheet } from 'react-native';
4
+
5
+ export default function Screen(props) {
6
+ return (
7
+ <ScreenNativeComponent
8
+ {...props}
9
+ style={[props.style, StyleSheet.absoluteFill]}
10
+ />
11
+ );
12
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @flow strict-local
3
+ * @format
4
+ */
5
+ /* eslint-disable */
6
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
7
+ import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
8
+ import type { HostComponent } from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';
9
+ import type { ColorValue } from 'react-native/Libraries/StyleSheet/StyleSheet';
10
+ import type {
11
+ BubblingEventHandler,
12
+ WithDefault,
13
+ Int32,
14
+ } from 'react-native/Libraries/Types/CodegenTypes';
15
+
16
+ type ScreenEvent = $ReadOnly<{||}>;
17
+
18
+ type ScreenDismissedEvent = $ReadOnly<{|
19
+ dismissCount: Int32,
20
+ |}>;
21
+
22
+ type StackPresentation = 'push' | 'modal' | 'transparentModal';
23
+ type StackAnimation =
24
+ | 'default'
25
+ | 'flip'
26
+ | 'simple_push'
27
+ | 'none'
28
+ | 'fade'
29
+ | 'slide_from_right'
30
+ | 'slide_from_left'
31
+ | 'slide_from_bottom'
32
+ | 'fade_from_bottom';
33
+
34
+ type ReplaceAnimation = 'pop' | 'push';
35
+
36
+ export type NativeProps = $ReadOnly<{|
37
+ ...ViewProps,
38
+ onAppear?: ?BubblingEventHandler<ScreenEvent>,
39
+ onDisappear?: ?BubblingEventHandler<ScreenEvent>,
40
+ onDismissed?: ?BubblingEventHandler<ScreenDismissedEvent>,
41
+ onWillAppear?: ?BubblingEventHandler<ScreenEvent>,
42
+ onWillDisappear?: ?BubblingEventHandler<ScreenEvent>,
43
+ // TODO: implement this props on iOS
44
+ stackPresentation?: WithDefault<StackPresentation, 'push'>,
45
+ stackAnimation?: WithDefault<StackAnimation, 'default'>,
46
+ gestureEnabled?: WithDefault<boolean, true>,
47
+ replaceAnimation?: WithDefault<ReplaceAnimation, 'pop'>,
48
+ screenOrientation?: string,
49
+ statusBarAnimation?: string,
50
+ statusBarColor?: ColorValue,
51
+ statusBarStyle?: string,
52
+ statusBarTranslucent?: boolean,
53
+ statusBarHidden?: boolean,
54
+ navigationBarColor?: ColorValue,
55
+ navigationBarHidden?: boolean,
56
+ nativeBackButtonDismissalEnabled?: boolean,
57
+ activityState?: WithDefault<Int32, -1>,
58
+ |}>;
59
+
60
+ type ComponentType = HostComponent<NativeProps>;
61
+
62
+ export default (codegenNativeComponent<NativeProps>('RNSScreen', {
63
+ interfaceOnly: true,
64
+ }): ComponentType);
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import ScreenStackNativeComponent from './ScreenStackNativeComponent';
3
+
4
+ export default function ScreenStack(props) {
5
+ return (
6
+ <ScreenStackNativeComponent {...props} style={[{ flex: 1 }, props.style]} />
7
+ );
8
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @flow strict-local
3
+ * @format
4
+ */
5
+ /* eslint-disable */
6
+ import * as React from 'react';
7
+
8
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
9
+ import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
10
+ import type { HostComponent } from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';
11
+ import type { ColorValue } from 'react-native/Libraries/StyleSheet/StyleSheet';
12
+ import type {
13
+ Int32,
14
+ WithDefault,
15
+ } from 'react-native/Libraries/Types/CodegenTypes';
16
+
17
+ type DirectionType = 'rtl' | 'ltr';
18
+
19
+ export type NativeProps = $ReadOnly<{|
20
+ ...ViewProps,
21
+ backgroundColor?: ColorValue,
22
+ backTitle?: string,
23
+ backTitleFontFamily?: string,
24
+ backTitleFontSize?: Int32,
25
+ color?: ColorValue,
26
+ direction?: WithDefault<DirectionType, 'ltr'>,
27
+ hidden?: boolean,
28
+ hideShadow?: boolean,
29
+ largeTitle?: boolean,
30
+ largeTitleFontFamily?: string,
31
+ largeTitleFontSize?: Int32,
32
+ largeTitleFontWeight?: string,
33
+ largeTitleBackgroundColor?: ColorValue,
34
+ largeTitleHideShadow?: boolean,
35
+ largeTitleColor?: ColorValue,
36
+ translucent?: boolean,
37
+ title?: string,
38
+ titleFontFamily?: string,
39
+ titleFontSize?: Int32,
40
+ titleFontWeight?: string,
41
+ titleColor?: ColorValue,
42
+ disableBackButtonMenu?: boolean,
43
+ hideBackButton?: boolean,
44
+ // TODO: implement this props on iOS
45
+ topInsetEnabled?: boolean,
46
+ backButtonInCustomView?: boolean,
47
+ |}>;
48
+
49
+ type ComponentType = HostComponent<NativeProps>;
50
+
51
+ export default (codegenNativeComponent<NativeProps>(
52
+ 'RNSScreenStackHeaderConfig',
53
+ {}
54
+ ): ComponentType);
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import NativeScreenStackHeaderSubview from './ScreenStackHeaderSubviewNativeComponent';
3
+ import { StyleSheet } from 'react-native';
4
+
5
+ const styles = StyleSheet.create({
6
+ headerSubview: {
7
+ position: 'absolute',
8
+ top: 0,
9
+ right: 0,
10
+ flexDirection: 'row',
11
+ alignItems: 'center',
12
+ justifyContent: 'center',
13
+ },
14
+ });
15
+
16
+ export default function ScreenStackHeaderSubview(props) {
17
+ return (
18
+ <NativeScreenStackHeaderSubview {...props} style={styles.headerSubview} />
19
+ );
20
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @flow strict-local
3
+ * @format
4
+ */
5
+ /* eslint-disable */
6
+ import * as React from 'react';
7
+
8
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
9
+ import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
10
+ import type { HostComponent } from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';
11
+ import type { WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
12
+
13
+ export type HeaderSubviewTypes =
14
+ | 'back'
15
+ | 'right'
16
+ | 'left'
17
+ | 'title'
18
+ | 'center'
19
+ | 'searchBar';
20
+
21
+ export type NativeProps = $ReadOnly<{|
22
+ ...ViewProps,
23
+ type?: WithDefault<HeaderSubviewTypes, 'left'>,
24
+ |}>;
25
+
26
+ type ComponentType = HostComponent<NativeProps>;
27
+
28
+ export default (codegenNativeComponent<NativeProps>(
29
+ 'RNSScreenStackHeaderSubview',
30
+ {}
31
+ ): ComponentType);
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @flow strict-local
3
+ * @format
4
+ */
5
+ /* eslint-disable */
6
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
7
+ import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
8
+ import type { HostComponent } from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';
9
+
10
+ type NativeProps = $ReadOnly<{|
11
+ ...ViewProps,
12
+ |}>;
13
+
14
+ type ComponentType = HostComponent<NativeProps>;
15
+
16
+ export default (codegenNativeComponent<NativeProps>(
17
+ 'RNSScreenStack',
18
+ {}
19
+ ): ComponentType);
@@ -0,0 +1,11 @@
1
+ import Screen from './Screen';
2
+ import ScreenStackHeaderSubview from './ScreenStackHeaderSubview';
3
+ import ScreenStackHeaderConfig from './ScreenStackHeaderConfigNativeComponent';
4
+ import ScreenStack from './ScreenStack';
5
+
6
+ export {
7
+ Screen,
8
+ ScreenStackHeaderSubview,
9
+ ScreenStackHeaderConfig,
10
+ ScreenStack,
11
+ };
@@ -44,6 +44,11 @@ const isPlatformSupported =
44
44
 
45
45
  let ENABLE_SCREENS = isPlatformSupported;
46
46
 
47
+ // @ts-expect-error nativeFabricUIManager is not yet included in the RN types
48
+ const ENABLE_FABRIC = !!global?.nativeFabricUIManager;
49
+
50
+ const FabricComponents = ENABLE_FABRIC ? require('./fabric') : {};
51
+
47
52
  function enableScreens(shouldEnableScreens = true): void {
48
53
  ENABLE_SCREENS = isPlatformSupported && shouldEnableScreens;
49
54
  if (ENABLE_SCREENS && !UIManager.getViewManagerConfig('RNSScreen')) {
@@ -92,7 +97,9 @@ let NativeFullWindowOverlay: React.ComponentType<View>;
92
97
  const ScreensNativeModules = {
93
98
  get NativeScreen() {
94
99
  NativeScreenValue =
95
- NativeScreenValue || requireNativeComponent('RNSScreen');
100
+ NativeScreenValue ||
101
+ FabricComponents.Screen ||
102
+ requireNativeComponent('RNSScreen');
96
103
  return NativeScreenValue;
97
104
  },
98
105
 
@@ -114,13 +121,16 @@ const ScreensNativeModules = {
114
121
 
115
122
  get NativeScreenStack() {
116
123
  NativeScreenStack =
117
- NativeScreenStack || requireNativeComponent('RNSScreenStack');
124
+ NativeScreenStack ||
125
+ FabricComponents.ScreenStack ||
126
+ requireNativeComponent('RNSScreenStack');
118
127
  return NativeScreenStack;
119
128
  },
120
129
 
121
130
  get NativeScreenStackHeaderConfig() {
122
131
  NativeScreenStackHeaderConfig =
123
132
  NativeScreenStackHeaderConfig ||
133
+ FabricComponents.ScreenStackHeaderConfig ||
124
134
  requireNativeComponent('RNSScreenStackHeaderConfig');
125
135
  return NativeScreenStackHeaderConfig;
126
136
  },
@@ -128,6 +138,7 @@ const ScreensNativeModules = {
128
138
  get NativeScreenStackHeaderSubview() {
129
139
  NativeScreenStackHeaderSubview =
130
140
  NativeScreenStackHeaderSubview ||
141
+ FabricComponents.ScreenStackHeaderSubview ||
131
142
  requireNativeComponent('RNSScreenStackHeaderSubview');
132
143
  return NativeScreenStackHeaderSubview;
133
144
  },
@@ -222,9 +233,15 @@ class Screen extends React.Component<ScreenProps> {
222
233
  const { enabled = ENABLE_SCREENS, ...rest } = this.props;
223
234
 
224
235
  if (enabled && isPlatformSupported) {
225
- AnimatedNativeScreen =
226
- AnimatedNativeScreen ||
227
- Animated.createAnimatedComponent(ScreensNativeModules.NativeScreen);
236
+ if (!AnimatedNativeScreen) {
237
+ if (ENABLE_FABRIC) {
238
+ AnimatedNativeScreen = ScreensNativeModules.NativeScreen;
239
+ } else {
240
+ AnimatedNativeScreen = Animated.createAnimatedComponent(
241
+ ScreensNativeModules.NativeScreen
242
+ ) as React.ComponentType<ScreenProps>;
243
+ }
244
+ }
228
245
 
229
246
  let {
230
247
  // Filter out active prop in this case because it is unused and
@@ -247,6 +264,18 @@ class Screen extends React.Component<ScreenProps> {
247
264
 
248
265
  const processedColor = processColor(statusBarColor);
249
266
 
267
+ const handleRef = (ref: ViewConfig) => {
268
+ if (!ENABLE_FABRIC) {
269
+ if (ref?.viewConfig?.validAttributes?.style) {
270
+ ref.viewConfig.validAttributes.style = {
271
+ ...ref.viewConfig.validAttributes.style,
272
+ display: false,
273
+ };
274
+ }
275
+ this.setRef(ref);
276
+ }
277
+ };
278
+
250
279
  return (
251
280
  <MaybeFreeze freeze={activityState === 0}>
252
281
  <AnimatedNativeScreen
@@ -255,15 +284,7 @@ class Screen extends React.Component<ScreenProps> {
255
284
  activityState={activityState}
256
285
  // This prevents showing blank screen when navigating between multiple screens with freezing
257
286
  // https://github.com/software-mansion/react-native-screens/pull/1208
258
- ref={(ref: ViewConfig) => {
259
- if (ref?.viewConfig?.validAttributes?.style) {
260
- ref.viewConfig.validAttributes.style = {
261
- ...ref.viewConfig.validAttributes.style,
262
- display: false,
263
- };
264
- }
265
- this.setRef(ref);
266
- }}
287
+ ref={handleRef}
267
288
  onTransitionProgress={
268
289
  !isNativeStack
269
290
  ? undefined
@@ -243,6 +243,12 @@ export type NativeStackNavigationOptions = {
243
243
  * Boolean indicating whether the navigation bar is translucent.
244
244
  */
245
245
  headerTranslucent?: boolean;
246
+ /**
247
+ * Whether the home indicator should be hidden on this screen. Defaults to `false`.
248
+ *
249
+ * @platform ios
250
+ */
251
+ homeIndicatorHidden?: boolean;
246
252
  /**
247
253
  * Boolean indicating whether, when the Android default back button is clicked, the `pop` action should be performed on the native side or on the JS side to be able to prevent it.
248
254
  * Unfortunately the same behavior is not available on iOS since the behavior of native back button cannot be changed there.
@@ -251,6 +257,18 @@ export type NativeStackNavigationOptions = {
251
257
  * @platform android
252
258
  */
253
259
  nativeBackButtonDismissalEnabled?: boolean;
260
+ /**
261
+ * Sets the navigation bar color. Defaults to initial status bar color.
262
+ *
263
+ * @platform android
264
+ */
265
+ navigationBarColor?: string;
266
+ /**
267
+ * Sets the visibility of the navigation bar. Defaults to `false`.
268
+ *
269
+ * @platform android
270
+ */
271
+ navigationBarHidden?: boolean;
254
272
  /**
255
273
  * How should the screen replacing another screen animate. Defaults to `pop`.
256
274
  * The following values are currently supported:
@@ -325,10 +343,26 @@ export type NativeStackNavigationOptions = {
325
343
  * @platform android
326
344
  */
327
345
  statusBarTranslucent?: boolean;
346
+ /**
347
+ * Sets the direction in which you should swipe to dismiss the screen.
348
+ * When using `vertical` option, options `fullScreenSwipeEnabled: true`, `customAnimationOnSwipe: true` and `stackAnimation: 'slide_from_bottom'` are set by default.
349
+ * The following values are supported:
350
+ * - `vertical` – dismiss screen vertically
351
+ * - `horizontal` – dismiss screen horizontally (default)
352
+ * @platform ios
353
+ */
354
+ swipeDirection?: ScreenProps['swipeDirection'];
328
355
  /**
329
356
  * String that can be displayed in the header as a fallback for `headerTitle`.
330
357
  */
331
358
  title?: string;
359
+ /**
360
+ * Changes the duration (in milliseconds) of `slide_from_bottom`, `fade_from_bottom`, `fade` and `simple_push` transitions on iOS. Defaults to `350`.
361
+ * The duration of `default` and `flip` transitions isn't customizable.
362
+ *
363
+ * @platform ios
364
+ */
365
+ transitionDuration?: number;
332
366
  };
333
367
 
334
368
  export type NativeStackNavigatorProps = DefaultNavigatorOptions<
@@ -149,22 +149,46 @@ const RouteView = ({
149
149
  }) => {
150
150
  const { options, render: renderScene } = descriptors[route.key];
151
151
  const {
152
- customAnimationOnSwipe,
153
- fullScreenSwipeEnabled,
154
152
  gestureEnabled,
155
153
  headerShown,
154
+ homeIndicatorHidden,
156
155
  nativeBackButtonDismissalEnabled = false,
156
+ navigationBarColor,
157
+ navigationBarHidden,
157
158
  replaceAnimation = 'pop',
158
159
  screenOrientation,
159
- stackAnimation,
160
160
  statusBarAnimation,
161
161
  statusBarColor,
162
162
  statusBarHidden,
163
163
  statusBarStyle,
164
164
  statusBarTranslucent,
165
+ swipeDirection = 'horizontal',
166
+ transitionDuration,
167
+ } = options;
168
+
169
+ let {
170
+ customAnimationOnSwipe,
171
+ fullScreenSwipeEnabled,
172
+ stackAnimation,
173
+ stackPresentation = 'push',
165
174
  } = options;
166
175
 
167
- let { stackPresentation = 'push' } = options;
176
+ if (swipeDirection === 'vertical') {
177
+ // for `vertical` direction to work, we need to set `fullScreenSwipeEnabled` to `true`
178
+ // so the screen can be dismissed from any point on screen.
179
+ // `customAnimationOnSwipe` needs to be set to `true` so the `stackAnimation` set by user can be used,
180
+ // otherwise `simple_push` will be used.
181
+ // Also, the default animation for this direction seems to be `slide_from_bottom`.
182
+ if (fullScreenSwipeEnabled === undefined) {
183
+ fullScreenSwipeEnabled = true;
184
+ }
185
+ if (customAnimationOnSwipe === undefined) {
186
+ customAnimationOnSwipe = true;
187
+ }
188
+ if (stackAnimation === undefined) {
189
+ stackAnimation = 'slide_from_bottom';
190
+ }
191
+ }
168
192
 
169
193
  if (index === 0) {
170
194
  // first screen should always be treated as `push`, it resolves problems with no header animation
@@ -194,8 +218,11 @@ const RouteView = ({
194
218
  style={StyleSheet.absoluteFill}
195
219
  customAnimationOnSwipe={customAnimationOnSwipe}
196
220
  fullScreenSwipeEnabled={fullScreenSwipeEnabled}
221
+ homeIndicatorHidden={homeIndicatorHidden}
197
222
  gestureEnabled={isAndroid ? false : gestureEnabled}
198
223
  nativeBackButtonDismissalEnabled={nativeBackButtonDismissalEnabled}
224
+ navigationBarColor={navigationBarColor}
225
+ navigationBarHidden={navigationBarHidden}
199
226
  replaceAnimation={replaceAnimation}
200
227
  screenOrientation={screenOrientation}
201
228
  stackAnimation={stackAnimation}
@@ -205,6 +232,8 @@ const RouteView = ({
205
232
  statusBarHidden={statusBarHidden}
206
233
  statusBarStyle={statusBarStyle}
207
234
  statusBarTranslucent={statusBarTranslucent}
235
+ swipeDirection={swipeDirection}
236
+ transitionDuration={transitionDuration}
208
237
  onHeaderBackButtonClicked={() => {
209
238
  navigation.dispatch({
210
239
  ...StackActions.pop(),
package/src/types.tsx CHANGED
@@ -47,6 +47,7 @@ export type BlurEffectTypes =
47
47
  | 'systemThickMaterialDark'
48
48
  | 'systemChromeMaterialDark';
49
49
  export type ScreenReplaceTypes = 'push' | 'pop';
50
+ export type SwipeDirectionTypes = 'vertical' | 'horizontal';
50
51
  export type ScreenOrientationTypes =
51
52
  | 'default'
52
53
  | 'all'
@@ -101,6 +102,12 @@ export interface ScreenProps extends ViewProps {
101
102
  * @platform ios
102
103
  */
103
104
  gestureEnabled?: boolean;
105
+ /**
106
+ * Whether the home indicator should be hidden on this screen. Defaults to `false`.
107
+ *
108
+ * @platform ios
109
+ */
110
+ homeIndicatorHidden?: boolean;
104
111
  /**
105
112
  * Boolean indicating whether, when the Android default back button is clicked, the `pop` action should be performed on the native side or on the JS side to be able to prevent it.
106
113
  * Unfortunately the same behavior is not available on iOS since the behavior of native back button cannot be changed there.
@@ -109,6 +116,18 @@ export interface ScreenProps extends ViewProps {
109
116
  * @platform android
110
117
  */
111
118
  nativeBackButtonDismissalEnabled?: boolean;
119
+ /**
120
+ * Sets the navigation bar color. Defaults to initial status bar color.
121
+ *
122
+ * @platform android
123
+ */
124
+ navigationBarColor?: string;
125
+ /**
126
+ * Sets the visibility of the navigation bar. Defaults to `false`.
127
+ *
128
+ * @platform android
129
+ */
130
+ navigationBarHidden?: boolean;
112
131
  /**
113
132
  * A callback that gets called when the current screen appears.
114
133
  */
@@ -214,6 +233,23 @@ export interface ScreenProps extends ViewProps {
214
233
  * @platform android
215
234
  */
216
235
  statusBarTranslucent?: boolean;
236
+ /**
237
+ * Sets the direction in which you should swipe to dismiss the screen.
238
+ * When using `vertical` option, options `fullScreenSwipeEnabled: true`, `customAnimationOnSwipe: true` and `stackAnimation: 'slide_from_bottom'` are set by default.
239
+ * The following values are supported:
240
+ * - `vertical` – dismiss screen vertically
241
+ * - `horizontal` – dismiss screen horizontally (default)
242
+ *
243
+ * @platform ios
244
+ */
245
+ swipeDirection?: SwipeDirectionTypes;
246
+ /**
247
+ * Changes the duration (in milliseconds) of `slide_from_bottom`, `fade_from_bottom`, `fade` and `simple_push` transitions on iOS. Defaults to `350`.
248
+ * The duration of `default` and `flip` transitions isn't customizable.
249
+ *
250
+ * @platform ios
251
+ */
252
+ transitionDuration?: number;
217
253
  }
218
254
 
219
255
  export interface ScreenContainerProps extends ViewProps {
@@ -441,17 +477,17 @@ export interface SearchBarProps {
441
477
  onChangeText?: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void;
442
478
 
443
479
  /**
444
- * A callback that gets called when search bar has received focus
480
+ * A callback that gets called when search bar is closed
481
+ *
482
+ * @platform android
445
483
  */
446
484
  onClose?: () => void;
447
485
  /**
448
- * A callback that gets called when search bar is opened
449
- *
450
- * @platform android
486
+ * A callback that gets called when search bar has received focus
451
487
  */
452
488
  onFocus?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
453
489
  /**
454
- * A callback that gets called when search bar is closed
490
+ * A callback that gets called when search bar is opened
455
491
  *
456
492
  * @platform android
457
493
  */
@@ -470,4 +506,23 @@ export interface SearchBarProps {
470
506
  * The search field text color
471
507
  */
472
508
  textColor?: string;
509
+ /**
510
+ * The search hint text color
511
+ *
512
+ * @plaform android
513
+ */
514
+ hintTextColor?: string;
515
+ /**
516
+ * The search and close icon color shown in the header
517
+ *
518
+ * @plaform android
519
+ */
520
+ headerIconColor?: string;
521
+ /**
522
+ * Show the search hint icon when search bar is focused
523
+ *
524
+ * @plaform android
525
+ * @default true
526
+ */
527
+ shouldShowHintSearchIcon?: boolean;
473
528
  }