react-native-screens 3.19.0 → 3.21.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 (203) hide show
  1. package/README.md +2 -1
  2. package/RNScreens.podspec +1 -1
  3. package/android/build.gradle +24 -6
  4. package/android/src/main/java/com/swmansion/rnscreens/CustomSearchView.kt +4 -0
  5. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt +7 -9
  6. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt +12 -4
  7. package/android/src/main/java/com/swmansion/rnscreens/SearchBarManager.kt +32 -8
  8. package/android/src/main/java/com/swmansion/rnscreens/SearchBarView.kt +36 -15
  9. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderAttachedEvent.kt +24 -0
  10. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderDetachedEvent.kt +24 -0
  11. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarBlurEvent.kt +24 -0
  12. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarChangeTextEvent.kt +29 -0
  13. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarCloseEvent.kt +24 -0
  14. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarFocusEvent.kt +24 -0
  15. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarOpenEvent.kt +24 -0
  16. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarSearchButtonPressEvent.kt +26 -0
  17. package/android/src/main/res/base/anim/rns_standard_accelerate_interpolator.xml +6 -0
  18. package/android/src/main/res/v33/anim-v33/rns_default_enter_in.xml +38 -0
  19. package/android/src/main/res/v33/anim-v33/rns_default_enter_out.xml +38 -0
  20. package/android/src/main/res/v33/anim-v33/rns_default_exit_in.xml +38 -0
  21. package/android/src/main/res/v33/anim-v33/rns_default_exit_out.xml +38 -0
  22. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerDelegate.java +3 -0
  23. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerInterface.java +1 -0
  24. package/common/cpp/react/renderer/components/rnscreens/RNSScreenState.h +1 -2
  25. package/ios/RCTImageComponentView+RNSScreenStackHeaderConfig.h +11 -0
  26. package/ios/RCTImageComponentView+RNSScreenStackHeaderConfig.mm +14 -0
  27. package/ios/RNSConvert.h +2 -2
  28. package/ios/RNSConvert.mm +2 -2
  29. package/ios/RNSFullWindowOverlay.h +5 -5
  30. package/ios/RNSFullWindowOverlay.mm +13 -13
  31. package/ios/RNSScreen.h +7 -6
  32. package/ios/RNSScreen.mm +35 -33
  33. package/ios/RNSScreenContainer.h +2 -2
  34. package/ios/RNSScreenContainer.mm +5 -5
  35. package/ios/RNSScreenNavigationContainer.mm +3 -3
  36. package/ios/RNSScreenStack.h +4 -4
  37. package/ios/RNSScreenStack.mm +62 -23
  38. package/ios/RNSScreenStackHeaderConfig.h +10 -3
  39. package/ios/RNSScreenStackHeaderConfig.mm +138 -81
  40. package/ios/RNSScreenStackHeaderSubview.h +5 -6
  41. package/ios/RNSScreenStackHeaderSubview.mm +20 -11
  42. package/ios/RNSScreenWindowTraits.mm +21 -2
  43. package/ios/RNSSearchBar.h +5 -4
  44. package/ios/RNSSearchBar.mm +87 -12
  45. package/ios/RNScreens.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  46. package/ios/RNScreens.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  47. package/ios/RNScreens.xcodeproj/project.xcworkspace/xcuserdata/wojciechlewicki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  48. package/ios/RNScreens.xcodeproj/xcuserdata/wojciechlewicki.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
  49. package/lib/commonjs/TransitionProgressContext.js.map +1 -1
  50. package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js +0 -5
  51. package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js.map +1 -1
  52. package/lib/commonjs/fabric/ScreenContainerNativeComponent.js +0 -5
  53. package/lib/commonjs/fabric/ScreenContainerNativeComponent.js.map +1 -1
  54. package/lib/commonjs/fabric/ScreenNativeComponent.js +0 -5
  55. package/lib/commonjs/fabric/ScreenNativeComponent.js.map +1 -1
  56. package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js +0 -5
  57. package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -1
  58. package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js +0 -8
  59. package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  60. package/lib/commonjs/fabric/ScreenStackHeaderSubviewNativeComponent.js +0 -8
  61. package/lib/commonjs/fabric/ScreenStackHeaderSubviewNativeComponent.js.map +1 -1
  62. package/lib/commonjs/fabric/ScreenStackNativeComponent.js +0 -5
  63. package/lib/commonjs/fabric/ScreenStackNativeComponent.js.map +1 -1
  64. package/lib/commonjs/fabric/SearchBarNativeComponent.js +7 -7
  65. package/lib/commonjs/fabric/SearchBarNativeComponent.js.map +1 -1
  66. package/lib/commonjs/index.js +1 -1
  67. package/lib/commonjs/index.js.map +1 -1
  68. package/lib/commonjs/index.native.js +53 -11
  69. package/lib/commonjs/index.native.js.map +1 -1
  70. package/lib/commonjs/native-stack/index.js.map +1 -1
  71. package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js +18 -16
  72. package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
  73. package/lib/commonjs/native-stack/types.js.map +1 -1
  74. package/lib/commonjs/native-stack/utils/HeaderHeightContext.js.map +1 -1
  75. package/lib/commonjs/native-stack/utils/SafeAreaProviderCompat.js.map +1 -1
  76. package/lib/commonjs/native-stack/utils/getDefaultHeaderHeight.js.map +1 -1
  77. package/lib/commonjs/native-stack/utils/useBackPressSubscription.js.map +1 -1
  78. package/lib/commonjs/native-stack/utils/useHeaderHeight.js.map +1 -1
  79. package/lib/commonjs/native-stack/views/FontProcessor.js +1 -0
  80. package/lib/commonjs/native-stack/views/FontProcessor.js.map +1 -1
  81. package/lib/commonjs/native-stack/views/HeaderConfig.js +3 -1
  82. package/lib/commonjs/native-stack/views/HeaderConfig.js.map +1 -1
  83. package/lib/commonjs/native-stack/views/NativeStackView.js +14 -1
  84. package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
  85. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  86. package/lib/commonjs/reanimated/ReanimatedScreen.js.map +1 -1
  87. package/lib/commonjs/reanimated/ReanimatedScreenProvider.js +3 -1
  88. package/lib/commonjs/reanimated/ReanimatedScreenProvider.js.map +1 -1
  89. package/lib/commonjs/reanimated/ReanimatedTransitionProgressContext.js.map +1 -1
  90. package/lib/commonjs/reanimated/index.js.map +1 -1
  91. package/lib/commonjs/reanimated/useReanimatedTransitionProgress.js.map +1 -1
  92. package/lib/commonjs/types.js.map +1 -1
  93. package/lib/commonjs/useTransitionProgress.js.map +1 -1
  94. package/lib/commonjs/utils.js.map +1 -1
  95. package/lib/module/fabric/FullWindowOverlayNativeComponent.js +0 -5
  96. package/lib/module/fabric/FullWindowOverlayNativeComponent.js.map +1 -1
  97. package/lib/module/fabric/ScreenContainerNativeComponent.js +0 -5
  98. package/lib/module/fabric/ScreenContainerNativeComponent.js.map +1 -1
  99. package/lib/module/fabric/ScreenNativeComponent.js +0 -5
  100. package/lib/module/fabric/ScreenNativeComponent.js.map +1 -1
  101. package/lib/module/fabric/ScreenNavigationContainerNativeComponent.js +0 -5
  102. package/lib/module/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -1
  103. package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js +0 -6
  104. package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  105. package/lib/module/fabric/ScreenStackHeaderSubviewNativeComponent.js +0 -6
  106. package/lib/module/fabric/ScreenStackHeaderSubviewNativeComponent.js.map +1 -1
  107. package/lib/module/fabric/ScreenStackNativeComponent.js +0 -5
  108. package/lib/module/fabric/ScreenStackNativeComponent.js.map +1 -1
  109. package/lib/module/fabric/SearchBarNativeComponent.js +4 -6
  110. package/lib/module/fabric/SearchBarNativeComponent.js.map +1 -1
  111. package/lib/module/index.js +1 -1
  112. package/lib/module/index.js.map +1 -1
  113. package/lib/module/index.native.js +54 -11
  114. package/lib/module/index.native.js.map +1 -1
  115. package/lib/module/native-stack/navigators/createNativeStackNavigator.js +18 -16
  116. package/lib/module/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
  117. package/lib/module/native-stack/types.js.map +1 -1
  118. package/lib/module/native-stack/utils/SafeAreaProviderCompat.js.map +1 -1
  119. package/lib/module/native-stack/utils/getDefaultHeaderHeight.js.map +1 -1
  120. package/lib/module/native-stack/utils/useBackPressSubscription.js.map +1 -1
  121. package/lib/module/native-stack/utils/useHeaderHeight.js.map +1 -1
  122. package/lib/module/native-stack/views/FontProcessor.js +1 -0
  123. package/lib/module/native-stack/views/FontProcessor.js.map +1 -1
  124. package/lib/module/native-stack/views/HeaderConfig.js +3 -1
  125. package/lib/module/native-stack/views/HeaderConfig.js.map +1 -1
  126. package/lib/module/native-stack/views/NativeStackView.js +15 -1
  127. package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
  128. package/lib/module/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  129. package/lib/module/reanimated/ReanimatedScreen.js.map +1 -1
  130. package/lib/module/reanimated/ReanimatedScreenProvider.js +3 -1
  131. package/lib/module/reanimated/ReanimatedScreenProvider.js.map +1 -1
  132. package/lib/module/reanimated/useReanimatedTransitionProgress.js.map +1 -1
  133. package/lib/module/types.js.map +1 -1
  134. package/lib/module/useTransitionProgress.js.map +1 -1
  135. package/lib/module/utils.js.map +1 -1
  136. package/lib/typescript/fabric/FullWindowOverlayNativeComponent.d.ts +6 -0
  137. package/lib/typescript/fabric/ScreenContainerNativeComponent.d.ts +6 -0
  138. package/lib/typescript/fabric/ScreenNativeComponent.d.ts +62 -0
  139. package/lib/typescript/fabric/ScreenNavigationContainerNativeComponent.d.ts +6 -0
  140. package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts +34 -0
  141. package/lib/typescript/fabric/ScreenStackHeaderSubviewNativeComponent.d.ts +9 -0
  142. package/lib/typescript/fabric/ScreenStackNativeComponent.d.ts +9 -0
  143. package/lib/typescript/fabric/SearchBarNativeComponent.d.ts +46 -0
  144. package/lib/typescript/index.d.ts +2 -2
  145. package/lib/typescript/native-stack/navigators/createNativeStackNavigator.d.ts +2 -2
  146. package/lib/typescript/native-stack/types.d.ts +55 -1
  147. package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts +1 -1
  148. package/lib/typescript/reanimated/ReanimatedScreen.d.ts +1 -1
  149. package/lib/typescript/types.d.ts +81 -2
  150. package/lib/typescript/useTransitionProgress.d.ts +3 -3
  151. package/native-stack/README.md +59 -1
  152. package/package.json +11 -14
  153. package/src/fabric/FullWindowOverlayNativeComponent.ts +6 -0
  154. package/src/fabric/ScreenContainerNativeComponent.ts +6 -0
  155. package/src/fabric/ScreenNativeComponent.ts +97 -0
  156. package/src/fabric/ScreenNavigationContainerNativeComponent.ts +9 -0
  157. package/src/fabric/ScreenStackHeaderConfigNativeComponent.ts +43 -0
  158. package/src/fabric/ScreenStackHeaderSubviewNativeComponent.ts +20 -0
  159. package/src/fabric/ScreenStackNativeComponent.ts +12 -0
  160. package/src/fabric/SearchBarNativeComponent.ts +73 -0
  161. package/src/index.native.tsx +107 -14
  162. package/src/index.tsx +4 -3
  163. package/src/native-stack/navigators/createNativeStackNavigator.tsx +23 -19
  164. package/src/native-stack/types.tsx +55 -0
  165. package/src/native-stack/views/FontProcessor.tsx +1 -0
  166. package/src/native-stack/views/HeaderConfig.tsx +3 -1
  167. package/src/native-stack/views/NativeStackView.tsx +14 -2
  168. package/src/types.tsx +84 -2
  169. package/android/src/main/java/com/swmansion/rnscreens/LifecycleHelper.kt +0 -60
  170. package/createNativeStackNavigator/README.md +0 -522
  171. package/createNativeStackNavigator/package.json +0 -6
  172. package/lib/commonjs/createNativeStackNavigator.js +0 -374
  173. package/lib/commonjs/createNativeStackNavigator.js.map +0 -1
  174. package/lib/module/createNativeStackNavigator.js +0 -366
  175. package/lib/module/createNativeStackNavigator.js.map +0 -1
  176. package/lib/typescript/createNativeStackNavigator.d.ts +0 -51
  177. package/src/createNativeStackNavigator.tsx +0 -594
  178. package/src/fabric/FullWindowOverlayNativeComponent.js +0 -19
  179. package/src/fabric/ScreenContainerNativeComponent.js +0 -19
  180. package/src/fabric/ScreenNativeComponent.js +0 -104
  181. package/src/fabric/ScreenNavigationContainerNativeComponent.js +0 -19
  182. package/src/fabric/ScreenStackHeaderConfigNativeComponent.js +0 -54
  183. package/src/fabric/ScreenStackHeaderSubviewNativeComponent.js +0 -31
  184. package/src/fabric/ScreenStackNativeComponent.js +0 -23
  185. package/src/fabric/SearchBarNativeComponent.js +0 -62
  186. /package/android/src/main/res/{anim → base/anim}/rns_default_enter_in.xml +0 -0
  187. /package/android/src/main/res/{anim → base/anim}/rns_default_enter_out.xml +0 -0
  188. /package/android/src/main/res/{anim → base/anim}/rns_default_exit_in.xml +0 -0
  189. /package/android/src/main/res/{anim → base/anim}/rns_default_exit_out.xml +0 -0
  190. /package/android/src/main/res/{anim → base/anim}/rns_fade_from_bottom.xml +0 -0
  191. /package/android/src/main/res/{anim → base/anim}/rns_fade_in.xml +0 -0
  192. /package/android/src/main/res/{anim → base/anim}/rns_fade_out.xml +0 -0
  193. /package/android/src/main/res/{anim → base/anim}/rns_fade_to_bottom.xml +0 -0
  194. /package/android/src/main/res/{anim → base/anim}/rns_no_animation_20.xml +0 -0
  195. /package/android/src/main/res/{anim → base/anim}/rns_no_animation_250.xml +0 -0
  196. /package/android/src/main/res/{anim → base/anim}/rns_no_animation_350.xml +0 -0
  197. /package/android/src/main/res/{anim → base/anim}/rns_no_animation_medium.xml +0 -0
  198. /package/android/src/main/res/{anim → base/anim}/rns_slide_in_from_bottom.xml +0 -0
  199. /package/android/src/main/res/{anim → base/anim}/rns_slide_in_from_left.xml +0 -0
  200. /package/android/src/main/res/{anim → base/anim}/rns_slide_in_from_right.xml +0 -0
  201. /package/android/src/main/res/{anim → base/anim}/rns_slide_out_to_bottom.xml +0 -0
  202. /package/android/src/main/res/{anim → base/anim}/rns_slide_out_to_left.xml +0 -0
  203. /package/android/src/main/res/{anim → base/anim}/rns_slide_out_to_right.xml +0 -0
