react-native-screens 3.18.2 → 3.20.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 +30 -38
- package/android/build.gradle +1 -5
- package/ios/RNSFullWindowOverlay.mm +32 -0
- package/ios/RNSScreen.h +3 -2
- package/ios/RNSScreen.mm +34 -2
- package/ios/RNSScreenStackHeaderConfig.mm +17 -1
- package/lib/commonjs/TransitionProgressContext.js +2 -7
- package/lib/commonjs/TransitionProgressContext.js.map +1 -1
- package/lib/commonjs/createNativeStackNavigator.js +29 -76
- package/lib/commonjs/createNativeStackNavigator.js.map +1 -1
- package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js +0 -5
- package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenContainerNativeComponent.js +0 -5
- package/lib/commonjs/fabric/ScreenContainerNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenNativeComponent.js +0 -5
- package/lib/commonjs/fabric/ScreenNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js +0 -5
- package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js +2 -10
- package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenStackHeaderSubviewNativeComponent.js +2 -10
- package/lib/commonjs/fabric/ScreenStackHeaderSubviewNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenStackNativeComponent.js +0 -5
- package/lib/commonjs/fabric/ScreenStackNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/SearchBarNativeComponent.js +0 -7
- package/lib/commonjs/fabric/SearchBarNativeComponent.js.map +1 -1
- package/lib/commonjs/index.js +21 -45
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.native.js +46 -104
- package/lib/commonjs/index.native.js.map +1 -1
- package/lib/commonjs/native-stack/index.js +6 -11
- package/lib/commonjs/native-stack/index.js.map +1 -1
- package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js +18 -25
- package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/commonjs/native-stack/types.js +4 -0
- package/lib/commonjs/native-stack/types.js.map +1 -1
- package/lib/commonjs/native-stack/utils/HeaderHeightContext.js +2 -6
- package/lib/commonjs/native-stack/utils/HeaderHeightContext.js.map +1 -1
- package/lib/commonjs/native-stack/utils/SafeAreaProviderCompat.js +11 -19
- package/lib/commonjs/native-stack/utils/SafeAreaProviderCompat.js.map +1 -1
- package/lib/commonjs/native-stack/utils/getDefaultHeaderHeight.js +0 -7
- package/lib/commonjs/native-stack/utils/getDefaultHeaderHeight.js.map +1 -1
- package/lib/commonjs/native-stack/utils/useBackPressSubscription.js +7 -18
- package/lib/commonjs/native-stack/utils/useBackPressSubscription.js.map +1 -1
- package/lib/commonjs/native-stack/utils/useHeaderHeight.js +2 -10
- package/lib/commonjs/native-stack/utils/useHeaderHeight.js.map +1 -1
- package/lib/commonjs/native-stack/views/FontProcessor.js +1 -6
- package/lib/commonjs/native-stack/views/FontProcessor.js.map +1 -1
- package/lib/commonjs/native-stack/views/HeaderConfig.js +46 -50
- package/lib/commonjs/native-stack/views/HeaderConfig.js.map +1 -1
- package/lib/commonjs/native-stack/views/NativeStackView.js +32 -58
- package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js +11 -21
- package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedScreen.js +3 -10
- package/lib/commonjs/reanimated/ReanimatedScreen.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedScreenProvider.js +6 -20
- package/lib/commonjs/reanimated/ReanimatedScreenProvider.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedTransitionProgressContext.js +2 -7
- package/lib/commonjs/reanimated/ReanimatedTransitionProgressContext.js.map +1 -1
- package/lib/commonjs/reanimated/index.js +0 -3
- package/lib/commonjs/reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated/useReanimatedTransitionProgress.js +2 -10
- package/lib/commonjs/reanimated/useReanimatedTransitionProgress.js.map +1 -1
- package/lib/commonjs/types.js +4 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/useTransitionProgress.js +2 -10
- package/lib/commonjs/useTransitionProgress.js.map +1 -1
- package/lib/commonjs/utils.js +0 -4
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/TransitionProgressContext.js.map +1 -1
- package/lib/module/createNativeStackNavigator.js +29 -67
- package/lib/module/createNativeStackNavigator.js.map +1 -1
- package/lib/module/fabric/FullWindowOverlayNativeComponent.js +0 -1
- package/lib/module/fabric/FullWindowOverlayNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenContainerNativeComponent.js +0 -1
- package/lib/module/fabric/ScreenContainerNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenNativeComponent.js +0 -1
- package/lib/module/fabric/ScreenNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenNavigationContainerNativeComponent.js +0 -1
- package/lib/module/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js +0 -1
- package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenStackHeaderSubviewNativeComponent.js +0 -1
- package/lib/module/fabric/ScreenStackHeaderSubviewNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenStackNativeComponent.js +0 -1
- package/lib/module/fabric/ScreenStackNativeComponent.js.map +1 -1
- package/lib/module/fabric/SearchBarNativeComponent.js +0 -1
- package/lib/module/fabric/SearchBarNativeComponent.js.map +1 -1
- package/lib/module/index.js +13 -11
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.native.js +48 -94
- package/lib/module/index.native.js.map +1 -1
- package/lib/module/native-stack/index.js +3 -2
- package/lib/module/native-stack/index.js.map +1 -1
- package/lib/module/native-stack/navigators/createNativeStackNavigator.js +16 -16
- package/lib/module/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/module/native-stack/types.js +1 -1
- package/lib/module/native-stack/types.js.map +1 -1
- package/lib/module/native-stack/utils/HeaderHeightContext.js.map +1 -1
- package/lib/module/native-stack/utils/SafeAreaProviderCompat.js +8 -7
- package/lib/module/native-stack/utils/SafeAreaProviderCompat.js.map +1 -1
- package/lib/module/native-stack/utils/getDefaultHeaderHeight.js +0 -4
- package/lib/module/native-stack/utils/getDefaultHeaderHeight.js.map +1 -1
- package/lib/module/native-stack/utils/useBackPressSubscription.js +7 -8
- package/lib/module/native-stack/utils/useBackPressSubscription.js.map +1 -1
- package/lib/module/native-stack/utils/useHeaderHeight.js +0 -2
- package/lib/module/native-stack/utils/useHeaderHeight.js.map +1 -1
- package/lib/module/native-stack/views/FontProcessor.js +0 -3
- package/lib/module/native-stack/views/FontProcessor.js.map +1 -1
- package/lib/module/native-stack/views/HeaderConfig.js +44 -39
- package/lib/module/native-stack/views/HeaderConfig.js.map +1 -1
- package/lib/module/native-stack/views/NativeStackView.js +32 -42
- package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/module/reanimated/ReanimatedNativeStackScreen.js +12 -9
- package/lib/module/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
- package/lib/module/reanimated/ReanimatedScreen.js +5 -4
- package/lib/module/reanimated/ReanimatedScreen.js.map +1 -1
- package/lib/module/reanimated/ReanimatedScreenProvider.js +6 -15
- package/lib/module/reanimated/ReanimatedScreenProvider.js.map +1 -1
- package/lib/module/reanimated/ReanimatedTransitionProgressContext.js +2 -1
- package/lib/module/reanimated/ReanimatedTransitionProgressContext.js.map +1 -1
- package/lib/module/reanimated/index.js.map +1 -1
- package/lib/module/reanimated/useReanimatedTransitionProgress.js +0 -2
- package/lib/module/reanimated/useReanimatedTransitionProgress.js.map +1 -1
- package/lib/module/types.js +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/useTransitionProgress.js +0 -2
- package/lib/module/useTransitionProgress.js.map +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/TransitionProgressContext.d.ts +1 -1
- package/lib/typescript/createNativeStackNavigator.d.ts +5 -5
- package/lib/typescript/index.d.ts +4 -2
- package/lib/typescript/native-stack/navigators/createNativeStackNavigator.d.ts +3 -2
- package/lib/typescript/native-stack/types.d.ts +9 -9
- package/lib/typescript/native-stack/utils/SafeAreaProviderCompat.d.ts +1 -1
- package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts +1 -1
- package/lib/typescript/native-stack/views/HeaderConfig.d.ts +2 -1
- package/lib/typescript/native-stack/views/NativeStackView.d.ts +2 -1
- package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts +1 -1
- package/lib/typescript/reanimated/ReanimatedScreen.d.ts +1 -1
- package/lib/typescript/reanimated/ReanimatedTransitionProgressContext.d.ts +1 -1
- package/lib/typescript/types.d.ts +10 -9
- package/package.json +10 -2
- package/src/createNativeStackNavigator.tsx +4 -2
- package/src/index.native.tsx +32 -16
- package/src/index.tsx +13 -8
- package/src/native-stack/types.tsx +4 -5
- package/src/native-stack/views/HeaderConfig.tsx +8 -10
- package/src/native-stack/views/NativeStackView.tsx +8 -4
- package/src/reanimated/ReanimatedNativeStackScreen.tsx +5 -3
- package/src/reanimated/ReanimatedScreen.tsx +1 -1
- package/android/src/main/java/com/swmansion/rnscreens/LifecycleHelper.kt +0 -60
package/README.md
CHANGED
|
@@ -18,31 +18,7 @@ To learn about how to use `react-native-screens` with Fabric architecture, head
|
|
|
18
18
|
|
|
19
19
|
### iOS
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
To make sure that there are no issues with screen orientation you should put following code in your `AppDelegate.m`:
|
|
23
|
-
|
|
24
|
-
```objective-c
|
|
25
|
-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
|
26
|
-
{
|
|
27
|
-
...
|
|
28
|
-
#if !TARGET_OS_TV
|
|
29
|
-
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
|
|
30
|
-
#endif // !TARGET_OS_TV
|
|
31
|
-
...
|
|
32
|
-
return YES:
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
- (void)applicationWillTerminate:(UIApplication *)application
|
|
36
|
-
{
|
|
37
|
-
#if !TARGET_OS_TV
|
|
38
|
-
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
|
|
39
|
-
#endif // !TARGET_OS_TV
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
You can see example of these changes being introduced in our [example applications](https://github.com/software-mansion/react-native-screens/blob/main/TestsExample/ios/TestsExample/AppDelegate.mm).
|
|
44
|
-
|
|
45
|
-
Other aspects of installation should be completely handled with auto-linking, just ensure you installed pods after adding this module.
|
|
21
|
+
Installation on iOS is completely handled with auto-linking, if you have ensured pods are installed after adding this module, no other actions are necessary.
|
|
46
22
|
|
|
47
23
|
### Android
|
|
48
24
|
|
|
@@ -51,13 +27,24 @@ On Android the View state is not persisted consistently across Activity restarts
|
|
|
51
27
|
For most people using an app built from the react-native template, that means editing `MainActivity.java`, likely located in `android/app/src/main/java/<your package name>/MainActivity.java`
|
|
52
28
|
|
|
53
29
|
You should add this code, which specifically discards any Activity state persisted during the Activity restart process, to avoid inconsistencies that lead to crashes.
|
|
30
|
+
Please note that the override code should not be placed inside `MainActivityDelegate`, but rather directly in `MainActivity`.
|
|
54
31
|
|
|
55
32
|
```java
|
|
56
33
|
import android.os.Bundle;
|
|
57
34
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
35
|
+
public class MainActivity extends ReactActivity {
|
|
36
|
+
|
|
37
|
+
//...code
|
|
38
|
+
|
|
39
|
+
//react-native-screens override
|
|
40
|
+
@Override
|
|
41
|
+
protected void onCreate(Bundle savedInstanceState) {
|
|
42
|
+
super.onCreate(null);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public static class MainActivityDelegate extends ReactActivityDelegate {
|
|
46
|
+
//...code
|
|
47
|
+
}
|
|
61
48
|
}
|
|
62
49
|
```
|
|
63
50
|
|
|
@@ -81,6 +68,7 @@ buildscript {
|
|
|
81
68
|
```
|
|
82
69
|
|
|
83
70
|
**Disclaimer**: `react-native-screens` requires Kotlin `1.3.50` or higher.
|
|
71
|
+
|
|
84
72
|
</details>
|
|
85
73
|
|
|
86
74
|
### Windows
|
|
@@ -100,17 +88,17 @@ Screens are already integrated with the React Native's most popular navigation l
|
|
|
100
88
|
| 2.0.0+ | 0.60.0+ |
|
|
101
89
|
|
|
102
90
|
### Support for Fabric
|
|
103
|
-
[Fabric](https://reactnative.dev/architecture/fabric-renderer) is React Native's new rendering system.
|
|
104
91
|
|
|
105
|
-
|
|
106
|
-
|
|
92
|
+
[Fabric](https://reactnative.dev/architecture/fabric-renderer) is React Native's new rendering system.
|
|
93
|
+
|
|
94
|
+
- As of [version `3.18.0`](https://github.com/software-mansion/react-native-screens/releases/tag/3.18.0) of this project, Fabric is supported only for react-native 0.70+. Support for lower versions has been dropped.
|
|
95
|
+
- As of [version `3.14.0`](https://github.com/software-mansion/react-native-screens/releases/tag/3.14.0) of this project, Fabric is supported only for react-native 0.69+. Support for lower versions has been dropped.
|
|
107
96
|
|
|
108
97
|
| version | react-native version |
|
|
109
98
|
| ------- | -------------------- |
|
|
110
99
|
| 3.18.0+ | 0.70.0+ |
|
|
111
100
|
| 3.14.0+ | 0.69.0+ |
|
|
112
101
|
|
|
113
|
-
|
|
114
102
|
## Usage with [react-navigation](https://github.com/react-navigation/react-navigation)
|
|
115
103
|
|
|
116
104
|
Screens support is built into [react-navigation](https://github.com/react-navigation/react-navigation) starting from version [2.14.0](https://github.com/react-navigation/react-navigation/releases/tag/2.14.0) for all the different navigator types (stack, tab, drawer, etc).
|
|
@@ -167,6 +155,10 @@ To take advantage of the native stack navigator primitive for React Navigation t
|
|
|
167
155
|
- for React Navigation v5 to the [README in react-native-screens/native-stack](https://github.com/software-mansion/react-native-screens/tree/main/native-stack)
|
|
168
156
|
- for older versions to the [README in react-native-screens/createNativeStackNavigator](https://github.com/software-mansion/react-native-screens/tree/main/createNativeStackNavigator)
|
|
169
157
|
|
|
158
|
+
## `FullWindowOverlay`
|
|
159
|
+
|
|
160
|
+
Native `iOS` component for rendering views straight under the `Window`. Based on `RCTPerfMonitor`. You should treat it as a wrapper, providing full-screen, transparent view which receives no props and should ideally render one child `View`, being the root of its view hierarchy. For the example usage, see https://github.com/software-mansion/react-native-screens/blob/main/TestsExample/src/Test1096.tsx
|
|
161
|
+
|
|
170
162
|
## Interop with [react-native-navigation](https://github.com/wix/react-native-navigation)
|
|
171
163
|
|
|
172
164
|
React-native-navigation library already uses native containers for rendering navigation scenes so wrapping these scenes with `<ScreenContainer>` or `<Screen>` component does not provide any benefits. Yet if you would like to build a component that uses screens primitives under the hood (for example a view pager component) it is safe to use `<ScreenContainer>` and `<Screen>` components for that as these work out of the box when rendered on react-native-navigation scenes.
|
|
@@ -194,12 +186,12 @@ Use `ScrollView` with prop `contentInsetAdjustmentBehavior=“automatic”` as a
|
|
|
194
186
|
|
|
195
187
|
### Other problems
|
|
196
188
|
|
|
197
|
-
| Problem
|
|
198
|
-
|
|
|
199
|
-
| [SVG component becomes transparent when goBack](https://github.com/software-mansion/react-native-screens/issues/773)
|
|
200
|
-
| [Memory leak while moving from one screen to another in the same stack](https://github.com/software-mansion/react-native-screens/issues/843)
|
|
201
|
-
| [LargeHeader stays small after pop/goBack/swipe gesture on iOS 14+](https://github.com/software-mansion/react-native-screens/issues/649)
|
|
202
|
-
| [`onScroll` and `onMomentumScrollEnd` of previous screen triggered in bottom tabs](https://github.com/software-mansion/react-native-screens/issues/1183)
|
|
189
|
+
| Problem | Solution |
|
|
190
|
+
| -------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
191
|
+
| [SVG component becomes transparent when goBack](https://github.com/software-mansion/react-native-screens/issues/773) | [related PRs](https://github.com/software-mansion/react-native-screens/issues/773#issuecomment-783469792) |
|
|
192
|
+
| [Memory leak while moving from one screen to another in the same stack](https://github.com/software-mansion/react-native-screens/issues/843) | [explanation](https://github.com/software-mansion/react-native-screens/issues/843#issuecomment-832034119) |
|
|
193
|
+
| [LargeHeader stays small after pop/goBack/swipe gesture on iOS 14+](https://github.com/software-mansion/react-native-screens/issues/649) | [potential fix](https://github.com/software-mansion/react-native-screens/issues/649#issuecomment-712199895) |
|
|
194
|
+
| [`onScroll` and `onMomentumScrollEnd` of previous screen triggered in bottom tabs](https://github.com/software-mansion/react-native-screens/issues/1183) | [explanation](https://github.com/software-mansion/react-native-screens/issues/1183#issuecomment-949313111) |
|
|
203
195
|
|
|
204
196
|
## Contributing
|
|
205
197
|
|
package/android/build.gradle
CHANGED
|
@@ -103,11 +103,7 @@ repositories {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
dependencies {
|
|
106
|
-
|
|
107
|
-
implementation project(":ReactAndroid")
|
|
108
|
-
} else {
|
|
109
|
-
implementation 'com.facebook.react:react-native:+'
|
|
110
|
-
}
|
|
106
|
+
implementation 'com.facebook.react:react-native:+'
|
|
111
107
|
implementation 'androidx.appcompat:appcompat:1.1.0'
|
|
112
108
|
implementation 'androidx.fragment:fragment:1.2.1'
|
|
113
109
|
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
|
|
@@ -25,6 +25,38 @@
|
|
|
25
25
|
return NO;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
|
|
29
|
+
{
|
|
30
|
+
BOOL canReceiveTouchEvents = ([self isUserInteractionEnabled] && ![self isHidden]);
|
|
31
|
+
if (!canReceiveTouchEvents) {
|
|
32
|
+
return nil;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// `hitSubview` is the topmost subview which was hit. The hit point can
|
|
36
|
+
// be outside the bounds of `view` (e.g., if -clipsToBounds is NO).
|
|
37
|
+
UIView *hitSubview = nil;
|
|
38
|
+
BOOL isPointInside = [self pointInside:point withEvent:event];
|
|
39
|
+
if (![self clipsToBounds] || isPointInside) {
|
|
40
|
+
// Take z-index into account when calculating the touch target.
|
|
41
|
+
NSArray<UIView *> *sortedSubviews = [self reactZIndexSortedSubviews];
|
|
42
|
+
|
|
43
|
+
// The default behaviour of UIKit is that if a view does not contain a point,
|
|
44
|
+
// then no subviews will be returned from hit testing, even if they contain
|
|
45
|
+
// the hit point. By doing hit testing directly on the subviews, we bypass
|
|
46
|
+
// the strict containment policy (i.e., UIKit guarantees that every ancestor
|
|
47
|
+
// of the hit view will return YES from -pointInside:withEvent:). See:
|
|
48
|
+
// - https://developer.apple.com/library/ios/qa/qa2013/qa1812.html
|
|
49
|
+
for (UIView *subview in [sortedSubviews reverseObjectEnumerator]) {
|
|
50
|
+
CGPoint convertedPoint = [subview convertPoint:point fromView:self];
|
|
51
|
+
hitSubview = [subview hitTest:convertedPoint withEvent:event];
|
|
52
|
+
if (hitSubview != nil) {
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return hitSubview;
|
|
58
|
+
}
|
|
59
|
+
|
|
28
60
|
@end
|
|
29
61
|
|
|
30
62
|
@implementation RNSFullWindowOverlay {
|
package/ios/RNSScreen.h
CHANGED
|
@@ -58,6 +58,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
58
58
|
@property (nonatomic) RNSScreenStackPresentation stackPresentation;
|
|
59
59
|
@property (nonatomic) RNSScreenSwipeDirection swipeDirection;
|
|
60
60
|
@property (nonatomic) RNSScreenReplaceAnimation replaceAnimation;
|
|
61
|
+
|
|
61
62
|
@property (nonatomic, retain) NSNumber *transitionDuration;
|
|
62
63
|
@property (nonatomic, readonly) BOOL dismissed;
|
|
63
64
|
@property (nonatomic) BOOL hideKeyboardOnSwipe;
|
|
@@ -74,7 +75,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
74
75
|
@property (nonatomic) UIInterfaceOrientationMask screenOrientation;
|
|
75
76
|
@property (nonatomic) BOOL statusBarHidden;
|
|
76
77
|
@property (nonatomic) BOOL homeIndicatorHidden;
|
|
77
|
-
#endif
|
|
78
|
+
#endif // !TARGET_OS_TV
|
|
78
79
|
|
|
79
80
|
#ifdef RN_FABRIC_ENABLED
|
|
80
81
|
// we recreate the behavior of `reactSetFrame` on new architecture
|
|
@@ -89,7 +90,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
89
90
|
@property (nonatomic, copy) RCTDirectEventBlock onWillDisappear;
|
|
90
91
|
@property (nonatomic, copy) RCTDirectEventBlock onNativeDismissCancelled;
|
|
91
92
|
@property (nonatomic, copy) RCTDirectEventBlock onTransitionProgress;
|
|
92
|
-
#endif
|
|
93
|
+
#endif // RN_FABRIC_ENABLED
|
|
93
94
|
|
|
94
95
|
- (void)notifyFinishTransitioning;
|
|
95
96
|
|
package/ios/RNSScreen.mm
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
|
|
58
58
|
return self;
|
|
59
59
|
}
|
|
60
|
-
#endif
|
|
60
|
+
#endif // RN_FABRIC_ENABLED
|
|
61
61
|
|
|
62
62
|
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
|
63
63
|
{
|
|
@@ -146,6 +146,7 @@
|
|
|
146
146
|
// ignored, we only need to keep in mind not to set presentation delegate
|
|
147
147
|
break;
|
|
148
148
|
}
|
|
149
|
+
|
|
149
150
|
// There is a bug in UIKit which causes retain loop when presentationController is accessed for a
|
|
150
151
|
// controller that is not going to be presented modally. We therefore need to avoid setting the
|
|
151
152
|
// delegate for screens presented using push. This also means that when controller is updated from
|
|
@@ -612,7 +613,7 @@
|
|
|
612
613
|
if (newScreenProps.homeIndicatorHidden != oldScreenProps.homeIndicatorHidden) {
|
|
613
614
|
[self setHomeIndicatorHidden:newScreenProps.homeIndicatorHidden];
|
|
614
615
|
}
|
|
615
|
-
#endif
|
|
616
|
+
#endif // !TARGET_OS_TV
|
|
616
617
|
|
|
617
618
|
// Notice that we compare against _stackPresentation, not oldScreenProps.stackPresentation.
|
|
618
619
|
// See comment in prepareForRecycle method for explanation.
|
|
@@ -1198,11 +1199,42 @@ RCT_EXPORT_VIEW_PROPERTY(statusBarStyle, RNSStatusBarStyle)
|
|
|
1198
1199
|
RCT_EXPORT_VIEW_PROPERTY(homeIndicatorHidden, BOOL)
|
|
1199
1200
|
#endif
|
|
1200
1201
|
|
|
1202
|
+
#if !TARGET_OS_TV
|
|
1203
|
+
// See:
|
|
1204
|
+
// 1. https://github.com/software-mansion/react-native-screens/pull/1543
|
|
1205
|
+
// 2. https://github.com/software-mansion/react-native-screens/pull/1596
|
|
1206
|
+
// This class is instatiated from React Native's internals during application startup
|
|
1207
|
+
- (instancetype)init
|
|
1208
|
+
{
|
|
1209
|
+
if (self = [super init]) {
|
|
1210
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
1211
|
+
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
return self;
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
- (void)dealloc
|
|
1218
|
+
{
|
|
1219
|
+
dispatch_sync(dispatch_get_main_queue(), ^{
|
|
1220
|
+
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
#endif // !TARGET_OS_TV
|
|
1224
|
+
|
|
1201
1225
|
- (UIView *)view
|
|
1202
1226
|
{
|
|
1203
1227
|
return [[RNSScreenView alloc] initWithBridge:self.bridge];
|
|
1204
1228
|
}
|
|
1205
1229
|
|
|
1230
|
+
+ (BOOL)requiresMainQueueSetup
|
|
1231
|
+
{
|
|
1232
|
+
// Returning NO here despite the fact some initialization in -init method dispatches tasks
|
|
1233
|
+
// on main queue, because the comments in RN source code states that modules which return YES
|
|
1234
|
+
// here will be constructed ahead-of-time -- and this is not required in our case.
|
|
1235
|
+
return NO;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1206
1238
|
@end
|
|
1207
1239
|
|
|
1208
1240
|
@implementation RCTConvert (RNSScreen)
|
|
@@ -460,7 +460,23 @@
|
|
|
460
460
|
}
|
|
461
461
|
|
|
462
462
|
#if !TARGET_OS_TV
|
|
463
|
-
|
|
463
|
+
// Fix for github.com/react-navigation/react-navigation/issues/11015
|
|
464
|
+
// It allows to hide back button title and use back button menu as normal.
|
|
465
|
+
// Back button display mode and back button menu are available since iOS 14.
|
|
466
|
+
if (@available(iOS 14.0, *)) {
|
|
467
|
+
// Make sure to set display mode to default.
|
|
468
|
+
// This line resets back button display mode - especially needed on the Fabric architecture.
|
|
469
|
+
navitem.backButtonDisplayMode = UINavigationItemBackButtonDisplayModeDefault;
|
|
470
|
+
|
|
471
|
+
NSString *trimmedBackTitle =
|
|
472
|
+
[config.backTitle stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
|
473
|
+
|
|
474
|
+
// When an whitespace only back title is passed set back button mode to minimal.
|
|
475
|
+
if (config.backTitle != nil && [trimmedBackTitle length] == 0) {
|
|
476
|
+
navitem.backButtonDisplayMode = UINavigationItemBackButtonDisplayModeMinimal;
|
|
477
|
+
}
|
|
478
|
+
} else if (
|
|
479
|
+
config.backTitle != nil || config.backTitleFontFamily || config.backTitleFontSize ||
|
|
464
480
|
config.disableBackButtonMenu) {
|
|
465
481
|
RNSUIBarButtonItem *backBarButtonItem = [[RNSUIBarButtonItem alloc] initWithTitle:config.backTitle ?: prevItem.title
|
|
466
482
|
style:UIBarButtonItemStylePlain
|
|
@@ -4,14 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var React = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
-
|
|
8
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
10
|
var _default = /*#__PURE__*/React.createContext(undefined);
|
|
15
|
-
|
|
16
11
|
exports.default = _default;
|
|
17
12
|
//# sourceMappingURL=TransitionProgressContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["React","createContext","undefined"],"sources":["TransitionProgressContext.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Animated } from 'react-native';\n\ntype TransitionProgressContextBody = {\n progress: Animated.Value;\n closing: Animated.Value;\n goingForward: Animated.Value;\n};\n\nexport default React.createContext<TransitionProgressContextBody | undefined>(\n undefined\n);\n"],"mappings":";;;;;;AAAA;AAA+B;AAAA;AAAA,4BAShBA,KAAK,CAACC,aAAa,CAChCC,SAAS,CACV;AAAA"}
|
|
@@ -4,33 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _reactNative = require("react-native");
|
|
11
|
-
|
|
12
9
|
var _reactNativeScreens = require("react-native-screens");
|
|
13
|
-
|
|
14
10
|
var _reactNavigation = require("react-navigation");
|
|
15
|
-
|
|
16
11
|
var _reactNavigationStack = require("react-navigation-stack");
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
|
-
|
|
13
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
22
14
|
const REMOVE_ACTION = 'NativeStackNavigator/REMOVE';
|
|
23
15
|
const isAndroid = _reactNative.Platform.OS === 'android';
|
|
24
16
|
let didWarn = isAndroid;
|
|
25
|
-
|
|
26
17
|
function renderComponentOrThunk(componentOrThunk, props) {
|
|
27
18
|
if (typeof componentOrThunk === 'function') {
|
|
28
19
|
return componentOrThunk(props);
|
|
29
20
|
}
|
|
30
|
-
|
|
31
21
|
return componentOrThunk;
|
|
32
22
|
}
|
|
33
|
-
|
|
34
23
|
function removeScene(route, dismissCount, navigation) {
|
|
35
24
|
navigation.dispatch({
|
|
36
25
|
// @ts-ignore special navigation action for native stack
|
|
@@ -40,23 +29,19 @@ function removeScene(route, dismissCount, navigation) {
|
|
|
40
29
|
dismissCount
|
|
41
30
|
});
|
|
42
31
|
}
|
|
43
|
-
|
|
44
32
|
function onAppear(route, descriptor, navigation) {
|
|
45
33
|
var _descriptor$options, _descriptor$options$o;
|
|
46
|
-
|
|
47
34
|
(_descriptor$options = descriptor.options) === null || _descriptor$options === void 0 ? void 0 : (_descriptor$options$o = _descriptor$options.onAppear) === null || _descriptor$options$o === void 0 ? void 0 : _descriptor$options$o.call(_descriptor$options);
|
|
48
35
|
navigation.dispatch(_reactNavigation.StackActions.completeTransition({
|
|
49
36
|
toChildKey: route.key,
|
|
50
37
|
key: navigation.state.key
|
|
51
38
|
}));
|
|
52
39
|
}
|
|
53
|
-
|
|
54
40
|
function onFinishTransitioning(navigation) {
|
|
55
41
|
const {
|
|
56
42
|
routes
|
|
57
43
|
} = navigation.state;
|
|
58
44
|
const lastRoute = (routes === null || routes === void 0 ? void 0 : routes.length) && routes[routes.length - 1];
|
|
59
|
-
|
|
60
45
|
if (lastRoute) {
|
|
61
46
|
navigation.dispatch(_reactNavigation.StackActions.completeTransition({
|
|
62
47
|
toChildKey: lastRoute.key,
|
|
@@ -64,7 +49,6 @@ function onFinishTransitioning(navigation) {
|
|
|
64
49
|
}));
|
|
65
50
|
}
|
|
66
51
|
}
|
|
67
|
-
|
|
68
52
|
function renderHeaderConfig(index, route, descriptor, navigationConfig) {
|
|
69
53
|
const {
|
|
70
54
|
options
|
|
@@ -130,31 +114,25 @@ function renderHeaderConfig(index, route, descriptor, navigationConfig) {
|
|
|
130
114
|
translucent: headerTranslucent || translucent || false
|
|
131
115
|
};
|
|
132
116
|
const hasHeader = headerShown !== false && headerMode !== 'none' && options.header !== null;
|
|
133
|
-
|
|
134
117
|
if (!hasHeader) {
|
|
135
118
|
return /*#__PURE__*/_react.default.createElement(_reactNativeScreens.ScreenStackHeaderConfig, _extends({}, headerOptions, {
|
|
136
119
|
hidden: true
|
|
137
120
|
}));
|
|
138
121
|
}
|
|
139
|
-
|
|
140
122
|
if (headerStyle !== undefined) {
|
|
141
123
|
headerOptions.backgroundColor = headerStyle.backgroundColor;
|
|
142
124
|
headerOptions.blurEffect = headerStyle.blurEffect;
|
|
143
125
|
}
|
|
144
|
-
|
|
145
126
|
const children = [];
|
|
146
|
-
|
|
147
127
|
if (options.backButtonImage) {
|
|
148
128
|
children.push( /*#__PURE__*/_react.default.createElement(_reactNativeScreens.ScreenStackHeaderBackButtonImage, {
|
|
149
129
|
key: "backImage",
|
|
150
130
|
source: options.backButtonImage
|
|
151
131
|
}));
|
|
152
132
|
}
|
|
153
|
-
|
|
154
133
|
if (_reactNative.Platform.OS === 'ios' && options.searchBar) {
|
|
155
134
|
children.push( /*#__PURE__*/_react.default.createElement(_reactNativeScreens.ScreenStackHeaderSearchBarView, null, /*#__PURE__*/_react.default.createElement(_reactNativeScreens.SearchBar, options.searchBar)));
|
|
156
135
|
}
|
|
157
|
-
|
|
158
136
|
if (options.headerLeft !== undefined) {
|
|
159
137
|
children.push( /*#__PURE__*/_react.default.createElement(_reactNativeScreens.ScreenStackHeaderLeftView, {
|
|
160
138
|
key: "left"
|
|
@@ -168,7 +146,6 @@ function renderHeaderConfig(index, route, descriptor, navigationConfig) {
|
|
|
168
146
|
descriptor.navigation.goBack(descriptor.key);
|
|
169
147
|
});
|
|
170
148
|
};
|
|
171
|
-
|
|
172
149
|
children.push( /*#__PURE__*/_react.default.createElement(_reactNativeScreens.ScreenStackHeaderLeftView, {
|
|
173
150
|
key: "left"
|
|
174
151
|
}, /*#__PURE__*/_react.default.createElement(_reactNavigationStack.HeaderBackButton, {
|
|
@@ -180,7 +157,8 @@ function renderHeaderConfig(index, route, descriptor, navigationConfig) {
|
|
|
180
157
|
truncatedLabel: options.truncatedBackButtonTitle,
|
|
181
158
|
labelVisible: options.backTitleVisible,
|
|
182
159
|
labelStyle: options.headerBackTitleStyle,
|
|
183
|
-
titleLayout: options.layoutPreset
|
|
160
|
+
titleLayout: options.layoutPreset
|
|
161
|
+
// @ts-ignore old props kept for very old version of `react-navigation-stack`
|
|
184
162
|
,
|
|
185
163
|
title: options.backButtonTitle,
|
|
186
164
|
truncatedTitle: options.truncatedBackButtonTitle,
|
|
@@ -190,7 +168,6 @@ function renderHeaderConfig(index, route, descriptor, navigationConfig) {
|
|
|
190
168
|
scene: scene
|
|
191
169
|
})));
|
|
192
170
|
}
|
|
193
|
-
|
|
194
171
|
if (options.headerTitle) {
|
|
195
172
|
if (title === undefined && typeof options.headerTitle === 'string') {
|
|
196
173
|
headerOptions.title = options.headerTitle;
|
|
@@ -202,7 +179,6 @@ function renderHeaderConfig(index, route, descriptor, navigationConfig) {
|
|
|
202
179
|
})));
|
|
203
180
|
}
|
|
204
181
|
}
|
|
205
|
-
|
|
206
182
|
if (options.headerRight) {
|
|
207
183
|
children.push( /*#__PURE__*/_react.default.createElement(_reactNativeScreens.ScreenStackHeaderRightView, {
|
|
208
184
|
key: "right"
|
|
@@ -210,26 +186,23 @@ function renderHeaderConfig(index, route, descriptor, navigationConfig) {
|
|
|
210
186
|
scene
|
|
211
187
|
})));
|
|
212
188
|
}
|
|
213
|
-
|
|
214
189
|
if (children.length > 0) {
|
|
215
190
|
headerOptions.children = children;
|
|
216
191
|
}
|
|
217
|
-
|
|
218
192
|
return /*#__PURE__*/_react.default.createElement(_reactNativeScreens.ScreenStackHeaderConfig, headerOptions);
|
|
219
193
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
194
|
+
const MaybeNestedStack = _ref => {
|
|
195
|
+
let {
|
|
196
|
+
isHeaderInModal,
|
|
197
|
+
screenProps,
|
|
198
|
+
route,
|
|
199
|
+
navigation,
|
|
200
|
+
SceneComponent,
|
|
201
|
+
index,
|
|
202
|
+
descriptor,
|
|
203
|
+
navigationConfig
|
|
204
|
+
} = _ref;
|
|
231
205
|
const Screen = _react.default.useContext(_reactNativeScreens.ScreenContext);
|
|
232
|
-
|
|
233
206
|
if (isHeaderInModal) {
|
|
234
207
|
return /*#__PURE__*/_react.default.createElement(_reactNativeScreens.ScreenStack, {
|
|
235
208
|
style: styles.scenes
|
|
@@ -243,26 +216,23 @@ const MaybeNestedStack = ({
|
|
|
243
216
|
component: SceneComponent
|
|
244
217
|
})));
|
|
245
218
|
}
|
|
246
|
-
|
|
247
219
|
return /*#__PURE__*/_react.default.createElement(_reactNavigation.SceneView, {
|
|
248
220
|
screenProps: screenProps,
|
|
249
221
|
navigation: navigation,
|
|
250
222
|
component: SceneComponent
|
|
251
223
|
});
|
|
252
224
|
};
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
225
|
+
function StackView(_ref2) {
|
|
226
|
+
let {
|
|
227
|
+
navigation,
|
|
228
|
+
descriptors,
|
|
229
|
+
navigationConfig,
|
|
230
|
+
screenProps
|
|
231
|
+
} = _ref2;
|
|
260
232
|
const {
|
|
261
233
|
routes
|
|
262
234
|
} = navigation.state;
|
|
263
|
-
|
|
264
235
|
const Screen = _react.default.useContext(_reactNativeScreens.ScreenContext);
|
|
265
|
-
|
|
266
236
|
return /*#__PURE__*/_react.default.createElement(_reactNativeScreens.ScreenStack, {
|
|
267
237
|
style: styles.scenes,
|
|
268
238
|
onFinishTransitioning: () => onFinishTransitioning(navigation)
|
|
@@ -279,33 +249,26 @@ function StackView({
|
|
|
279
249
|
} = navigationConfig;
|
|
280
250
|
const SceneComponent = getComponent();
|
|
281
251
|
let stackPresentation = 'push';
|
|
282
|
-
|
|
283
252
|
if (options.stackPresentation) {
|
|
284
253
|
stackPresentation = options.stackPresentation;
|
|
285
254
|
} else {
|
|
286
255
|
// this shouldn't be used because we have a prop for that
|
|
287
256
|
if (mode === 'modal' || mode === 'containedModal') {
|
|
288
257
|
stackPresentation = mode;
|
|
289
|
-
|
|
290
258
|
if (transparentCard || options.cardTransparent) {
|
|
291
259
|
stackPresentation = mode === 'containedModal' ? 'containedTransparentModal' : 'transparentModal';
|
|
292
260
|
}
|
|
293
261
|
}
|
|
294
262
|
}
|
|
295
|
-
|
|
296
263
|
let stackAnimation = options.stackAnimation;
|
|
297
|
-
|
|
298
264
|
if (options.animationEnabled === false) {
|
|
299
265
|
stackAnimation = 'none';
|
|
300
266
|
}
|
|
301
|
-
|
|
302
267
|
const hasHeader = options.headerShown !== false && (navigationConfig === null || navigationConfig === void 0 ? void 0 : navigationConfig.headerMode) !== 'none' && options.header !== null;
|
|
303
|
-
|
|
304
268
|
if (!didWarn && stackPresentation !== 'push' && options.headerShown !== undefined) {
|
|
305
269
|
didWarn = true;
|
|
306
270
|
console.warn('Be aware that changing the visibility of header in modal on iOS will result in resetting the state of the screen.');
|
|
307
271
|
}
|
|
308
|
-
|
|
309
272
|
const isHeaderInModal = isAndroid ? false : stackPresentation !== 'push' && hasHeader && options.headerShown === true;
|
|
310
273
|
const isHeaderInPush = isAndroid ? hasHeader : stackPresentation === 'push' && hasHeader;
|
|
311
274
|
return /*#__PURE__*/_react.default.createElement(Screen, {
|
|
@@ -330,17 +293,14 @@ function StackView({
|
|
|
330
293
|
onAppear: () => onAppear(route, descriptor, routeNavigationProp),
|
|
331
294
|
onWillAppear: () => {
|
|
332
295
|
var _options$onWillAppear;
|
|
333
|
-
|
|
334
296
|
return options === null || options === void 0 ? void 0 : (_options$onWillAppear = options.onWillAppear) === null || _options$onWillAppear === void 0 ? void 0 : _options$onWillAppear.call(options);
|
|
335
297
|
},
|
|
336
298
|
onWillDisappear: () => {
|
|
337
299
|
var _options$onWillDisapp;
|
|
338
|
-
|
|
339
300
|
return options === null || options === void 0 ? void 0 : (_options$onWillDisapp = options.onWillDisappear) === null || _options$onWillDisapp === void 0 ? void 0 : _options$onWillDisapp.call(options);
|
|
340
301
|
},
|
|
341
302
|
onDisappear: () => {
|
|
342
303
|
var _options$onDisappear;
|
|
343
|
-
|
|
344
304
|
return options === null || options === void 0 ? void 0 : (_options$onDisappear = options.onDisappear) === null || _options$onDisappear === void 0 ? void 0 : _options$onDisappear.call(options);
|
|
345
305
|
},
|
|
346
306
|
onHeaderBackButtonClicked: () => removeScene(route, 1, routeNavigationProp),
|
|
@@ -357,24 +317,23 @@ function StackView({
|
|
|
357
317
|
}));
|
|
358
318
|
}));
|
|
359
319
|
}
|
|
360
|
-
|
|
361
320
|
const styles = _reactNative.StyleSheet.create({
|
|
362
321
|
scenes: {
|
|
363
322
|
flex: 1
|
|
364
323
|
}
|
|
365
324
|
});
|
|
325
|
+
function createStackNavigator(routeConfigMap) {
|
|
326
|
+
let stackConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
327
|
+
const router = (0, _reactNavigation.StackRouter)(routeConfigMap, stackConfig);
|
|
366
328
|
|
|
367
|
-
|
|
368
|
-
const router = (0, _reactNavigation.StackRouter)(routeConfigMap, stackConfig); // below we override getStateForAction method in order to add handling for
|
|
329
|
+
// below we override getStateForAction method in order to add handling for
|
|
369
330
|
// a custom native stack navigation action. The action REMOVE that we want to
|
|
370
331
|
// add works in a similar way to POP, but it does not remove all the routes
|
|
371
332
|
// that sit on top of the removed route. For example if we have three routes
|
|
372
333
|
// [a,b,c] and call POP on b, then both b and c will go away. In case we
|
|
373
334
|
// call REMOVE on b, only b will be removed from the stack and the resulting
|
|
374
335
|
// state will be [a, c]
|
|
375
|
-
|
|
376
336
|
const superGetStateForAction = router.getStateForAction;
|
|
377
|
-
|
|
378
337
|
router.getStateForAction = (action, state) => {
|
|
379
338
|
if (action.type === REMOVE_ACTION) {
|
|
380
339
|
const {
|
|
@@ -383,15 +342,12 @@ function createStackNavigator(routeConfigMap, stackConfig = {}) {
|
|
|
383
342
|
dismissCount
|
|
384
343
|
} = action;
|
|
385
344
|
let backRouteIndex = state.index;
|
|
386
|
-
|
|
387
345
|
if (key) {
|
|
388
346
|
const backRoute = state.routes.find(route => route.key === key);
|
|
389
347
|
backRouteIndex = state.routes.indexOf(backRoute);
|
|
390
348
|
}
|
|
391
|
-
|
|
392
349
|
if (backRouteIndex > 0) {
|
|
393
350
|
const newRoutes = [...state.routes];
|
|
394
|
-
|
|
395
351
|
if (dismissCount > 1) {
|
|
396
352
|
// when dismissing with iOS 14 native header back button, we can pop more than 1 screen at a time
|
|
397
353
|
// and the `backRouteIndex` is the index of the previous screen. Since we are starting already
|
|
@@ -400,22 +356,19 @@ function createStackNavigator(routeConfigMap, stackConfig = {}) {
|
|
|
400
356
|
} else {
|
|
401
357
|
newRoutes.splice(backRouteIndex, 1);
|
|
402
358
|
}
|
|
403
|
-
|
|
404
|
-
|
|
359
|
+
return {
|
|
360
|
+
...state,
|
|
405
361
|
routes: newRoutes,
|
|
406
362
|
index: newRoutes.length - 1,
|
|
407
363
|
isTransitioning: immediate !== true
|
|
408
364
|
};
|
|
409
365
|
}
|
|
410
366
|
}
|
|
411
|
-
|
|
412
367
|
return superGetStateForAction(action, state);
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
|
|
368
|
+
};
|
|
369
|
+
// Create a navigator with StackView as the view
|
|
416
370
|
return (0, _reactNavigation.createNavigator)(StackView, router, stackConfig);
|
|
417
371
|
}
|
|
418
|
-
|
|
419
372
|
var _default = createStackNavigator;
|
|
420
373
|
exports.default = _default;
|
|
421
374
|
//# sourceMappingURL=createNativeStackNavigator.js.map
|