react-native-screens 3.13.1 → 3.14.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.
- package/README.md +2 -2
- package/RNScreens.podspec +5 -4
- package/android/build.gradle +18 -1
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +8 -4
- package/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +24 -6
- package/android/src/main/java/com/swmansion/rnscreens/ScreenWindowTraits.kt +14 -18
- package/android/src/main/jni/Android.mk +1 -2
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenManagerDelegate.java +39 -14
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenManagerInterface.java +15 -6
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerDelegate.java +3 -3
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerInterface.java +1 -1
- package/common/cpp/Android.mk +1 -2
- package/createNativeStackNavigator/README.md +4 -0
- package/ios/RNSConvert.h +30 -0
- package/ios/RNSConvert.mm +120 -0
- package/ios/RNSEnums.h +59 -0
- package/ios/RNSFullWindowOverlay.h +17 -2
- package/ios/RNSFullWindowOverlay.mm +199 -0
- package/ios/RNSScreen.h +70 -79
- package/ios/{RNSScreen.m → RNSScreen.mm} +679 -302
- package/ios/RNSScreenContainer.h +15 -1
- package/ios/{RNSScreenContainer.m → RNSScreenContainer.mm} +99 -8
- package/ios/{RNSScreenNavigationContainer.m → RNSScreenNavigationContainer.mm} +22 -0
- package/ios/RNSScreenStack.h +19 -3
- package/ios/{RNSScreenStack.m → RNSScreenStack.mm} +377 -126
- package/ios/{RNSScreenStackAnimator.m → RNSScreenStackAnimator.mm} +19 -14
- package/ios/RNSScreenStackHeaderConfig.h +20 -21
- package/ios/{RNSScreenStackHeaderConfig.m → RNSScreenStackHeaderConfig.mm} +232 -117
- package/ios/RNSScreenStackHeaderSubview.h +45 -0
- package/ios/RNSScreenStackHeaderSubview.mm +137 -0
- package/ios/RNSScreenViewEvent.h +12 -0
- package/ios/RNSScreenViewEvent.mm +59 -0
- package/ios/{RNSScreenWindowTraits.m → RNSScreenWindowTraits.mm} +3 -2
- package/ios/RNSSearchBar.h +14 -1
- package/ios/RNSSearchBar.mm +351 -0
- package/ios/{UIViewController+RNScreens.m → UIViewController+RNScreens.mm} +0 -0
- package/ios/{UIWindow+RNScreens.m → UIWindow+RNScreens.mm} +0 -0
- package/lib/commonjs/fabric/FullWindowOverlay.js +26 -0
- package/lib/commonjs/fabric/FullWindowOverlay.js.map +1 -0
- package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js +21 -0
- package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js.map +1 -0
- package/lib/commonjs/fabric/ScreenContainer.js +28 -0
- package/lib/commonjs/fabric/ScreenContainer.js.map +1 -0
- package/lib/commonjs/fabric/ScreenContainerNativeComponent.js +21 -0
- package/lib/commonjs/fabric/ScreenContainerNativeComponent.js.map +1 -0
- package/lib/commonjs/fabric/ScreenNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenNavigationContainer.js +28 -0
- package/lib/commonjs/fabric/ScreenNavigationContainer.js.map +1 -0
- package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js +21 -0
- package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -0
- package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenStackNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/SearchBar.js +37 -0
- package/lib/commonjs/fabric/SearchBar.js.map +1 -0
- package/lib/commonjs/fabric/SearchBarNativeComponent.js +25 -0
- package/lib/commonjs/fabric/SearchBarNativeComponent.js.map +1 -0
- package/lib/commonjs/fabric/index.js +32 -0
- package/lib/commonjs/fabric/index.js.map +1 -1
- package/lib/commonjs/index.native.js +5 -18
- package/lib/commonjs/index.native.js.map +1 -1
- package/lib/commonjs/native-stack/views/NativeStackView.js +30 -0
- package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js +8 -2
- package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
- package/lib/module/fabric/FullWindowOverlay.js +15 -0
- package/lib/module/fabric/FullWindowOverlay.js.map +1 -0
- package/lib/module/fabric/FullWindowOverlayNativeComponent.js +9 -0
- package/lib/module/fabric/FullWindowOverlayNativeComponent.js.map +1 -0
- package/lib/module/fabric/ScreenContainer.js +17 -0
- package/lib/module/fabric/ScreenContainer.js.map +1 -0
- package/lib/module/fabric/ScreenContainerNativeComponent.js +9 -0
- package/lib/module/fabric/ScreenContainerNativeComponent.js.map +1 -0
- package/lib/module/fabric/ScreenNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenNavigationContainer.js +17 -0
- package/lib/module/fabric/ScreenNavigationContainer.js.map +1 -0
- package/lib/module/fabric/ScreenNavigationContainerNativeComponent.js +9 -0
- package/lib/module/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -0
- package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenStackNativeComponent.js.map +1 -1
- package/lib/module/fabric/SearchBar.js +24 -0
- package/lib/module/fabric/SearchBar.js.map +1 -0
- package/lib/module/fabric/SearchBarNativeComponent.js +11 -0
- package/lib/module/fabric/SearchBarNativeComponent.js.map +1 -0
- package/lib/module/fabric/index.js +5 -1
- package/lib/module/fabric/index.js.map +1 -1
- package/lib/module/index.native.js +6 -20
- package/lib/module/index.native.js.map +1 -1
- package/lib/module/native-stack/views/NativeStackView.js +30 -0
- package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/module/reanimated/ReanimatedNativeStackScreen.js +7 -2
- package/lib/module/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
- package/lib/typescript/native-stack/types.d.ts +12 -0
- package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts +1 -1
- package/lib/typescript/reanimated/ReanimatedScreen.d.ts +1 -1
- package/lib/typescript/types.d.ts +24 -0
- package/native-stack/README.md +21 -0
- package/package.json +2 -2
- package/src/fabric/FullWindowOverlay.js +13 -0
- package/src/fabric/FullWindowOverlayNativeComponent.js +19 -0
- package/src/fabric/ScreenContainer.js +16 -0
- package/src/fabric/ScreenContainerNativeComponent.js +19 -0
- package/src/fabric/ScreenNativeComponent.js +41 -8
- package/src/fabric/ScreenNavigationContainer.js +16 -0
- package/src/fabric/ScreenNavigationContainerNativeComponent.js +19 -0
- package/src/fabric/ScreenStackHeaderConfigNativeComponent.js +1 -1
- package/src/fabric/ScreenStackNativeComponent.js +4 -0
- package/src/fabric/SearchBar.js +20 -0
- package/src/fabric/SearchBarNativeComponent.js +62 -0
- package/src/fabric/index.js +8 -0
- package/src/index.native.tsx +13 -19
- package/src/native-stack/types.tsx +12 -0
- package/src/native-stack/views/NativeStackView.tsx +27 -0
- package/src/reanimated/ReanimatedNativeStackScreen.tsx +6 -0
- package/src/types.tsx +25 -0
- package/ios/RNSFullWindowOverlay.m +0 -105
- package/ios/RNSScreenComponentView.h +0 -23
- package/ios/RNSScreenComponentView.mm +0 -159
- package/ios/RNSScreenController.h +0 -10
- package/ios/RNSScreenController.mm +0 -79
- package/ios/RNSScreenStackComponentView.h +0 -15
- package/ios/RNSScreenStackComponentView.mm +0 -295
- package/ios/RNSScreenStackHeaderConfigComponentView.h +0 -42
- package/ios/RNSScreenStackHeaderConfigComponentView.mm +0 -662
- package/ios/RNSScreenStackHeaderSubviewComponentView.h +0 -14
- package/ios/RNSScreenStackHeaderSubviewComponentView.mm +0 -77
- package/ios/RNSSearchBar.m +0 -198
|
@@ -0,0 +1,62 @@
|
|
|
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 { ColorValue } from 'react-native/Libraries/StyleSheet/StyleSheet';
|
|
10
|
+
import type {
|
|
11
|
+
WithDefault,
|
|
12
|
+
BubblingEventHandler,
|
|
13
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
14
|
+
import { tintColor } from 'react-native/Libraries/Components/View/ReactNativeStyleAttributes';
|
|
15
|
+
|
|
16
|
+
type SearchBarEvent = $ReadOnly<{||}>;
|
|
17
|
+
|
|
18
|
+
type SearchButtonPressedEvent = $ReadOnly<{|
|
|
19
|
+
text?: string,
|
|
20
|
+
|}>;
|
|
21
|
+
|
|
22
|
+
type ChangeTextEvent = $ReadOnly<{|
|
|
23
|
+
text?: string,
|
|
24
|
+
|}>;
|
|
25
|
+
|
|
26
|
+
type AutoCapitalizeType = 'none' | 'words' | 'sentences' | 'characters';
|
|
27
|
+
|
|
28
|
+
type NativeProps = $ReadOnly<{|
|
|
29
|
+
...ViewProps,
|
|
30
|
+
onFocus?: ?BubblingEventHandler<SearchBarEvent>,
|
|
31
|
+
onBlur?: ?BubblingEventHandler<SearchBarEvent>,
|
|
32
|
+
onSearchButtonPress?: ?BubblingEventHandler<SearchButtonPressedEvent>,
|
|
33
|
+
onCancelButtonPress?: ?BubblingEventHandler<SearchBarEvent>,
|
|
34
|
+
onChangeText?: ?BubblingEventHandler<ChangeTextEvent>,
|
|
35
|
+
hideWhenScrolling?: boolean,
|
|
36
|
+
autoCapitalize?: WithDefault<AutoCapitalizeType, 'none'>,
|
|
37
|
+
placeholder?: string,
|
|
38
|
+
obscureBackground?: boolean,
|
|
39
|
+
hideNavigationBar?: boolean,
|
|
40
|
+
cancelButtonText?: string,
|
|
41
|
+
// TODO: implement these on iOS
|
|
42
|
+
barTintColor?: ColorValue,
|
|
43
|
+
tintColor?: ColorValue,
|
|
44
|
+
textColor?: ColorValue,
|
|
45
|
+
|
|
46
|
+
// Android only
|
|
47
|
+
disableBackButtonOverride?: boolean,
|
|
48
|
+
// TODO: consider creating enum here
|
|
49
|
+
inputType?: string,
|
|
50
|
+
onClose?: ?BubblingEventHandler<SearchBarEvent>,
|
|
51
|
+
onOpen?: ?BubblingEventHandler<SearchBarEvent>,
|
|
52
|
+
hintTextColor?: ColorValue,
|
|
53
|
+
headerIconColor?: ColorValue,
|
|
54
|
+
shouldShowHintSearchIcon?: WithDefault<boolean, true>,
|
|
55
|
+
|}>;
|
|
56
|
+
|
|
57
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
58
|
+
|
|
59
|
+
export default (codegenNativeComponent<NativeProps>(
|
|
60
|
+
'RNSSearchBar',
|
|
61
|
+
{}
|
|
62
|
+
): ComponentType);
|
package/src/fabric/index.js
CHANGED
|
@@ -2,10 +2,18 @@ import Screen from './Screen';
|
|
|
2
2
|
import ScreenStackHeaderSubview from './ScreenStackHeaderSubview';
|
|
3
3
|
import ScreenStackHeaderConfig from './ScreenStackHeaderConfigNativeComponent';
|
|
4
4
|
import ScreenStack from './ScreenStack';
|
|
5
|
+
import SearchBar from './SearchBar';
|
|
6
|
+
import ScreenContainer from './ScreenContainer';
|
|
7
|
+
import ScreenNavigationContainer from './ScreenNavigationContainer';
|
|
8
|
+
import FullWindowOverlay from './FullWindowOverlay';
|
|
5
9
|
|
|
6
10
|
export {
|
|
7
11
|
Screen,
|
|
8
12
|
ScreenStackHeaderSubview,
|
|
9
13
|
ScreenStackHeaderConfig,
|
|
10
14
|
ScreenStack,
|
|
15
|
+
SearchBar,
|
|
16
|
+
ScreenContainer,
|
|
17
|
+
ScreenNavigationContainer,
|
|
18
|
+
FullWindowOverlay,
|
|
11
19
|
};
|
package/src/index.native.tsx
CHANGED
|
@@ -11,9 +11,6 @@ import {
|
|
|
11
11
|
ViewProps,
|
|
12
12
|
} from 'react-native';
|
|
13
13
|
import { Freeze } from 'react-freeze';
|
|
14
|
-
// @ts-ignore Getting private component
|
|
15
|
-
// eslint-disable-next-line import/default
|
|
16
|
-
import processColor from 'react-native/Libraries/StyleSheet/processColor';
|
|
17
14
|
import { version } from 'react-native/package.json';
|
|
18
15
|
|
|
19
16
|
import TransitionProgressContext from './TransitionProgressContext';
|
|
@@ -106,6 +103,7 @@ const ScreensNativeModules = {
|
|
|
106
103
|
get NativeScreenContainer() {
|
|
107
104
|
NativeScreenContainerValue =
|
|
108
105
|
NativeScreenContainerValue ||
|
|
106
|
+
FabricComponents.ScreenContainer ||
|
|
109
107
|
requireNativeComponent('RNSScreenContainer');
|
|
110
108
|
return NativeScreenContainerValue;
|
|
111
109
|
},
|
|
@@ -114,7 +112,8 @@ const ScreensNativeModules = {
|
|
|
114
112
|
NativeScreenNavigationContainerValue =
|
|
115
113
|
NativeScreenNavigationContainerValue ||
|
|
116
114
|
(Platform.OS === 'ios'
|
|
117
|
-
?
|
|
115
|
+
? FabricComponents.ScreenNavigationContainer ||
|
|
116
|
+
requireNativeComponent('RNSScreenNavigationContainer')
|
|
118
117
|
: this.NativeScreenContainer);
|
|
119
118
|
return NativeScreenNavigationContainerValue;
|
|
120
119
|
},
|
|
@@ -144,13 +143,18 @@ const ScreensNativeModules = {
|
|
|
144
143
|
},
|
|
145
144
|
|
|
146
145
|
get NativeSearchBar() {
|
|
147
|
-
NativeSearchBar =
|
|
146
|
+
NativeSearchBar =
|
|
147
|
+
NativeSearchBar ||
|
|
148
|
+
FabricComponents.SearchBar ||
|
|
149
|
+
requireNativeComponent('RNSSearchBar');
|
|
148
150
|
return NativeSearchBar;
|
|
149
151
|
},
|
|
150
152
|
|
|
151
153
|
get NativeFullWindowOverlay() {
|
|
152
154
|
NativeFullWindowOverlay =
|
|
153
|
-
NativeFullWindowOverlay ||
|
|
155
|
+
NativeFullWindowOverlay ||
|
|
156
|
+
FabricComponents.FullWindowOverlay ||
|
|
157
|
+
requireNativeComponent('RNSFullWindowOverlay');
|
|
154
158
|
return NativeFullWindowOverlay;
|
|
155
159
|
},
|
|
156
160
|
};
|
|
@@ -233,15 +237,9 @@ class Screen extends React.Component<ScreenProps> {
|
|
|
233
237
|
const { enabled = ENABLE_SCREENS, ...rest } = this.props;
|
|
234
238
|
|
|
235
239
|
if (enabled && isPlatformSupported) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
} else {
|
|
240
|
-
AnimatedNativeScreen = Animated.createAnimatedComponent(
|
|
241
|
-
ScreensNativeModules.NativeScreen
|
|
242
|
-
) as React.ComponentType<ScreenProps>;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
240
|
+
AnimatedNativeScreen =
|
|
241
|
+
AnimatedNativeScreen ||
|
|
242
|
+
Animated.createAnimatedComponent(ScreensNativeModules.NativeScreen);
|
|
245
243
|
|
|
246
244
|
let {
|
|
247
245
|
// Filter out active prop in this case because it is unused and
|
|
@@ -251,7 +249,6 @@ class Screen extends React.Component<ScreenProps> {
|
|
|
251
249
|
activityState,
|
|
252
250
|
children,
|
|
253
251
|
isNativeStack,
|
|
254
|
-
statusBarColor,
|
|
255
252
|
...props
|
|
256
253
|
} = rest;
|
|
257
254
|
|
|
@@ -262,8 +259,6 @@ class Screen extends React.Component<ScreenProps> {
|
|
|
262
259
|
activityState = active !== 0 ? 2 : 0; // in the new version, we need one of the screens to have value of 2 after the transition
|
|
263
260
|
}
|
|
264
261
|
|
|
265
|
-
const processedColor = processColor(statusBarColor);
|
|
266
|
-
|
|
267
262
|
const handleRef = (ref: ViewConfig) => {
|
|
268
263
|
if (!ENABLE_FABRIC) {
|
|
269
264
|
if (ref?.viewConfig?.validAttributes?.style) {
|
|
@@ -280,7 +275,6 @@ class Screen extends React.Component<ScreenProps> {
|
|
|
280
275
|
<MaybeFreeze freeze={activityState === 0}>
|
|
281
276
|
<AnimatedNativeScreen
|
|
282
277
|
{...props}
|
|
283
|
-
statusBarColor={processedColor}
|
|
284
278
|
activityState={activityState}
|
|
285
279
|
// This prevents showing blank screen when navigating between multiple screens with freezing
|
|
286
280
|
// https://github.com/software-mansion/react-native-screens/pull/1208
|
|
@@ -111,6 +111,12 @@ export type NativeStackNavigationOptions = {
|
|
|
111
111
|
* @platform ios
|
|
112
112
|
*/
|
|
113
113
|
gestureEnabled?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Use it to restrict the distance from the edges of screen in which the gesture should be recognized. To be used alongside `fullScreenSwipeEnabled`.
|
|
116
|
+
*
|
|
117
|
+
* @platform ios
|
|
118
|
+
*/
|
|
119
|
+
gestureResponseDistance?: ScreenProps['gestureResponseDistance'];
|
|
114
120
|
/**
|
|
115
121
|
* Title to display in the back button.
|
|
116
122
|
* Only supported on iOS.
|
|
@@ -249,6 +255,12 @@ export type NativeStackNavigationOptions = {
|
|
|
249
255
|
* @platform ios
|
|
250
256
|
*/
|
|
251
257
|
homeIndicatorHidden?: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Whether the keyboard should hide when swiping to the previous screen. Defaults to `false`.
|
|
260
|
+
*
|
|
261
|
+
* @platform ios
|
|
262
|
+
*/
|
|
263
|
+
hideKeyboardOnSwipe?: boolean;
|
|
252
264
|
/**
|
|
253
265
|
* 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.
|
|
254
266
|
* Unfortunately the same behavior is not available on iOS since the behavior of native back button cannot be changed there.
|
|
@@ -151,6 +151,7 @@ const RouteView = ({
|
|
|
151
151
|
const {
|
|
152
152
|
gestureEnabled,
|
|
153
153
|
headerShown,
|
|
154
|
+
hideKeyboardOnSwipe,
|
|
154
155
|
homeIndicatorHidden,
|
|
155
156
|
nativeBackButtonDismissalEnabled = false,
|
|
156
157
|
navigationBarColor,
|
|
@@ -169,6 +170,7 @@ const RouteView = ({
|
|
|
169
170
|
let {
|
|
170
171
|
customAnimationOnSwipe,
|
|
171
172
|
fullScreenSwipeEnabled,
|
|
173
|
+
gestureResponseDistance,
|
|
172
174
|
stackAnimation,
|
|
173
175
|
stackPresentation = 'push',
|
|
174
176
|
} = options;
|
|
@@ -190,6 +192,29 @@ const RouteView = ({
|
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
194
|
|
|
195
|
+
if (gestureResponseDistance === undefined) {
|
|
196
|
+
// default values, required for unification of Fabric & Paper implementation
|
|
197
|
+
gestureResponseDistance = {
|
|
198
|
+
start: -1,
|
|
199
|
+
end: -1,
|
|
200
|
+
top: -1,
|
|
201
|
+
bottom: -1,
|
|
202
|
+
};
|
|
203
|
+
} else {
|
|
204
|
+
if (gestureResponseDistance.start === undefined) {
|
|
205
|
+
gestureResponseDistance.start = -1;
|
|
206
|
+
}
|
|
207
|
+
if (gestureResponseDistance.end === undefined) {
|
|
208
|
+
gestureResponseDistance.end = -1;
|
|
209
|
+
}
|
|
210
|
+
if (gestureResponseDistance.top === undefined) {
|
|
211
|
+
gestureResponseDistance.top = -1;
|
|
212
|
+
}
|
|
213
|
+
if (gestureResponseDistance.bottom === undefined) {
|
|
214
|
+
gestureResponseDistance.bottom = -1;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
193
218
|
if (index === 0) {
|
|
194
219
|
// first screen should always be treated as `push`, it resolves problems with no header animation
|
|
195
220
|
// for navigator with first screen as `modal` and the next as `push`
|
|
@@ -218,8 +243,10 @@ const RouteView = ({
|
|
|
218
243
|
style={StyleSheet.absoluteFill}
|
|
219
244
|
customAnimationOnSwipe={customAnimationOnSwipe}
|
|
220
245
|
fullScreenSwipeEnabled={fullScreenSwipeEnabled}
|
|
246
|
+
hideKeyboardOnSwipe={hideKeyboardOnSwipe}
|
|
221
247
|
homeIndicatorHidden={homeIndicatorHidden}
|
|
222
248
|
gestureEnabled={isAndroid ? false : gestureEnabled}
|
|
249
|
+
gestureResponseDistance={gestureResponseDistance}
|
|
223
250
|
nativeBackButtonDismissalEnabled={nativeBackButtonDismissalEnabled}
|
|
224
251
|
navigationBarColor={navigationBarColor}
|
|
225
252
|
navigationBarHidden={navigationBarHidden}
|
|
@@ -14,6 +14,9 @@ const AnimatedScreen = Animated.createAnimatedComponent(
|
|
|
14
14
|
(Screen as unknown) as React.ComponentClass
|
|
15
15
|
);
|
|
16
16
|
|
|
17
|
+
// @ts-expect-error nativeFabricUIManager is not yet included in the RN types
|
|
18
|
+
const ENABLE_FABRIC = !!global?.nativeFabricUIManager;
|
|
19
|
+
|
|
17
20
|
const ReanimatedNativeStackScreen = React.forwardRef<
|
|
18
21
|
typeof AnimatedScreen,
|
|
19
22
|
ScreenProps
|
|
@@ -39,6 +42,9 @@ const ReanimatedNativeStackScreen = React.forwardRef<
|
|
|
39
42
|
// This should not be necessary, but is not properly managed by `react-native-reanimated`
|
|
40
43
|
// @ts-ignore wrong type
|
|
41
44
|
Platform.OS === 'android'
|
|
45
|
+
? 'onTransitionProgress'
|
|
46
|
+
: // for some reason there is a difference in required event name between architectures
|
|
47
|
+
ENABLE_FABRIC
|
|
42
48
|
? 'onTransitionProgress'
|
|
43
49
|
: 'topTransitionProgress',
|
|
44
50
|
]
|
package/src/types.tsx
CHANGED
|
@@ -70,6 +70,13 @@ export type TransitionProgressEventType = {
|
|
|
70
70
|
goingForward: number;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
export type GestureResponseDistanceType = {
|
|
74
|
+
start?: number;
|
|
75
|
+
end?: number;
|
|
76
|
+
top?: number;
|
|
77
|
+
bottom?: number;
|
|
78
|
+
};
|
|
79
|
+
|
|
73
80
|
export interface ScreenProps extends ViewProps {
|
|
74
81
|
active?: 0 | 1 | Animated.AnimatedInterpolation;
|
|
75
82
|
activityState?: 0 | 1 | 2 | Animated.AnimatedInterpolation;
|
|
@@ -102,12 +109,24 @@ export interface ScreenProps extends ViewProps {
|
|
|
102
109
|
* @platform ios
|
|
103
110
|
*/
|
|
104
111
|
gestureEnabled?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Use it to restrict the distance from the edges of screen in which the gesture should be recognized. To be used alongside `fullScreenSwipeEnabled`.
|
|
114
|
+
*
|
|
115
|
+
* @platform ios
|
|
116
|
+
*/
|
|
117
|
+
gestureResponseDistance?: GestureResponseDistanceType;
|
|
105
118
|
/**
|
|
106
119
|
* Whether the home indicator should be hidden on this screen. Defaults to `false`.
|
|
107
120
|
*
|
|
108
121
|
* @platform ios
|
|
109
122
|
*/
|
|
110
123
|
homeIndicatorHidden?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Whether the keyboard should hide when swiping to the previous screen. Defaults to `false`.
|
|
126
|
+
*
|
|
127
|
+
* @platform ios
|
|
128
|
+
*/
|
|
129
|
+
hideKeyboardOnSwipe?: boolean;
|
|
111
130
|
/**
|
|
112
131
|
* 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.
|
|
113
132
|
* Unfortunately the same behavior is not available on iOS since the behavior of native back button cannot be changed there.
|
|
@@ -425,6 +444,12 @@ export interface SearchBarProps {
|
|
|
425
444
|
* The search field background color
|
|
426
445
|
*/
|
|
427
446
|
barTintColor?: string;
|
|
447
|
+
/**
|
|
448
|
+
* The color for the cursor caret and cancel button text.
|
|
449
|
+
*
|
|
450
|
+
* @platform ios
|
|
451
|
+
*/
|
|
452
|
+
tintColor?: string;
|
|
428
453
|
/**
|
|
429
454
|
* The text to be used instead of default `Cancel` button text
|
|
430
455
|
*
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
#import <UIKit/UIKit.h>
|
|
2
|
-
|
|
3
|
-
#import "RNSFullWindowOverlay.h"
|
|
4
|
-
|
|
5
|
-
#import <React/RCTTouchHandler.h>
|
|
6
|
-
|
|
7
|
-
@implementation RNSFullWindowOverlayContainer
|
|
8
|
-
|
|
9
|
-
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
|
|
10
|
-
{
|
|
11
|
-
for (UIView *view in [self subviews]) {
|
|
12
|
-
if (view.userInteractionEnabled && [view pointInside:[self convertPoint:point toView:view] withEvent:event]) {
|
|
13
|
-
return YES;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return NO;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@end
|
|
20
|
-
|
|
21
|
-
@implementation RNSFullWindowOverlay {
|
|
22
|
-
__weak RCTBridge *_bridge;
|
|
23
|
-
RNSFullWindowOverlayContainer *_container;
|
|
24
|
-
CGRect _reactFrame;
|
|
25
|
-
RCTTouchHandler *_touchHandler;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
|
29
|
-
{
|
|
30
|
-
if (self = [super init]) {
|
|
31
|
-
_bridge = bridge;
|
|
32
|
-
_reactFrame = CGRectNull;
|
|
33
|
-
_container = self.container;
|
|
34
|
-
[self show];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return self;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
- (void)reactSetFrame:(CGRect)frame
|
|
41
|
-
{
|
|
42
|
-
_reactFrame = frame;
|
|
43
|
-
[_container setFrame:frame];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
- (void)addSubview:(UIView *)view
|
|
47
|
-
{
|
|
48
|
-
[_container addSubview:view];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
- (RNSFullWindowOverlayContainer *)container
|
|
52
|
-
{
|
|
53
|
-
if (_container == nil) {
|
|
54
|
-
_container = [[RNSFullWindowOverlayContainer alloc] initWithFrame:_reactFrame];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return _container;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
- (void)show
|
|
61
|
-
{
|
|
62
|
-
UIWindow *window = RCTSharedApplication().delegate.window;
|
|
63
|
-
[window addSubview:_container];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
- (void)hide
|
|
67
|
-
{
|
|
68
|
-
if (!_container) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
[_container removeFromSuperview];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
- (void)didMoveToWindow
|
|
76
|
-
{
|
|
77
|
-
if (self.window == nil) {
|
|
78
|
-
[self hide];
|
|
79
|
-
[_touchHandler detachFromView:_container];
|
|
80
|
-
} else {
|
|
81
|
-
if (_touchHandler == nil) {
|
|
82
|
-
_touchHandler = [[RCTTouchHandler alloc] initWithBridge:_bridge];
|
|
83
|
-
}
|
|
84
|
-
[_touchHandler attachToView:_container];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
- (void)invalidate
|
|
89
|
-
{
|
|
90
|
-
[self hide];
|
|
91
|
-
_container = nil;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
@end
|
|
95
|
-
|
|
96
|
-
@implementation RNSFullWindowOverlayManager
|
|
97
|
-
|
|
98
|
-
RCT_EXPORT_MODULE()
|
|
99
|
-
|
|
100
|
-
- (UIView *)view
|
|
101
|
-
{
|
|
102
|
-
return [[RNSFullWindowOverlay alloc] initWithBridge:self.bridge];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
@end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#import <UIKit/UIKit.h>
|
|
2
|
-
|
|
3
|
-
#import <React/RCTViewComponentView.h>
|
|
4
|
-
#import "RNSScreenController.h"
|
|
5
|
-
|
|
6
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
7
|
-
|
|
8
|
-
@interface RNSScreenComponentView : RCTViewComponentView
|
|
9
|
-
|
|
10
|
-
@property (weak, nonatomic) UIView *reactSuperview;
|
|
11
|
-
@property (weak, nonatomic) UIView *config;
|
|
12
|
-
@property (nonatomic, retain) RNSScreenController *controller;
|
|
13
|
-
|
|
14
|
-
- (void)notifyWillAppear;
|
|
15
|
-
- (void)notifyWillDisappear;
|
|
16
|
-
- (void)notifyAppear;
|
|
17
|
-
- (void)notifyDisappear;
|
|
18
|
-
- (void)updateBounds;
|
|
19
|
-
- (void)notifyDismissedWithCount:(int)dismissCount;
|
|
20
|
-
|
|
21
|
-
@end
|
|
22
|
-
|
|
23
|
-
NS_ASSUME_NONNULL_END
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
#import "RNSScreenComponentView.h"
|
|
2
|
-
#import "RNSScreenStackHeaderConfigComponentView.h"
|
|
3
|
-
|
|
4
|
-
#import <React/RCTConversions.h>
|
|
5
|
-
#import <React/RCTMountingTransactionObserving.h>
|
|
6
|
-
|
|
7
|
-
#import <react/renderer/components/rnscreens/EventEmitters.h>
|
|
8
|
-
#import <react/renderer/components/rnscreens/Props.h>
|
|
9
|
-
#import <react/renderer/components/rnscreens/RCTComponentViewHelpers.h>
|
|
10
|
-
#import <rnscreens/RNSScreenComponentDescriptor.h>
|
|
11
|
-
|
|
12
|
-
#import "RCTFabricComponentsPlugins.h"
|
|
13
|
-
|
|
14
|
-
using namespace facebook::react;
|
|
15
|
-
|
|
16
|
-
@interface RNSScreenComponentView () <RCTRNSScreenViewProtocol, RCTMountingTransactionObserving>
|
|
17
|
-
@end
|
|
18
|
-
|
|
19
|
-
@implementation RNSScreenComponentView {
|
|
20
|
-
RNSScreenController *_controller;
|
|
21
|
-
RNSScreenShadowNode::ConcreteState::Shared _state;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
- (instancetype)initWithFrame:(CGRect)frame
|
|
25
|
-
{
|
|
26
|
-
if (self = [super initWithFrame:frame]) {
|
|
27
|
-
static const auto defaultProps = std::make_shared<const RNSScreenProps>();
|
|
28
|
-
_props = defaultProps;
|
|
29
|
-
_controller = [[RNSScreenController alloc] initWithView:self];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return self;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
36
|
-
{
|
|
37
|
-
[super mountChildComponentView:childComponentView index:index];
|
|
38
|
-
if ([childComponentView isKindOfClass:[RNSScreenStackHeaderConfigComponentView class]]) {
|
|
39
|
-
_config = childComponentView;
|
|
40
|
-
((RNSScreenStackHeaderConfigComponentView *)childComponentView).screenView = self;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
45
|
-
{
|
|
46
|
-
[self.controller setViewToSnapshot];
|
|
47
|
-
if ([childComponentView isKindOfClass:[RNSScreenStackHeaderConfigComponentView class]]) {
|
|
48
|
-
_config = nil;
|
|
49
|
-
}
|
|
50
|
-
[super unmountChildComponentView:childComponentView index:index];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
- (void)updateBounds
|
|
54
|
-
{
|
|
55
|
-
if (_state != nullptr) {
|
|
56
|
-
auto boundsSize = self.bounds.size;
|
|
57
|
-
auto newState = RNSScreenState{RCTSizeFromCGSize(boundsSize)};
|
|
58
|
-
_state->updateState(std::move(newState));
|
|
59
|
-
UINavigationController *navctr = _controller.navigationController;
|
|
60
|
-
[navctr.view setNeedsLayout];
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
- (UIView *)reactSuperview
|
|
65
|
-
{
|
|
66
|
-
return _reactSuperview;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
- (void)notifyWillAppear
|
|
70
|
-
{
|
|
71
|
-
// If screen is already unmounted then there will be no event emitter
|
|
72
|
-
// it will be cleaned in prepareForRecycle
|
|
73
|
-
if (_eventEmitter != nullptr) {
|
|
74
|
-
std::dynamic_pointer_cast<const RNSScreenEventEmitter>(_eventEmitter)
|
|
75
|
-
->onWillAppear(RNSScreenEventEmitter::OnWillAppear{});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
- (void)notifyWillDisappear
|
|
80
|
-
{
|
|
81
|
-
// If screen is already unmounted then there will be no event emitter
|
|
82
|
-
// it will be cleaned in prepareForRecycle
|
|
83
|
-
if (_eventEmitter != nullptr) {
|
|
84
|
-
std::dynamic_pointer_cast<const RNSScreenEventEmitter>(_eventEmitter)
|
|
85
|
-
->onWillDisappear(RNSScreenEventEmitter::OnWillDisappear{});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
- (void)notifyAppear
|
|
90
|
-
{
|
|
91
|
-
// If screen is already unmounted then there will be no event emitter
|
|
92
|
-
// it will be cleaned in prepareForRecycle
|
|
93
|
-
if (_eventEmitter != nullptr) {
|
|
94
|
-
std::dynamic_pointer_cast<const RNSScreenEventEmitter>(_eventEmitter)->onAppear(RNSScreenEventEmitter::OnAppear{});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
- (void)notifyDismissedWithCount:(int)dismissCount
|
|
99
|
-
{
|
|
100
|
-
// If screen is already unmounted then there will be no event emitter
|
|
101
|
-
// it will be cleaned in prepareForRecycle
|
|
102
|
-
if (_eventEmitter != nullptr) {
|
|
103
|
-
std::dynamic_pointer_cast<const RNSScreenEventEmitter>(_eventEmitter)
|
|
104
|
-
->onDismissed(RNSScreenEventEmitter::OnDismissed{dismissCount : dismissCount});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
- (void)notifyDisappear
|
|
109
|
-
{
|
|
110
|
-
// If screen is already unmounted then there will be no event emitter
|
|
111
|
-
// it will be cleaned in prepareForRecycle
|
|
112
|
-
if (_eventEmitter != nullptr) {
|
|
113
|
-
std::dynamic_pointer_cast<const RNSScreenEventEmitter>(_eventEmitter)
|
|
114
|
-
->onDisappear(RNSScreenEventEmitter::OnDisappear{});
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
#pragma mark - RCTMountingTransactionObserving
|
|
119
|
-
|
|
120
|
-
- (void)mountingTransactionWillMountWithMetadata:(MountingTransactionMetadata const &)metadata
|
|
121
|
-
{
|
|
122
|
-
[self.controller takeSnapshot];
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
#pragma mark - RCTComponentViewProtocol
|
|
126
|
-
|
|
127
|
-
- (void)prepareForRecycle
|
|
128
|
-
{
|
|
129
|
-
[super prepareForRecycle];
|
|
130
|
-
// TODO: Make sure that there is no edge case when this should be uncommented
|
|
131
|
-
// _controller=nil;
|
|
132
|
-
_state.reset();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
136
|
-
{
|
|
137
|
-
return concreteComponentDescriptorProvider<RNSScreenComponentDescriptor>();
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
141
|
-
{
|
|
142
|
-
const auto &oldScreenProps = *std::static_pointer_cast<const RNSScreenProps>(_props);
|
|
143
|
-
const auto &newScreenProps = *std::static_pointer_cast<const RNSScreenProps>(props);
|
|
144
|
-
|
|
145
|
-
[super updateProps:props oldProps:oldProps];
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
- (void)updateState:(facebook::react::State::Shared const &)state
|
|
149
|
-
oldState:(facebook::react::State::Shared const &)oldState
|
|
150
|
-
{
|
|
151
|
-
_state = std::static_pointer_cast<const RNSScreenShadowNode::ConcreteState>(state);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
@end
|
|
155
|
-
|
|
156
|
-
Class<RCTComponentViewProtocol> RNSScreenCls(void)
|
|
157
|
-
{
|
|
158
|
-
return RNSScreenComponentView.class;
|
|
159
|
-
}
|