@@ -0,0 +1,20 @@
1
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
+ import type { ViewProps } from 'react-native';
3
+ import type { WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
4
+
5
+ export type HeaderSubviewTypes =
6
+ | 'back'
7
+ | 'right'
8
+ | 'left'
9
+ | 'title'
10
+ | 'center'
11
+ | 'searchBar';
12
+
13
+ export interface NativeProps extends ViewProps {
14
+ type?: WithDefault<HeaderSubviewTypes, 'left'>;
15
+ }
16
+
17
+ export default codegenNativeComponent<NativeProps>(
18
+ 'RNSScreenStackHeaderSubview',
19
+ {}
20
+ );
@@ -0,0 +1,12 @@
1
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
+ import type { ViewProps } from 'react-native';
3
+ import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
4
+
5
+ // eslint-disable-next-line @typescript-eslint/ban-types
6
+ type FinishTransitioningEvent = Readonly<{}>;
7
+
8
+ interface NativeProps extends ViewProps {
9
+ onFinishTransitioning?: DirectEventHandler<FinishTransitioningEvent>;
10
+ }
11
+
12
+ export default codegenNativeComponent<NativeProps>('RNSScreenStack', {});
@@ -0,0 +1,73 @@
1
+ /* eslint-disable */
2
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
3
+ import type { ViewProps, ColorValue, HostComponent } from 'react-native';
4
+ import type {
5
+ WithDefault,
6
+ BubblingEventHandler,
7
+ } from 'react-native/Libraries/Types/CodegenTypes';
8
+ import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
9
+
10
+ type SearchBarEvent = Readonly<{}>;
11
+
12
+ type SearchButtonPressedEvent = Readonly<{
13
+ text?: string;
14
+ }>;
15
+
16
+ type ChangeTextEvent = Readonly<{
17
+ text?: string;
18
+ }>;
19
+
20
+ type AutoCapitalizeType = 'none' | 'words' | 'sentences' | 'characters';
21
+
22
+ interface NativeProps extends ViewProps {
23
+ onFocus?: BubblingEventHandler<SearchBarEvent> | null;
24
+ onBlur?: BubblingEventHandler<SearchBarEvent> | null;
25
+ onSearchButtonPress?: BubblingEventHandler<SearchButtonPressedEvent> | null;
26
+ onCancelButtonPress?: BubblingEventHandler<SearchBarEvent> | null;
27
+ onChangeText?: BubblingEventHandler<ChangeTextEvent> | null;
28
+ hideWhenScrolling?: boolean;
29
+ autoCapitalize?: WithDefault<AutoCapitalizeType, 'none'>;
30
+ placeholder?: string;
31
+ obscureBackground?: boolean;
32
+ hideNavigationBar?: boolean;
33
+ cancelButtonText?: string;
34
+ // TODO: implement these on iOS
35
+ barTintColor?: ColorValue;
36
+ tintColor?: ColorValue;
37
+ textColor?: ColorValue;
38
+
39
+ // Android only
40
+ disableBackButtonOverride?: boolean;
41
+ // TODO: consider creating enum here
42
+ inputType?: string;
43
+ onClose?: BubblingEventHandler<SearchBarEvent> | null;
44
+ onOpen?: BubblingEventHandler<SearchBarEvent> | null;
45
+ hintTextColor?: ColorValue;
46
+ headerIconColor?: ColorValue;
47
+ shouldShowHintSearchIcon?: WithDefault<boolean, true>;
48
+ }
49
+
50
+ type ComponentType = HostComponent<NativeProps>;
51
+
52
+ interface NativeCommands {
53
+ blur: (viewRef: React.ElementRef<ComponentType>) => void;
54
+ focus: (viewRef: React.ElementRef<ComponentType>) => void;
55
+ clearText: (viewRef: React.ElementRef<ComponentType>) => void;
56
+ toggleCancelButton: (
57
+ viewRef: React.ElementRef<ComponentType>,
58
+ flag: boolean
59
+ ) => void;
60
+ setText: (viewRef: React.ElementRef<ComponentType>, text: string) => void;
61
+ }
62
+
63
+ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
64
+ supportedCommands: [
65
+ 'blur',
66
+ 'focus',
67
+ 'clearText',
68
+ 'toggleCancelButton',
69
+ 'setText',
70
+ ],
71
+ });
72
+
73
+ export default codegenNativeComponent<NativeProps>('RNSSearchBar', {});
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
1
2
  import React, { PropsWithChildren, ReactNode } from 'react';
2
3
  import {
3
4
  Animated,
@@ -29,6 +30,7 @@ import {
29
30
  ScreenStackProps,
30
31
  ScreenStackHeaderConfigProps,
31
32
  SearchBarProps,
33
+ SearchBarCommands,
32
34
  } from './types';
33
35
  import {
34
36
  isSearchBarAvailableForCurrentPlatform,
@@ -74,6 +76,26 @@ function screensEnabled(): boolean {
74
76
  return ENABLE_SCREENS;
75
77
  }
76
78
 
79
+ type SearchBarCommandsType = {
80
+ blur: (
81
+ viewRef: React.ElementRef<typeof ScreensNativeModules.NativeSearchBar>
82
+ ) => void;
83
+ focus: (
84
+ viewRef: React.ElementRef<typeof ScreensNativeModules.NativeSearchBar>
85
+ ) => void;
86
+ clearText: (
87
+ viewRef: React.ElementRef<typeof ScreensNativeModules.NativeSearchBar>
88
+ ) => void;
89
+ toggleCancelButton: (
90
+ viewRef: React.ElementRef<typeof ScreensNativeModules.NativeSearchBar>,
91
+ flag: boolean
92
+ ) => void;
93
+ setText: (
94
+ viewRef: React.ElementRef<typeof ScreensNativeModules.NativeSearchBar>,
95
+ text: string
96
+ ) => void;
97
+ };
98
+
77
99
  // We initialize these lazily so that importing the module doesn't throw error when not linked
78
100
  // This is necessary coz libraries such as React Navigation import the library where it may not be enabled
79
101
  let NativeScreenValue: React.ComponentType<ScreenProps>;
@@ -85,7 +107,11 @@ let NativeScreenStackHeaderSubview: React.ComponentType<
85
107
  React.PropsWithChildren<ViewProps & { type?: HeaderSubviewTypes }>
86
108
  >;
87
109
  let AnimatedNativeScreen: React.ComponentType<ScreenProps>;
88
- let NativeSearchBar: React.ComponentType<SearchBarProps>;
110
+
111
+ let NativeSearchBar: React.ComponentType<SearchBarProps> &
112
+ typeof NativeSearchBarCommands;
113
+ let NativeSearchBarCommands: SearchBarCommandsType;
114
+
89
115
  let NativeFullWindowOverlay: React.ComponentType<
90
116
  PropsWithChildren<{
91
117
  style: StyleProp<ViewStyle>;
@@ -95,14 +121,14 @@ let NativeFullWindowOverlay: React.ComponentType<
95
121
  const ScreensNativeModules = {
96
122
  get NativeScreen() {
97
123
  NativeScreenValue =
98
- NativeScreenValue || requireNativeComponent('RNSScreen');
124
+ NativeScreenValue || require('./fabric/ScreenNativeComponent').default;
99
125
  return NativeScreenValue;
100
126
  },
101
127
 
102
128
  get NativeScreenContainer() {
103
129
  NativeScreenContainerValue =
104
130
  NativeScreenContainerValue ||
105
- requireNativeComponent('RNSScreenContainer');
131
+ require('./fabric/ScreenContainerNativeComponent').default;
106
132
  return NativeScreenContainerValue;
107
133
  },
108
134
 
@@ -136,9 +162,16 @@ const ScreensNativeModules = {
136
162
  },
137
163
 
138
164
  get NativeSearchBar() {
139
- NativeSearchBar = NativeSearchBar || requireNativeComponent('RNSSearchBar');
165
+ NativeSearchBar =
166
+ NativeSearchBar || require('./fabric/SearchBarNativeComponent').default;
140
167
  return NativeSearchBar;
141
168
  },
169
+ get NativeSearchBarCommands() {
170
+ NativeSearchBarCommands =
171
+ NativeSearchBarCommands ||
172
+ require('./fabric/SearchBarNativeComponent').Commands;
173
+ return NativeSearchBarCommands;
174
+ },
142
175
 
143
176
  get NativeFullWindowOverlay() {
144
177
  NativeFullWindowOverlay =
@@ -379,6 +412,72 @@ const ScreenStackHeaderBackButtonImage = (props: ImageProps): JSX.Element => (
379
412
  </ScreensNativeModules.NativeScreenStackHeaderSubview>
380
413
  );
381
414
 
415
+ class SearchBar extends React.Component<SearchBarProps> {
416
+ nativeSearchBarRef: React.RefObject<SearchBarCommands>;
417
+
418
+ constructor(props: SearchBarProps) {
419
+ super(props);
420
+ this.nativeSearchBarRef = React.createRef();
421
+ }
422
+
423
+ _callMethodWithRef(method: (ref: SearchBarCommands) => void) {
424
+ const ref = this.nativeSearchBarRef.current;
425
+ if (ref) {
426
+ method(ref);
427
+ } else {
428
+ console.warn(
429
+ 'Reference to native search bar component has not been updated yet'
430
+ );
431
+ }
432
+ }
433
+
434
+ blur() {
435
+ this._callMethodWithRef((ref) =>
436
+ ScreensNativeModules.NativeSearchBarCommands.blur(ref)
437
+ );
438
+ }
439
+
440
+ focus() {
441
+ this._callMethodWithRef((ref) =>
442
+ ScreensNativeModules.NativeSearchBarCommands.focus(ref)
443
+ );
444
+ }
445
+
446
+ toggleCancelButton(flag: boolean) {
447
+ this._callMethodWithRef((ref) =>
448
+ ScreensNativeModules.NativeSearchBarCommands.toggleCancelButton(ref, flag)
449
+ );
450
+ }
451
+
452
+ clearText() {
453
+ this._callMethodWithRef((ref) =>
454
+ ScreensNativeModules.NativeSearchBarCommands.clearText(ref)
455
+ );
456
+ }
457
+
458
+ setText(text: string) {
459
+ this._callMethodWithRef((ref) =>
460
+ ScreensNativeModules.NativeSearchBarCommands.setText(ref, text)
461
+ );
462
+ }
463
+
464
+ render() {
465
+ if (!isSearchBarAvailableForCurrentPlatform) {
466
+ console.warn(
467
+ 'Importing SearchBar is only valid on iOS and Android devices.'
468
+ );
469
+ return View as any as ReactNode;
470
+ }
471
+
472
+ return (
473
+ <ScreensNativeModules.NativeSearchBar
474
+ {...this.props}
475
+ ref={this.nativeSearchBarRef}
476
+ />
477
+ );
478
+ }
479
+ }
480
+
382
481
  const ScreenStackHeaderRightView = (
383
482
  props: React.PropsWithChildren<ViewProps>
384
483
  ): JSX.Element => (
@@ -441,7 +540,7 @@ class Screen extends React.Component<ScreenProps> {
441
540
  static contextType = ScreenContext;
442
541
 
443
542
  render() {
444
- const ScreenWrapper = this.context || InnerScreen;
543
+ const ScreenWrapper = (this.context || InnerScreen) as React.ElementType;
445
544
  return <ScreenWrapper {...this.props} />;
446
545
  }
447
546
  }
@@ -454,6 +553,7 @@ module.exports = {
454
553
  ScreenContext,
455
554
  ScreenStack,
456
555
  InnerScreen,
556
+ SearchBar,
457
557
  FullWindowOverlay,
458
558
 
459
559
  get NativeScreen() {
@@ -474,15 +574,8 @@ module.exports = {
474
574
  get ScreenStackHeaderSubview() {
475
575
  return ScreensNativeModules.NativeScreenStackHeaderSubview;
476
576
  },
477
- get SearchBar() {
478
- if (!isSearchBarAvailableForCurrentPlatform) {
479
- console.warn(
480
- 'Importing SearchBar is only valid on iOS and Android devices.'
481
- );
482
- return View;
483
- }
484
-
485
- return ScreensNativeModules.NativeSearchBar;
577
+ get SearchBarCommands() {
578
+ return ScreensNativeModules.NativeSearchBarCommands;
486
579
  },
487
580
  // these are functions and will not be evaluated until used
488
581
  // so no need to use getters for them
package/src/index.tsx CHANGED
@@ -101,11 +101,12 @@ export const ScreenStackHeaderCenterView = (
101
101
  ): JSX.Element => <View {...props} />;
102
102
 
103
103
  export const ScreenStackHeaderSearchBarView = (
104
- props: React.PropsWithChildren<SearchBarProps>
104
+ props: React.PropsWithChildren<Omit<SearchBarProps, 'ref'>>
105
105
  ): JSX.Element => <View {...props} />;
106
106
 
107
- export const ScreenStackHeaderConfig: React.ComponentType<ScreenStackHeaderConfigProps> =
108
- View;
107
+ export const ScreenStackHeaderConfig = (
108
+ props: React.PropsWithChildren<ScreenStackHeaderConfigProps>
109
+ ): JSX.Element => <View {...props} />;
109
110
 
110
111
  // @ts-expect-error: search bar props have no common props with View
111
112
  export const SearchBar: React.ComponentType<SearchBarProps> = View;
@@ -48,26 +48,30 @@ function NativeStackNavigator({
48
48
 
49
49
  React.useEffect(
50
50
  () =>
51
- navigation?.addListener?.('tabPress', (e) => {
52
- const isFocused = navigation.isFocused();
51
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
+ (navigation as typeof navigation & { addListener: any })?.addListener?.(
53
+ 'tabPress',
54
+ (e: any) => {
55
+ const isFocused = navigation.isFocused();
53
56
 
54
- // Run the operation in the next frame so we're sure all listeners have been run
55
- // This is necessary to know if preventDefault() has been called
56
- requestAnimationFrame(() => {
57
- if (
58
- state.index > 0 &&
59
- isFocused &&
60
- !(e as EventArg<'tabPress', true>).defaultPrevented
61
- ) {
62
- // When user taps on already focused tab and we're inside the tab,
63
- // reset the stack to replicate native behaviour
64
- navigation.dispatch({
65
- ...StackActions.popToTop(),
66
- target: state.key,
67
- });
68
- }
69
- });
70
- }),
57
+ // Run the operation in the next frame so we're sure all listeners have been run
58
+ // This is necessary to know if preventDefault() has been called
59
+ requestAnimationFrame(() => {
60
+ if (
61
+ state.index > 0 &&
62
+ isFocused &&
63
+ !(e as EventArg<'tabPress', true>).defaultPrevented
64
+ ) {
65
+ // When user taps on already focused tab and we're inside the tab,
66
+ // reset the stack to replicate native behaviour
67
+ navigation.dispatch({
68
+ ...StackActions.popToTop(),
69
+ target: state.key,
70
+ });
71
+ }
72
+ });
73
+ }
74
+ ),
71
75
  [navigation, state.index, state.key]
72
76
  );
73
77
 
@@ -15,6 +15,7 @@ import {
15
15
  ScreenProps,
16
16
  ScreenStackHeaderConfigProps,
17
17
  SearchBarProps,
18
+ SheetDetentTypes,
18
19
  } from 'react-native-screens';
19
20
 
20
21
  export type NativeStackNavigationEventMap = {
@@ -310,6 +311,60 @@ export type NativeStackNavigationOptions = {
310
311
  * Object in which you should pass props in order to render native iOS searchBar.
311
312
  */
312
313
  searchBar?: SearchBarProps;
314
+ /**
315
+ * Describes heights where a sheet can rest.
316
+ * Works only when `stackPresentation` is set to `formSheet`.
317
+ * Defaults to `large`.
318
+ *
319
+ * Available values:
320
+ *
321
+ * - `large` - only large detent level will be allowed
322
+ * - `medium` - only medium detent level will be allowed
323
+ * - `all` - all detent levels will be allowed
324
+ *
325
+ * @platform ios
326
+ */
327
+ sheetAllowedDetents?: SheetDetentTypes;
328
+ /**
329
+ * Whether the sheet should expand to larger detent when scrolling.
330
+ * Works only when `stackPresentation` is set to `formSheet`.
331
+ * Defaults to `true`.
332
+ */
333
+ sheetExpandsWhenScrolledToEdge?: boolean;
334
+ /**
335
+ * The corner radius that the sheet will try to render with.
336
+ * Works only when `stackPresentation` is set to `formSheet`.
337
+ *
338
+ * If set to non-negative value it will try to render sheet with provided radius, else ti will apply system default.
339
+ *
340
+ * If left unset system default is used.
341
+ *
342
+ * @platform ios
343
+ */
344
+ sheetCornerRadius?: number;
345
+ /**
346
+ * Boolean indicating whether the sheet shows a grabber at the top.
347
+ * Works only when `stackPresentation` is set to `formSheet`.
348
+ * Defaults to `false`.
349
+ *
350
+ * @platform ios
351
+ */
352
+ sheetGrabberVisible?: boolean;
353
+ /**
354
+ * The largest sheet detent for which a view underneath won't be dimmed.
355
+ * Works only when `stackPresentation` is se tto `formSheet`.
356
+ *
357
+ * If this prop is set to:
358
+ *
359
+ * - `large` - the view underneath won't be dimmed at any detent level
360
+ * - `medium` - the view underneath will be dimmed only when detent level is `large`
361
+ * - `all` - the view underneath will be dimmed for any detent level
362
+ *
363
+ * Defaults to `all`.
364
+ *
365
+ * @platform ios
366
+ */
367
+ sheetLargestUndimmedDetent?: SheetDetentTypes;
313
368
  /**
314
369
  * How the screen should appear/disappear when pushed or popped at the top of the stack.
315
370
  * The following values are currently supported:
@@ -1,4 +1,5 @@
1
1
  // @ts-ignore: No declaration available
2
+ // eslint-disable-next-line import/no-named-as-default, import/default, import/no-named-as-default-member, import/namespace
2
3
  import ReactNativeStyleAttributes from 'react-native/Libraries/Components/View/ReactNativeStyleAttributes';
3
4
 
4
5
  export function processFonts(
@@ -73,6 +73,7 @@ export default function HeaderConfig({
73
73
  ]);
74
74
 
75
75
  // We want to clear clearSubscription only when components unmounts or search bar changes
76
+ // eslint-disable-next-line react-hooks/exhaustive-deps
76
77
  React.useEffect(() => clearSubscription, [searchBar]);
77
78
 
78
79
  const processedSearchBarOptions = React.useMemo(() => {
@@ -101,9 +102,10 @@ export default function HeaderConfig({
101
102
  backgroundColor={
102
103
  headerStyle.backgroundColor ? headerStyle.backgroundColor : colors.card
103
104
  }
104
- backTitle={headerBackTitleVisible ? headerBackTitle : ' '}
105
+ backTitle={headerBackTitle}
105
106
  backTitleFontFamily={backTitleFontFamily}
106
107
  backTitleFontSize={headerBackTitleStyle.fontSize}
108
+ backTitleVisible={headerBackTitleVisible}
107
109
  blurEffect={headerStyle.blurEffect}
108
110
  color={tintColor}
109
111
  direction={direction}
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { Platform, StyleSheet, View, ViewProps } from 'react-native';
3
3
  // @ts-ignore Getting private component
4
+ // eslint-disable-next-line import/no-named-as-default, import/default, import/no-named-as-default-member, import/namespace
4
5
  import AppContainer from 'react-native/Libraries/ReactNative/AppContainer';
5
6
  import warnOnce from 'warn-once';
6
7
  import {
@@ -124,7 +125,6 @@ const MaybeNestedStack = ({
124
125
  </ScreenStack>
125
126
  );
126
127
  }
127
-
128
128
  return content;
129
129
  };
130
130
 
@@ -154,6 +154,11 @@ const RouteView = ({
154
154
  headerShown,
155
155
  hideKeyboardOnSwipe,
156
156
  homeIndicatorHidden,
157
+ sheetAllowedDetents = 'large',
158
+ sheetLargestUndimmedDetent = 'all',
159
+ sheetGrabberVisible = false,
160
+ sheetCornerRadius = -1.0,
161
+ sheetExpandsWhenScrolledToEdge = true,
157
162
  nativeBackButtonDismissalEnabled = false,
158
163
  navigationBarColor,
159
164
  navigationBarHidden,
@@ -214,12 +219,19 @@ const RouteView = ({
214
219
  const parentHeaderHeight = React.useContext(HeaderHeightContext);
215
220
  const Screen = React.useContext(ScreenContext);
216
221
 
222
+ const { dark } = useTheme();
223
+
217
224
  return (
218
225
  <Screen
219
226
  key={route.key}
220
227
  enabled
221
228
  isNativeStack
222
229
  style={StyleSheet.absoluteFill}
230
+ sheetAllowedDetents={sheetAllowedDetents}
231
+ sheetLargestUndimmedDetent={sheetLargestUndimmedDetent}
232
+ sheetGrabberVisible={sheetGrabberVisible}
233
+ sheetCornerRadius={sheetCornerRadius}
234
+ sheetExpandsWhenScrolledToEdge={sheetExpandsWhenScrolledToEdge}
223
235
  customAnimationOnSwipe={customAnimationOnSwipe}
224
236
  freezeOnBlur={freezeOnBlur}
225
237
  fullScreenSwipeEnabled={fullScreenSwipeEnabled}
@@ -237,7 +249,7 @@ const RouteView = ({
237
249
  statusBarAnimation={statusBarAnimation}
238
250
  statusBarColor={statusBarColor}
239
251
  statusBarHidden={statusBarHidden}
240
- statusBarStyle={statusBarStyle}
252
+ statusBarStyle={statusBarStyle ?? (dark ? 'light' : 'dark')}
241
253
  statusBarTranslucent={statusBarTranslucent}
242
254
  swipeDirection={swipeDirection}
243
255
  transitionDuration={transitionDuration}
package/src/types.tsx CHANGED
@@ -7,6 +7,14 @@ import {
7
7
  TextInputFocusEventData,
8
8
  } from 'react-native';
9
9
 
10
+ export type SearchBarCommands = {
11
+ focus: () => void;
12
+ blur: () => void;
13
+ clearText: () => void;
14
+ toggleCancelButton: (show: boolean) => void;
15
+ setText: (text: string) => void;
16
+ };
17
+
10
18
  export type StackPresentationTypes =
11
19
  | 'push'
12
20
  | 'modal'
@@ -77,9 +85,11 @@ export type GestureResponseDistanceType = {
77
85
  bottom?: number;
78
86
  };
79
87
 
88
+ export type SheetDetentTypes = 'medium' | 'large' | 'all';
89
+
80
90
  export interface ScreenProps extends ViewProps {
81
- active?: 0 | 1 | Animated.AnimatedInterpolation;
82
- activityState?: 0 | 1 | 2 | Animated.AnimatedInterpolation;
91
+ active?: 0 | 1 | Animated.AnimatedInterpolation<number>;
92
+ activityState?: 0 | 1 | 2 | Animated.AnimatedInterpolation<number>;
83
93
  children?: React.ReactNode;
84
94
  /**
85
95
  * Boolean indicating that swipe dismissal should trigger animation provided by `stackAnimation`. Defaults to `false`.
@@ -222,6 +232,60 @@ export interface ScreenProps extends ViewProps {
222
232
  * - "landscape_right" – landscape-right orientation is permitted
223
233
  */
224
234
  screenOrientation?: ScreenOrientationTypes;
235
+ /**
236
+ * Describes heights where a sheet can rest.
237
+ * Works only when `stackPresentation` is set to `formSheet`.
238
+ * Defaults to `large`.
239
+ *
240
+ * Available values:
241
+ *
242
+ * - `large` - only large detent level will be allowed
243
+ * - `medium` - only medium detent level will be allowed
244
+ * - `all` - all detent levels will be allowed
245
+ *
246
+ * @platform ios
247
+ */
248
+ sheetAllowedDetents?: SheetDetentTypes;
249
+ /**
250
+ * Whether the sheet should expand to larger detent when scrolling.
251
+ * Works only when `stackPresentation` is set to `formSheet`.
252
+ * Defaults to `true`.
253
+ */
254
+ sheetExpandsWhenScrolledToEdge?: boolean;
255
+ /**
256
+ * The corner radius that the sheet will try to render with.
257
+ * Works only when `stackPresentation` is set to `formSheet`.
258
+ *
259
+ * If set to non-negative value it will try to render sheet with provided radius, else ti will apply system default.
260
+ *
261
+ * If left unset system default is used.
262
+ *
263
+ * @platform ios
264
+ */
265
+ sheetCornerRadius?: number;
266
+ /**
267
+ * Boolean indicating whether the sheet shows a grabber at the top.
268
+ * Works only when `stackPresentation` is set to `formSheet`.
269
+ * Defaults to `false`.
270
+ *
271
+ * @platform ios
272
+ */
273
+ sheetGrabberVisible?: boolean;
274
+ /**
275
+ * The largest sheet detent for which a view underneath won't be dimmed.
276
+ * Works only when `stackPresentation` is set to `formSheet`.
277
+ *
278
+ * If this prop is set to:
279
+ *
280
+ * - `large` - the view underneath won't be dimmed at any detent level
281
+ * - `medium` - the view underneath will be dimmed only when detent level is `large`
282
+ * - `all` - the view underneath will be dimmed for any detent level
283
+ *
284
+ * Defaults to `all`.
285
+ *
286
+ * @platform ios
287
+ */
288
+ sheetLargestUndimmedDetent?: SheetDetentTypes;
225
289
  /**
226
290
  * How the screen should appear/disappear when pushed or popped at the top of the stack.
227
291
  * The following values are currently supported:
@@ -335,6 +399,11 @@ export interface ScreenStackHeaderConfigProps extends ViewProps {
335
399
  * @platform ios
336
400
  */
337
401
  backTitleFontSize?: number;
402
+ /**
403
+ * Whether the back button title should be visible or not. Defaults to `true`.
404
+ * @platform ios
405
+ */
406
+ backTitleVisible?: boolean;
338
407
  /**
339
408
  * Blur effect to be applied to the header. Works with backgroundColor's alpha < 1.
340
409
  * @platform ios
@@ -450,6 +519,19 @@ export interface ScreenStackHeaderConfigProps extends ViewProps {
450
519
  }
451
520
 
452
521
  export interface SearchBarProps {
522
+ /**
523
+ * Reference to imperatively modify search bar.
524
+ *
525
+ * Currently supported operations are:
526
+ *
527
+ * * `focus` - focuses the search bar
528
+ * * `blur` - removes focus from the search bar
529
+ * * `clearText` - removes any text present in the search bar input field
530
+ * * `setText` - sets the search bar's content to given value
531
+ * * `toggleCancelButton` - depending on passed boolean value, hides or shows cancel button (iOS only)
532
+ */
533
+ ref?: React.RefObject<SearchBarCommands>;
534
+
453
535
  /**
454
536
  * The auto-capitalization behavior
455
537
  */