react-native-screens 3.28.0 → 3.30.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 +7 -7
- package/RNScreens.podspec +3 -3
- package/android/CMakeLists.txt +27 -0
- package/android/build.gradle +21 -2
- package/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +17 -14
- package/android/src/main/cpp/jni-adapter.cpp +110 -0
- package/android/src/main/java/com/swmansion/rnscreens/CustomSearchView.kt +13 -8
- package/android/src/main/java/com/swmansion/rnscreens/FragmentBackPressOverrider.kt +8 -8
- package/android/src/main/java/com/swmansion/rnscreens/ModalScreenViewManager.kt +12 -0
- package/android/src/main/java/com/swmansion/rnscreens/RNScreensPackage.kt +38 -5
- package/android/src/main/java/com/swmansion/rnscreens/Screen.kt +32 -42
- package/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt +76 -48
- package/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt +38 -35
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +43 -37
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt +23 -23
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt +73 -71
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt +3 -3
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubview.kt +5 -5
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubviewManager.kt +3 -3
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackViewManager.kt +3 -3
- package/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +4 -4
- package/android/src/main/java/com/swmansion/rnscreens/ScreenWindowTraits.kt +13 -16
- package/android/src/main/java/com/swmansion/rnscreens/ScreensModule.kt +105 -0
- package/android/src/main/java/com/swmansion/rnscreens/ScreensShadowNode.kt +2 -2
- package/android/src/main/java/com/swmansion/rnscreens/SearchBarManager.kt +1 -0
- package/android/src/main/java/com/swmansion/rnscreens/SearchBarView.kt +14 -10
- package/android/src/main/java/com/swmansion/rnscreens/SearchViewFormatter.kt +8 -8
- package/android/src/main/java/com/swmansion/rnscreens/events/HeaderAttachedEvent.kt +3 -7
- package/android/src/main/java/com/swmansion/rnscreens/events/HeaderBackButtonClickedEvent.kt +4 -8
- package/android/src/main/java/com/swmansion/rnscreens/events/HeaderDetachedEvent.kt +3 -7
- package/android/src/main/java/com/swmansion/rnscreens/events/HeaderHeightChangeEvent.kt +3 -3
- package/android/src/main/java/com/swmansion/rnscreens/events/ScreenTransitionProgressEvent.kt +9 -13
- package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarBlurEvent.kt +3 -7
- package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarChangeTextEvent.kt +3 -7
- package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarCloseEvent.kt +3 -7
- package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarFocusEvent.kt +3 -7
- package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarOpenEvent.kt +3 -7
- package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarSearchButtonPressEvent.kt +3 -7
- package/android/src/main/jni/rnscreens.h +1 -0
- package/android/src/main/res/v33/anim-v33/rns_default_enter_in.xml +0 -1
- package/android/src/main/res/v33/anim-v33/rns_default_enter_out.xml +2 -2
- package/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +1 -1
- package/android/src/paper/java/com/swmansion/rnscreens/NativeScreensModuleSpec.java +32 -0
- package/common/cpp/react/renderer/components/rnscreens/RNSModalScreenComponentDescriptor.h +41 -0
- package/common/cpp/react/renderer/components/rnscreens/RNSModalScreenShadowNode.cpp +15 -0
- package/common/cpp/react/renderer/components/rnscreens/RNSModalScreenShadowNode.h +31 -0
- package/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp +6 -0
- package/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.h +1 -5
- package/common/cpp/react/renderer/components/rnscreens/RNSScreenState.cpp +1 -1
- package/common/cpp/react/renderer/components/rnscreens/RNSScreenState.h +8 -3
- package/cpp/RNScreensTurboModule.cpp +107 -0
- package/cpp/RNScreensTurboModule.h +43 -0
- package/gesture-handler/package.json +6 -0
- package/ios/RNSConvert.h +2 -0
- package/ios/RNSConvert.mm +5 -2
- package/ios/RNSEnums.h +1 -0
- package/ios/RNSModalScreen.h +8 -0
- package/ios/RNSModalScreen.mm +36 -0
- package/ios/RNSModule.h +19 -0
- package/ios/RNSModule.mm +174 -0
- package/ios/RNSScreen.h +4 -1
- package/ios/RNSScreen.mm +48 -26
- package/ios/RNSScreenStack.h +6 -0
- package/ios/RNSScreenStack.mm +150 -23
- package/ios/RNSScreenStackAnimator.mm +89 -1
- package/ios/RNSScreenStackHeaderConfig.mm +7 -1
- package/ios/RNSScreenWindowTraits.h +1 -1
- package/ios/RNSScreenWindowTraits.mm +24 -50
- package/ios/RNSSearchBar.mm +24 -0
- package/ios/utils/RNSUIBarButtonItem.h +2 -0
- package/lib/commonjs/TransitionProgressContext.js +3 -4
- package/lib/commonjs/TransitionProgressContext.js.map +1 -1
- package/lib/commonjs/components/FullWindowOverlay.js +28 -0
- package/lib/commonjs/components/FullWindowOverlay.js.map +1 -0
- package/lib/commonjs/components/FullWindowOverlay.web.js +9 -0
- package/lib/commonjs/components/FullWindowOverlay.web.js.map +1 -0
- package/lib/commonjs/components/Screen.js +161 -0
- package/lib/commonjs/components/Screen.js.map +1 -0
- package/lib/commonjs/components/Screen.web.js +46 -0
- package/lib/commonjs/components/Screen.web.js.map +1 -0
- package/lib/commonjs/components/ScreenContainer.js +33 -0
- package/lib/commonjs/components/ScreenContainer.js.map +1 -0
- package/lib/commonjs/components/ScreenContainer.web.js +11 -0
- package/lib/commonjs/components/ScreenContainer.web.js.map +1 -0
- package/lib/commonjs/components/ScreenStack.js +45 -0
- package/lib/commonjs/components/ScreenStack.js.map +1 -0
- package/lib/commonjs/components/ScreenStack.web.js +9 -0
- package/lib/commonjs/components/ScreenStack.web.js.map +1 -0
- package/lib/commonjs/components/ScreenStackHeaderConfig.js +53 -0
- package/lib/commonjs/components/ScreenStackHeaderConfig.js.map +1 -0
- package/lib/commonjs/components/ScreenStackHeaderConfig.web.js +27 -0
- package/lib/commonjs/components/ScreenStackHeaderConfig.web.js.map +1 -0
- package/lib/commonjs/components/SearchBar.js +59 -0
- package/lib/commonjs/components/SearchBar.js.map +1 -0
- package/lib/commonjs/components/SearchBar.web.js +11 -0
- package/lib/commonjs/components/SearchBar.web.js.map +1 -0
- package/lib/commonjs/components/helpers/DelayedFreeze.js +32 -0
- package/lib/commonjs/components/helpers/DelayedFreeze.js.map +1 -0
- package/lib/commonjs/core.js +41 -0
- package/lib/commonjs/core.js.map +1 -0
- package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js +1 -2
- package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ModalScreenNativeComponent.js +13 -0
- package/lib/commonjs/fabric/ModalScreenNativeComponent.js.map +1 -0
- package/lib/commonjs/fabric/NativeScreensModule.js +10 -0
- package/lib/commonjs/fabric/NativeScreensModule.js.map +1 -0
- package/lib/commonjs/fabric/NativeScreensModule.web.js +8 -0
- package/lib/commonjs/fabric/NativeScreensModule.web.js.map +1 -0
- package/lib/commonjs/fabric/ScreenContainerNativeComponent.js +1 -2
- package/lib/commonjs/fabric/ScreenContainerNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenNativeComponent.js +1 -2
- package/lib/commonjs/fabric/ScreenNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js +1 -2
- package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js +1 -2
- package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenStackHeaderSubviewNativeComponent.js +1 -2
- package/lib/commonjs/fabric/ScreenStackHeaderSubviewNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenStackNativeComponent.js +1 -2
- package/lib/commonjs/fabric/ScreenStackNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/SearchBarNativeComponent.js +3 -5
- package/lib/commonjs/fabric/SearchBarNativeComponent.js.map +1 -1
- package/lib/commonjs/gesture-handler/GestureDetectorProvider.js +19 -0
- package/lib/commonjs/gesture-handler/GestureDetectorProvider.js.map +1 -0
- package/lib/commonjs/gesture-handler/RNScreensTurboModule.js +8 -0
- package/lib/commonjs/gesture-handler/RNScreensTurboModule.js.map +1 -0
- package/lib/commonjs/gesture-handler/ScreenGestureDetector.js +202 -0
- package/lib/commonjs/gesture-handler/ScreenGestureDetector.js.map +1 -0
- package/lib/commonjs/gesture-handler/constraints.js +64 -0
- package/lib/commonjs/gesture-handler/constraints.js.map +1 -0
- package/lib/commonjs/gesture-handler/defaults.js +38 -0
- package/lib/commonjs/gesture-handler/defaults.js.map +1 -0
- package/lib/commonjs/gesture-handler/fabricUtils.js +30 -0
- package/lib/commonjs/gesture-handler/fabricUtils.js.map +1 -0
- package/lib/commonjs/gesture-handler/fabricUtils.web.js +17 -0
- package/lib/commonjs/gesture-handler/fabricUtils.web.js.map +1 -0
- package/lib/commonjs/gesture-handler/index.js +14 -0
- package/lib/commonjs/gesture-handler/index.js.map +1 -0
- package/lib/commonjs/index.js +183 -100
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-stack/contexts/GHContext.js +11 -0
- package/lib/commonjs/native-stack/contexts/GHContext.js.map +1 -0
- package/lib/commonjs/native-stack/index.js.map +1 -1
- package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js +20 -24
- package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/commonjs/native-stack/types.js.map +1 -1
- package/lib/commonjs/native-stack/utils/AnimatedHeaderHeightContext.js +3 -4
- package/lib/commonjs/native-stack/utils/AnimatedHeaderHeightContext.js.map +1 -1
- package/lib/commonjs/native-stack/utils/HeaderHeightContext.js +3 -4
- package/lib/commonjs/native-stack/utils/HeaderHeightContext.js.map +1 -1
- package/lib/commonjs/native-stack/utils/SafeAreaProviderCompat.js +2 -2
- package/lib/commonjs/native-stack/utils/SafeAreaProviderCompat.js.map +1 -1
- package/lib/commonjs/native-stack/utils/getDefaultHeaderHeight.js.map +1 -1
- package/lib/commonjs/native-stack/utils/getStatusBarHeight.js.map +1 -1
- package/lib/commonjs/native-stack/utils/useAnimatedHeaderHeight.js +2 -2
- package/lib/commonjs/native-stack/utils/useAnimatedHeaderHeight.js.map +1 -1
- package/lib/commonjs/native-stack/utils/useBackPressSubscription.js +2 -4
- package/lib/commonjs/native-stack/utils/useBackPressSubscription.js.map +1 -1
- package/lib/commonjs/native-stack/utils/useHeaderHeight.js +2 -2
- package/lib/commonjs/native-stack/utils/useHeaderHeight.js.map +1 -1
- package/lib/commonjs/native-stack/views/FontProcessor.js +1 -2
- package/lib/commonjs/native-stack/views/FontProcessor.js.map +1 -1
- package/lib/commonjs/native-stack/views/HeaderConfig.js +11 -7
- package/lib/commonjs/native-stack/views/HeaderConfig.js.map +1 -1
- package/lib/commonjs/native-stack/views/NativeStackView.js +50 -15
- package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedHeaderHeightContext.js +3 -4
- package/lib/commonjs/reanimated/ReanimatedHeaderHeightContext.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js +6 -9
- package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedScreen.js +1 -2
- package/lib/commonjs/reanimated/ReanimatedScreen.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedScreenProvider.js +6 -14
- package/lib/commonjs/reanimated/ReanimatedScreenProvider.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedTransitionProgressContext.js +3 -4
- package/lib/commonjs/reanimated/ReanimatedTransitionProgressContext.js.map +1 -1
- package/lib/commonjs/reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated/useReanimatedHeaderHeight.js +2 -2
- package/lib/commonjs/reanimated/useReanimatedHeaderHeight.js.map +1 -1
- package/lib/commonjs/reanimated/useReanimatedTransitionProgress.js +2 -2
- package/lib/commonjs/reanimated/useReanimatedTransitionProgress.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/useTransitionProgress.js +2 -2
- package/lib/commonjs/useTransitionProgress.js.map +1 -1
- package/lib/commonjs/utils.js +2 -4
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/TransitionProgressContext.js.map +1 -1
- package/lib/module/components/FullWindowOverlay.js +21 -0
- package/lib/module/components/FullWindowOverlay.js.map +1 -0
- package/lib/module/components/FullWindowOverlay.web.js +3 -0
- package/lib/module/components/FullWindowOverlay.web.js.map +1 -0
- package/lib/module/components/Screen.js +156 -0
- package/lib/module/components/Screen.js.map +1 -0
- package/lib/module/components/Screen.web.js +38 -0
- package/lib/module/components/Screen.web.js.map +1 -0
- package/lib/module/components/ScreenContainer.js +26 -0
- package/lib/module/components/ScreenContainer.js.map +1 -0
- package/lib/module/components/ScreenContainer.web.js +5 -0
- package/lib/module/components/ScreenContainer.web.js.map +1 -0
- package/lib/module/components/ScreenStack.js +40 -0
- package/lib/module/components/ScreenStack.js.map +1 -0
- package/lib/module/components/ScreenStack.web.js +3 -0
- package/lib/module/components/ScreenStack.web.js.map +1 -0
- package/lib/module/components/ScreenStackHeaderConfig.js +43 -0
- package/lib/module/components/ScreenStackHeaderConfig.js.map +1 -0
- package/lib/module/components/ScreenStackHeaderConfig.web.js +14 -0
- package/lib/module/components/ScreenStackHeaderConfig.web.js.map +1 -0
- package/lib/module/components/SearchBar.js +52 -0
- package/lib/module/components/SearchBar.js.map +1 -0
- package/lib/module/components/SearchBar.web.js +5 -0
- package/lib/module/components/SearchBar.web.js.map +1 -0
- package/lib/module/components/helpers/DelayedFreeze.js +25 -0
- package/lib/module/components/helpers/DelayedFreeze.js.map +1 -0
- package/lib/module/core.js +31 -0
- package/lib/module/core.js.map +1 -0
- package/lib/module/fabric/FullWindowOverlayNativeComponent.js.map +1 -1
- package/lib/module/fabric/ModalScreenNativeComponent.js +8 -0
- package/lib/module/fabric/ModalScreenNativeComponent.js.map +1 -0
- package/lib/module/fabric/NativeScreensModule.js +5 -0
- package/lib/module/fabric/NativeScreensModule.js.map +1 -0
- package/lib/module/fabric/NativeScreensModule.web.js +2 -0
- package/lib/module/fabric/NativeScreensModule.web.js.map +1 -0
- package/lib/module/fabric/ScreenContainerNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenStackHeaderSubviewNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenStackNativeComponent.js.map +1 -1
- package/lib/module/fabric/SearchBarNativeComponent.js +1 -1
- package/lib/module/fabric/SearchBarNativeComponent.js.map +1 -1
- package/lib/module/gesture-handler/GestureDetectorProvider.js +12 -0
- package/lib/module/gesture-handler/GestureDetectorProvider.js.map +1 -0
- package/lib/module/gesture-handler/RNScreensTurboModule.js +2 -0
- package/lib/module/gesture-handler/RNScreensTurboModule.js.map +1 -0
- package/lib/module/gesture-handler/ScreenGestureDetector.js +194 -0
- package/lib/module/gesture-handler/ScreenGestureDetector.js.map +1 -0
- package/lib/module/gesture-handler/constraints.js +56 -0
- package/lib/module/gesture-handler/constraints.js.map +1 -0
- package/lib/module/gesture-handler/defaults.js +32 -0
- package/lib/module/gesture-handler/defaults.js.map +1 -0
- package/lib/module/gesture-handler/fabricUtils.js +23 -0
- package/lib/module/gesture-handler/fabricUtils.js.map +1 -0
- package/lib/module/gesture-handler/fabricUtils.web.js +10 -0
- package/lib/module/gesture-handler/fabricUtils.web.js.map +1 -0
- package/lib/module/gesture-handler/index.js +5 -0
- package/lib/module/gesture-handler/index.js.map +1 -0
- package/lib/module/index.js +31 -64
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-stack/contexts/GHContext.js +4 -0
- package/lib/module/native-stack/contexts/GHContext.js.map +1 -0
- package/lib/module/native-stack/index.js.map +1 -1
- package/lib/module/native-stack/navigators/createNativeStackNavigator.js +17 -20
- package/lib/module/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/module/native-stack/types.js.map +1 -1
- package/lib/module/native-stack/utils/AnimatedHeaderHeightContext.js.map +1 -1
- package/lib/module/native-stack/utils/HeaderHeightContext.js.map +1 -1
- package/lib/module/native-stack/utils/SafeAreaProviderCompat.js.map +1 -1
- package/lib/module/native-stack/utils/getDefaultHeaderHeight.js.map +1 -1
- package/lib/module/native-stack/utils/getStatusBarHeight.js.map +1 -1
- package/lib/module/native-stack/utils/useAnimatedHeaderHeight.js.map +1 -1
- package/lib/module/native-stack/utils/useBackPressSubscription.js +2 -4
- package/lib/module/native-stack/utils/useBackPressSubscription.js.map +1 -1
- package/lib/module/native-stack/utils/useHeaderHeight.js.map +1 -1
- package/lib/module/native-stack/views/FontProcessor.js +1 -2
- package/lib/module/native-stack/views/FontProcessor.js.map +1 -1
- package/lib/module/native-stack/views/HeaderConfig.js +8 -5
- package/lib/module/native-stack/views/HeaderConfig.js.map +1 -1
- package/lib/module/native-stack/views/NativeStackView.js +49 -14
- package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/module/reanimated/ReanimatedHeaderHeightContext.js.map +1 -1
- package/lib/module/reanimated/ReanimatedNativeStackScreen.js +2 -4
- package/lib/module/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
- package/lib/module/reanimated/ReanimatedScreen.js.map +1 -1
- package/lib/module/reanimated/ReanimatedScreenProvider.js +6 -14
- package/lib/module/reanimated/ReanimatedScreenProvider.js.map +1 -1
- package/lib/module/reanimated/ReanimatedTransitionProgressContext.js.map +1 -1
- package/lib/module/reanimated/index.js.map +1 -1
- package/lib/module/reanimated/useReanimatedHeaderHeight.js.map +1 -1
- package/lib/module/reanimated/useReanimatedTransitionProgress.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/useTransitionProgress.js.map +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/TransitionProgressContext.d.ts +1 -0
- package/lib/typescript/TransitionProgressContext.d.ts.map +1 -0
- package/lib/typescript/components/FullWindowOverlay.d.ts +6 -0
- package/lib/typescript/components/FullWindowOverlay.d.ts.map +1 -0
- package/lib/typescript/components/FullWindowOverlay.web.d.ts +6 -0
- package/lib/typescript/components/FullWindowOverlay.web.d.ts.map +1 -0
- package/lib/typescript/components/Screen.d.ts +20 -0
- package/lib/typescript/components/Screen.d.ts.map +1 -0
- package/lib/typescript/components/Screen.web.d.ts +11 -0
- package/lib/typescript/components/Screen.web.d.ts.map +1 -0
- package/lib/typescript/components/ScreenContainer.d.ts +7 -0
- package/lib/typescript/components/ScreenContainer.d.ts.map +1 -0
- package/lib/typescript/components/ScreenContainer.web.d.ts +5 -0
- package/lib/typescript/components/ScreenContainer.web.d.ts.map +1 -0
- package/lib/typescript/components/ScreenStack.d.ts +5 -0
- package/lib/typescript/components/ScreenStack.d.ts.map +1 -0
- package/lib/typescript/components/ScreenStack.web.d.ts +3 -0
- package/lib/typescript/components/ScreenStack.web.d.ts.map +1 -0
- package/lib/typescript/components/ScreenStackHeaderConfig.d.ts +13 -0
- package/lib/typescript/components/ScreenStackHeaderConfig.d.ts.map +1 -0
- package/lib/typescript/components/ScreenStackHeaderConfig.web.d.ts +13 -0
- package/lib/typescript/components/ScreenStackHeaderConfig.web.d.ts.map +1 -0
- package/lib/typescript/components/SearchBar.d.ts +26 -0
- package/lib/typescript/components/SearchBar.d.ts.map +1 -0
- package/lib/typescript/components/SearchBar.web.d.ts +5 -0
- package/lib/typescript/components/SearchBar.web.d.ts.map +1 -0
- package/lib/typescript/components/helpers/DelayedFreeze.d.ts +8 -0
- package/lib/typescript/components/helpers/DelayedFreeze.d.ts.map +1 -0
- package/lib/typescript/core.d.ts +7 -0
- package/lib/typescript/core.d.ts.map +1 -0
- package/lib/typescript/fabric/FullWindowOverlayNativeComponent.d.ts +1 -0
- package/lib/typescript/fabric/FullWindowOverlayNativeComponent.d.ts.map +1 -0
- package/lib/typescript/fabric/ModalScreenNativeComponent.d.ts +68 -0
- package/lib/typescript/fabric/ModalScreenNativeComponent.d.ts.map +1 -0
- package/lib/typescript/fabric/NativeScreensModule.d.ts +6 -0
- package/lib/typescript/fabric/NativeScreensModule.d.ts.map +1 -0
- package/lib/typescript/fabric/NativeScreensModule.web.d.ts +3 -0
- package/lib/typescript/fabric/NativeScreensModule.web.d.ts.map +1 -0
- package/lib/typescript/fabric/ScreenContainerNativeComponent.d.ts +1 -0
- package/lib/typescript/fabric/ScreenContainerNativeComponent.d.ts.map +1 -0
- package/lib/typescript/fabric/ScreenNativeComponent.d.ts +2 -1
- package/lib/typescript/fabric/ScreenNativeComponent.d.ts.map +1 -0
- package/lib/typescript/fabric/ScreenNavigationContainerNativeComponent.d.ts +1 -0
- package/lib/typescript/fabric/ScreenNavigationContainerNativeComponent.d.ts.map +1 -0
- package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts +1 -0
- package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts.map +1 -0
- package/lib/typescript/fabric/ScreenStackHeaderSubviewNativeComponent.d.ts +1 -0
- package/lib/typescript/fabric/ScreenStackHeaderSubviewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/fabric/ScreenStackNativeComponent.d.ts +1 -0
- package/lib/typescript/fabric/ScreenStackNativeComponent.d.ts.map +1 -0
- package/lib/typescript/fabric/SearchBarNativeComponent.d.ts +3 -1
- package/lib/typescript/fabric/SearchBarNativeComponent.d.ts.map +1 -0
- package/lib/typescript/gesture-handler/GestureDetectorProvider.d.ts +5 -0
- package/lib/typescript/gesture-handler/GestureDetectorProvider.d.ts.map +1 -0
- package/lib/typescript/gesture-handler/RNScreensTurboModule.d.ts +13 -0
- package/lib/typescript/gesture-handler/RNScreensTurboModule.d.ts.map +1 -0
- package/lib/typescript/gesture-handler/ScreenGestureDetector.d.ts +5 -0
- package/lib/typescript/gesture-handler/ScreenGestureDetector.d.ts.map +1 -0
- package/lib/typescript/gesture-handler/constraints.d.ts +6 -0
- package/lib/typescript/gesture-handler/constraints.d.ts.map +1 -0
- package/lib/typescript/gesture-handler/defaults.d.ts +20 -0
- package/lib/typescript/gesture-handler/defaults.d.ts.map +1 -0
- package/lib/typescript/gesture-handler/fabricUtils.d.ts +8 -0
- package/lib/typescript/gesture-handler/fabricUtils.d.ts.map +1 -0
- package/lib/typescript/gesture-handler/fabricUtils.web.d.ts +6 -0
- package/lib/typescript/gesture-handler/fabricUtils.web.d.ts.map +1 -0
- package/lib/typescript/gesture-handler/index.d.ts +2 -0
- package/lib/typescript/gesture-handler/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +11 -31
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/native-stack/contexts/GHContext.d.ts +4 -0
- package/lib/typescript/native-stack/contexts/GHContext.d.ts.map +1 -0
- package/lib/typescript/native-stack/index.d.ts +1 -0
- package/lib/typescript/native-stack/index.d.ts.map +1 -0
- package/lib/typescript/native-stack/navigators/createNativeStackNavigator.d.ts +1 -0
- package/lib/typescript/native-stack/navigators/createNativeStackNavigator.d.ts.map +1 -0
- package/lib/typescript/native-stack/types.d.ts +39 -2
- package/lib/typescript/native-stack/types.d.ts.map +1 -0
- package/lib/typescript/native-stack/utils/AnimatedHeaderHeightContext.d.ts +1 -0
- package/lib/typescript/native-stack/utils/AnimatedHeaderHeightContext.d.ts.map +1 -0
- package/lib/typescript/native-stack/utils/HeaderHeightContext.d.ts +1 -0
- package/lib/typescript/native-stack/utils/HeaderHeightContext.d.ts.map +1 -0
- package/lib/typescript/native-stack/utils/SafeAreaProviderCompat.d.ts +1 -0
- package/lib/typescript/native-stack/utils/SafeAreaProviderCompat.d.ts.map +1 -0
- package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts +1 -0
- package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts.map +1 -0
- package/lib/typescript/native-stack/utils/getStatusBarHeight.d.ts +1 -0
- package/lib/typescript/native-stack/utils/getStatusBarHeight.d.ts.map +1 -0
- package/lib/typescript/native-stack/utils/useAnimatedHeaderHeight.d.ts +1 -0
- package/lib/typescript/native-stack/utils/useAnimatedHeaderHeight.d.ts.map +1 -0
- package/lib/typescript/native-stack/utils/useBackPressSubscription.d.ts +1 -0
- package/lib/typescript/native-stack/utils/useBackPressSubscription.d.ts.map +1 -0
- package/lib/typescript/native-stack/utils/useHeaderHeight.d.ts +1 -0
- package/lib/typescript/native-stack/utils/useHeaderHeight.d.ts.map +1 -0
- package/lib/typescript/native-stack/views/FontProcessor.d.ts +1 -0
- package/lib/typescript/native-stack/views/FontProcessor.d.ts.map +1 -0
- package/lib/typescript/native-stack/views/HeaderConfig.d.ts +1 -0
- package/lib/typescript/native-stack/views/HeaderConfig.d.ts.map +1 -0
- package/lib/typescript/native-stack/views/NativeStackView.d.ts +1 -0
- package/lib/typescript/native-stack/views/NativeStackView.d.ts.map +1 -0
- package/lib/typescript/reanimated/ReanimatedHeaderHeightContext.d.ts +1 -0
- package/lib/typescript/reanimated/ReanimatedHeaderHeightContext.d.ts.map +1 -0
- package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts +2 -2
- package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts.map +1 -0
- package/lib/typescript/reanimated/ReanimatedScreen.d.ts +2 -2
- package/lib/typescript/reanimated/ReanimatedScreen.d.ts.map +1 -0
- package/lib/typescript/reanimated/ReanimatedScreenProvider.d.ts +1 -0
- package/lib/typescript/reanimated/ReanimatedScreenProvider.d.ts.map +1 -0
- package/lib/typescript/reanimated/ReanimatedTransitionProgressContext.d.ts +1 -0
- package/lib/typescript/reanimated/ReanimatedTransitionProgressContext.d.ts.map +1 -0
- package/lib/typescript/reanimated/index.d.ts +1 -0
- package/lib/typescript/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/reanimated/useReanimatedHeaderHeight.d.ts +2 -3
- package/lib/typescript/reanimated/useReanimatedHeaderHeight.d.ts.map +1 -0
- package/lib/typescript/reanimated/useReanimatedTransitionProgress.d.ts +4 -9
- package/lib/typescript/reanimated/useReanimatedTransitionProgress.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +11 -2
- package/lib/typescript/types.d.ts.map +1 -0
- package/lib/typescript/useTransitionProgress.d.ts +1 -0
- package/lib/typescript/useTransitionProgress.d.ts.map +1 -0
- package/lib/typescript/utils.d.ts +1 -0
- package/lib/typescript/utils.d.ts.map +1 -0
- package/native-stack/README.md +2 -1
- package/native-stack/package.json +1 -1
- package/package.json +18 -11
- package/react-native.config.js +2 -1
- package/reanimated/package.json +1 -1
- package/src/components/FullWindowOverlay.tsx +25 -0
- package/src/components/FullWindowOverlay.web.tsx +6 -0
- package/src/components/Screen.tsx +218 -0
- package/src/components/Screen.web.tsx +43 -0
- package/src/components/ScreenContainer.tsx +33 -0
- package/src/components/ScreenContainer.web.tsx +6 -0
- package/src/components/ScreenStack.tsx +41 -0
- package/src/components/ScreenStack.web.tsx +3 -0
- package/src/components/ScreenStackHeaderConfig.tsx +76 -0
- package/src/components/ScreenStackHeaderConfig.web.tsx +39 -0
- package/src/components/SearchBar.tsx +91 -0
- package/src/components/SearchBar.web.tsx +6 -0
- package/src/components/helpers/DelayedFreeze.tsx +27 -0
- package/src/core.ts +43 -0
- package/src/fabric/ModalScreenNativeComponent.ts +104 -0
- package/src/fabric/NativeScreensModule.ts +7 -0
- package/src/fabric/NativeScreensModule.web.ts +1 -0
- package/src/fabric/ScreenNativeComponent.ts +1 -1
- package/src/fabric/SearchBarNativeComponent.ts +2 -0
- package/src/gesture-handler/GestureDetectorProvider.tsx +16 -0
- package/src/gesture-handler/RNScreensTurboModule.ts +13 -0
- package/src/gesture-handler/ScreenGestureDetector.tsx +241 -0
- package/src/gesture-handler/constraints.ts +87 -0
- package/src/gesture-handler/defaults.ts +38 -0
- package/src/gesture-handler/fabricUtils.ts +39 -0
- package/src/gesture-handler/fabricUtils.web.ts +10 -0
- package/src/gesture-handler/index.tsx +4 -0
- package/src/index.tsx +65 -112
- package/src/native-stack/contexts/GHContext.tsx +7 -0
- package/src/native-stack/types.tsx +62 -1
- package/src/native-stack/views/HeaderConfig.tsx +11 -0
- package/src/native-stack/views/NativeStackView.tsx +65 -13
- package/src/types.tsx +13 -1
- package/lib/commonjs/index.native.js +0 -418
- package/lib/commonjs/index.native.js.map +0 -1
- package/lib/module/index.native.js +0 -415
- package/lib/module/index.native.js.map +0 -1
- package/lib/typescript/index.native.d.ts +0 -2
- package/src/index.native.tsx +0 -619
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Animated, View, Platform } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import TransitionProgressContext from '../TransitionProgressContext';
|
|
6
|
+
import DelayedFreeze from './helpers/DelayedFreeze';
|
|
7
|
+
import { ScreenProps } from 'react-native-screens';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
freezeEnabled,
|
|
11
|
+
isNativePlatformSupported,
|
|
12
|
+
screensEnabled,
|
|
13
|
+
} from '../core';
|
|
14
|
+
|
|
15
|
+
// Native components
|
|
16
|
+
import ScreenNativeComponent from '../fabric/ScreenNativeComponent';
|
|
17
|
+
import ModalScreenNativeComponent from '../fabric/ModalScreenNativeComponent';
|
|
18
|
+
|
|
19
|
+
export const NativeScreen: React.ComponentType<ScreenProps> =
|
|
20
|
+
ScreenNativeComponent as any;
|
|
21
|
+
const AnimatedNativeScreen = Animated.createAnimatedComponent(NativeScreen);
|
|
22
|
+
const AnimatedNativeModalScreen = Animated.createAnimatedComponent(
|
|
23
|
+
ModalScreenNativeComponent as React.ComponentType<ScreenProps>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// Incomplete type, all accessible properties available at:
|
|
27
|
+
// react-native/Libraries/Components/View/ReactNativeViewViewConfig.js
|
|
28
|
+
interface ViewConfig extends View {
|
|
29
|
+
viewConfig: {
|
|
30
|
+
validAttributes: {
|
|
31
|
+
style: {
|
|
32
|
+
display: boolean;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
_viewConfig: {
|
|
37
|
+
validAttributes: {
|
|
38
|
+
style: {
|
|
39
|
+
display: boolean;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class InnerScreen extends React.Component<ScreenProps> {
|
|
46
|
+
private ref: React.ElementRef<typeof View> | null = null;
|
|
47
|
+
private closing = new Animated.Value(0);
|
|
48
|
+
private progress = new Animated.Value(0);
|
|
49
|
+
private goingForward = new Animated.Value(0);
|
|
50
|
+
|
|
51
|
+
setNativeProps(props: ScreenProps): void {
|
|
52
|
+
this.ref?.setNativeProps(props);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
setRef = (ref: React.ElementRef<typeof View> | null): void => {
|
|
56
|
+
this.ref = ref;
|
|
57
|
+
this.props.onComponentRef?.(ref);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
render() {
|
|
61
|
+
const {
|
|
62
|
+
enabled = screensEnabled(),
|
|
63
|
+
freezeOnBlur = freezeEnabled(),
|
|
64
|
+
...rest
|
|
65
|
+
} = this.props;
|
|
66
|
+
|
|
67
|
+
// To maintain default behavior of formSheet stack presentation style and to have reasonable
|
|
68
|
+
// defaults for new medium-detent iOS API we need to set defaults here
|
|
69
|
+
const {
|
|
70
|
+
sheetAllowedDetents = 'large',
|
|
71
|
+
sheetLargestUndimmedDetent = 'all',
|
|
72
|
+
sheetGrabberVisible = false,
|
|
73
|
+
sheetCornerRadius = -1.0,
|
|
74
|
+
sheetExpandsWhenScrolledToEdge = true,
|
|
75
|
+
stackPresentation,
|
|
76
|
+
} = rest;
|
|
77
|
+
|
|
78
|
+
if (enabled && isNativePlatformSupported) {
|
|
79
|
+
// Due to how Yoga resolves layout, we need to have different components for modal nad non-modal screens
|
|
80
|
+
const AnimatedScreen =
|
|
81
|
+
Platform.OS === 'android' ||
|
|
82
|
+
stackPresentation === 'push' ||
|
|
83
|
+
stackPresentation === 'containedModal' ||
|
|
84
|
+
stackPresentation === 'containedTransparentModal'
|
|
85
|
+
? AnimatedNativeScreen
|
|
86
|
+
: AnimatedNativeModalScreen;
|
|
87
|
+
|
|
88
|
+
let {
|
|
89
|
+
// Filter out active prop in this case because it is unused and
|
|
90
|
+
// can cause problems depending on react-native version:
|
|
91
|
+
// https://github.com/react-navigation/react-navigation/issues/4886
|
|
92
|
+
active,
|
|
93
|
+
activityState,
|
|
94
|
+
children,
|
|
95
|
+
isNativeStack,
|
|
96
|
+
gestureResponseDistance,
|
|
97
|
+
onGestureCancel,
|
|
98
|
+
...props
|
|
99
|
+
} = rest;
|
|
100
|
+
|
|
101
|
+
if (active !== undefined && activityState === undefined) {
|
|
102
|
+
console.warn(
|
|
103
|
+
'It appears that you are using old version of react-navigation library. Please update @react-navigation/bottom-tabs, @react-navigation/stack and @react-navigation/drawer to version 5.10.0 or above to take full advantage of new functionality added to react-native-screens'
|
|
104
|
+
);
|
|
105
|
+
activityState = active !== 0 ? 2 : 0; // in the new version, we need one of the screens to have value of 2 after the transition
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const handleRef = (ref: ViewConfig) => {
|
|
109
|
+
if (ref?.viewConfig?.validAttributes?.style) {
|
|
110
|
+
ref.viewConfig.validAttributes.style = {
|
|
111
|
+
...ref.viewConfig.validAttributes.style,
|
|
112
|
+
display: false,
|
|
113
|
+
};
|
|
114
|
+
this.setRef(ref);
|
|
115
|
+
} else if (ref?._viewConfig?.validAttributes?.style) {
|
|
116
|
+
ref._viewConfig.validAttributes.style = {
|
|
117
|
+
...ref._viewConfig.validAttributes.style,
|
|
118
|
+
display: false,
|
|
119
|
+
};
|
|
120
|
+
this.setRef(ref);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<DelayedFreeze freeze={freezeOnBlur && activityState === 0}>
|
|
126
|
+
<AnimatedScreen
|
|
127
|
+
{...props}
|
|
128
|
+
activityState={activityState}
|
|
129
|
+
sheetAllowedDetents={sheetAllowedDetents}
|
|
130
|
+
sheetLargestUndimmedDetent={sheetLargestUndimmedDetent}
|
|
131
|
+
sheetGrabberVisible={sheetGrabberVisible}
|
|
132
|
+
sheetCornerRadius={sheetCornerRadius}
|
|
133
|
+
sheetExpandsWhenScrolledToEdge={sheetExpandsWhenScrolledToEdge}
|
|
134
|
+
gestureResponseDistance={{
|
|
135
|
+
start: gestureResponseDistance?.start ?? -1,
|
|
136
|
+
end: gestureResponseDistance?.end ?? -1,
|
|
137
|
+
top: gestureResponseDistance?.top ?? -1,
|
|
138
|
+
bottom: gestureResponseDistance?.bottom ?? -1,
|
|
139
|
+
}}
|
|
140
|
+
// This prevents showing blank screen when navigating between multiple screens with freezing
|
|
141
|
+
// https://github.com/software-mansion/react-native-screens/pull/1208
|
|
142
|
+
ref={handleRef}
|
|
143
|
+
onTransitionProgress={
|
|
144
|
+
!isNativeStack
|
|
145
|
+
? undefined
|
|
146
|
+
: Animated.event(
|
|
147
|
+
[
|
|
148
|
+
{
|
|
149
|
+
nativeEvent: {
|
|
150
|
+
progress: this.progress,
|
|
151
|
+
closing: this.closing,
|
|
152
|
+
goingForward: this.goingForward,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
{ useNativeDriver: true }
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
onGestureCancel={
|
|
160
|
+
onGestureCancel ??
|
|
161
|
+
(() => {
|
|
162
|
+
// for internal use
|
|
163
|
+
})
|
|
164
|
+
}>
|
|
165
|
+
{!isNativeStack ? ( // see comment of this prop in types.tsx for information why it is needed
|
|
166
|
+
children
|
|
167
|
+
) : (
|
|
168
|
+
<TransitionProgressContext.Provider
|
|
169
|
+
value={{
|
|
170
|
+
progress: this.progress,
|
|
171
|
+
closing: this.closing,
|
|
172
|
+
goingForward: this.goingForward,
|
|
173
|
+
}}>
|
|
174
|
+
{children}
|
|
175
|
+
</TransitionProgressContext.Provider>
|
|
176
|
+
)}
|
|
177
|
+
</AnimatedScreen>
|
|
178
|
+
</DelayedFreeze>
|
|
179
|
+
);
|
|
180
|
+
} else {
|
|
181
|
+
// same reason as above
|
|
182
|
+
let {
|
|
183
|
+
active,
|
|
184
|
+
activityState,
|
|
185
|
+
style,
|
|
186
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
187
|
+
onComponentRef,
|
|
188
|
+
...props
|
|
189
|
+
} = rest;
|
|
190
|
+
|
|
191
|
+
if (active !== undefined && activityState === undefined) {
|
|
192
|
+
activityState = active !== 0 ? 2 : 0;
|
|
193
|
+
}
|
|
194
|
+
return (
|
|
195
|
+
<Animated.View
|
|
196
|
+
style={[style, { display: activityState !== 0 ? 'flex' : 'none' }]}
|
|
197
|
+
ref={this.setRef}
|
|
198
|
+
{...props}
|
|
199
|
+
/>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// context to be used when the user wants to use enhanced implementation
|
|
206
|
+
// e.g. to use `useReanimatedTransitionProgress` (see `reanimated` folder in repo)
|
|
207
|
+
export const ScreenContext = React.createContext(InnerScreen);
|
|
208
|
+
|
|
209
|
+
class Screen extends React.Component<ScreenProps> {
|
|
210
|
+
static contextType = ScreenContext;
|
|
211
|
+
|
|
212
|
+
render() {
|
|
213
|
+
const ScreenWrapper = (this.context || InnerScreen) as React.ElementType;
|
|
214
|
+
return <ScreenWrapper {...this.props} />;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export default Screen;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ScreenProps } from 'react-native-screens';
|
|
2
|
+
import { Animated, View } from 'react-native';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { screensEnabled } from '../core';
|
|
6
|
+
|
|
7
|
+
export const InnerScreen = View;
|
|
8
|
+
|
|
9
|
+
// We're using class component here because of the error from reanimated:
|
|
10
|
+
// createAnimatedComponent` does not support stateless functional components; use a class component instead.
|
|
11
|
+
export class NativeScreen extends React.Component<ScreenProps> {
|
|
12
|
+
render(): JSX.Element {
|
|
13
|
+
let {
|
|
14
|
+
active,
|
|
15
|
+
activityState,
|
|
16
|
+
style,
|
|
17
|
+
enabled = screensEnabled(),
|
|
18
|
+
...rest
|
|
19
|
+
} = this.props;
|
|
20
|
+
|
|
21
|
+
if (enabled) {
|
|
22
|
+
if (active !== undefined && activityState === undefined) {
|
|
23
|
+
activityState = active !== 0 ? 2 : 0; // change taken from index.native.tsx
|
|
24
|
+
}
|
|
25
|
+
return (
|
|
26
|
+
<View
|
|
27
|
+
// @ts-expect-error: hidden exists on web, but not in React Native
|
|
28
|
+
hidden={activityState === 0}
|
|
29
|
+
style={[style, { display: activityState !== 0 ? 'flex' : 'none' }]}
|
|
30
|
+
{...rest}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return <View {...rest} />;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const Screen = Animated.createAnimatedComponent(NativeScreen);
|
|
40
|
+
|
|
41
|
+
export const ScreenContext = React.createContext(Screen);
|
|
42
|
+
|
|
43
|
+
export default Screen;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Platform, View } from 'react-native';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ScreenContainerProps } from 'react-native-screens';
|
|
4
|
+
import { isNativePlatformSupported, screensEnabled } from '../core';
|
|
5
|
+
|
|
6
|
+
// Native components
|
|
7
|
+
import ScreenContainerNativeComponent from '../fabric/ScreenContainerNativeComponent';
|
|
8
|
+
import ScreenNavigationContainerNativeComponent from '../fabric/ScreenNavigationContainerNativeComponent';
|
|
9
|
+
|
|
10
|
+
export const NativeScreenContainer: React.ComponentType<ScreenContainerProps> =
|
|
11
|
+
Platform.OS !== 'web' ? (ScreenContainerNativeComponent as any) : View;
|
|
12
|
+
export const NativeScreenNavigationContainer: React.ComponentType<ScreenContainerProps> =
|
|
13
|
+
Platform.OS !== 'web'
|
|
14
|
+
? (ScreenNavigationContainerNativeComponent as any)
|
|
15
|
+
: View;
|
|
16
|
+
|
|
17
|
+
function ScreenContainer(props: ScreenContainerProps) {
|
|
18
|
+
const { enabled = screensEnabled(), hasTwoStates, ...rest } = props;
|
|
19
|
+
|
|
20
|
+
if (enabled && isNativePlatformSupported) {
|
|
21
|
+
if (hasTwoStates) {
|
|
22
|
+
const ScreenNavigationContainer =
|
|
23
|
+
Platform.OS === 'ios'
|
|
24
|
+
? NativeScreenNavigationContainer
|
|
25
|
+
: NativeScreenContainer;
|
|
26
|
+
return <ScreenNavigationContainer {...rest} />;
|
|
27
|
+
}
|
|
28
|
+
return <NativeScreenContainer {...rest} />;
|
|
29
|
+
}
|
|
30
|
+
return <View {...rest} />;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default ScreenContainer;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScreenStackProps, freezeEnabled } from 'react-native-screens';
|
|
3
|
+
import DelayedFreeze from './helpers/DelayedFreeze';
|
|
4
|
+
|
|
5
|
+
// Native components
|
|
6
|
+
import ScreenStackNativeComponent from '../fabric/ScreenStackNativeComponent';
|
|
7
|
+
const NativeScreenStack: React.ComponentType<ScreenStackProps> =
|
|
8
|
+
ScreenStackNativeComponent as any;
|
|
9
|
+
|
|
10
|
+
function ScreenStack(props: ScreenStackProps) {
|
|
11
|
+
const { children, gestureDetectorBridge, ...rest } = props;
|
|
12
|
+
const ref = React.useRef(null);
|
|
13
|
+
const size = React.Children.count(children);
|
|
14
|
+
// freezes all screens except the top one
|
|
15
|
+
const childrenWithFreeze = React.Children.map(children, (child, index) => {
|
|
16
|
+
// @ts-expect-error it's either SceneView in v6 or RouteView in v5
|
|
17
|
+
const { props, key } = child;
|
|
18
|
+
const descriptor = props?.descriptor ?? props?.descriptors?.[key];
|
|
19
|
+
const isFreezeEnabled =
|
|
20
|
+
descriptor?.options?.freezeOnBlur ?? freezeEnabled();
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<DelayedFreeze freeze={isFreezeEnabled && size - index > 1}>
|
|
24
|
+
{child}
|
|
25
|
+
</DelayedFreeze>
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
React.useEffect(() => {
|
|
30
|
+
if (gestureDetectorBridge) {
|
|
31
|
+
gestureDetectorBridge.current.stackUseEffectCallback(ref);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return (
|
|
35
|
+
<NativeScreenStack {...rest} ref={ref}>
|
|
36
|
+
{childrenWithFreeze}
|
|
37
|
+
</NativeScreenStack>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default ScreenStack;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
HeaderSubviewTypes,
|
|
4
|
+
ScreenStackHeaderConfigProps,
|
|
5
|
+
SearchBarProps,
|
|
6
|
+
} from 'react-native-screens';
|
|
7
|
+
import { Image, ImageProps, StyleSheet, ViewProps } from 'react-native';
|
|
8
|
+
|
|
9
|
+
// Native components
|
|
10
|
+
import ScreenStackHeaderConfigNativeComponent from '../fabric/ScreenStackHeaderConfigNativeComponent';
|
|
11
|
+
import ScreenStackHeaderSubviewNativeComponent from '../fabric/ScreenStackHeaderSubviewNativeComponent';
|
|
12
|
+
|
|
13
|
+
export const ScreenStackHeaderConfig: React.ComponentType<ScreenStackHeaderConfigProps> =
|
|
14
|
+
ScreenStackHeaderConfigNativeComponent as any;
|
|
15
|
+
export const ScreenStackHeaderSubview: React.ComponentType<
|
|
16
|
+
React.PropsWithChildren<ViewProps & { type?: HeaderSubviewTypes }>
|
|
17
|
+
> = ScreenStackHeaderSubviewNativeComponent as any;
|
|
18
|
+
|
|
19
|
+
export const ScreenStackHeaderBackButtonImage = (
|
|
20
|
+
props: ImageProps
|
|
21
|
+
): JSX.Element => (
|
|
22
|
+
<ScreenStackHeaderSubview type="back" style={styles.headerSubview}>
|
|
23
|
+
<Image resizeMode="center" fadeDuration={0} {...props} />
|
|
24
|
+
</ScreenStackHeaderSubview>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export const ScreenStackHeaderRightView = (
|
|
28
|
+
props: React.PropsWithChildren<ViewProps>
|
|
29
|
+
): JSX.Element => (
|
|
30
|
+
<ScreenStackHeaderSubview
|
|
31
|
+
{...props}
|
|
32
|
+
type="right"
|
|
33
|
+
style={styles.headerSubview}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export const ScreenStackHeaderLeftView = (
|
|
38
|
+
props: React.PropsWithChildren<ViewProps>
|
|
39
|
+
): JSX.Element => (
|
|
40
|
+
<ScreenStackHeaderSubview
|
|
41
|
+
{...props}
|
|
42
|
+
type="left"
|
|
43
|
+
style={styles.headerSubview}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export const ScreenStackHeaderCenterView = (
|
|
48
|
+
props: React.PropsWithChildren<ViewProps>
|
|
49
|
+
): JSX.Element => (
|
|
50
|
+
<ScreenStackHeaderSubview
|
|
51
|
+
{...props}
|
|
52
|
+
type="center"
|
|
53
|
+
style={styles.headerSubview}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
export const ScreenStackHeaderSearchBarView = (
|
|
58
|
+
props: React.PropsWithChildren<SearchBarProps>
|
|
59
|
+
): JSX.Element => (
|
|
60
|
+
<ScreenStackHeaderSubview
|
|
61
|
+
{...props}
|
|
62
|
+
type="searchBar"
|
|
63
|
+
style={styles.headerSubview}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const styles = StyleSheet.create({
|
|
68
|
+
headerSubview: {
|
|
69
|
+
position: 'absolute',
|
|
70
|
+
top: 0,
|
|
71
|
+
right: 0,
|
|
72
|
+
flexDirection: 'row',
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
justifyContent: 'center',
|
|
75
|
+
},
|
|
76
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Image, ImageProps, View, ViewProps } from 'react-native';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {
|
|
4
|
+
HeaderSubviewTypes,
|
|
5
|
+
ScreenStackHeaderConfigProps,
|
|
6
|
+
SearchBarProps,
|
|
7
|
+
} from 'react-native-screens';
|
|
8
|
+
|
|
9
|
+
export const ScreenStackHeaderBackButtonImage = (
|
|
10
|
+
props: ImageProps
|
|
11
|
+
): JSX.Element => (
|
|
12
|
+
<View>
|
|
13
|
+
<Image resizeMode="center" fadeDuration={0} {...props} />
|
|
14
|
+
</View>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export const ScreenStackHeaderRightView = (
|
|
18
|
+
props: React.PropsWithChildren<ViewProps>
|
|
19
|
+
): JSX.Element => <View {...props} />;
|
|
20
|
+
|
|
21
|
+
export const ScreenStackHeaderLeftView = (
|
|
22
|
+
props: React.PropsWithChildren<ViewProps>
|
|
23
|
+
): JSX.Element => <View {...props} />;
|
|
24
|
+
|
|
25
|
+
export const ScreenStackHeaderCenterView = (
|
|
26
|
+
props: React.PropsWithChildren<ViewProps>
|
|
27
|
+
): JSX.Element => <View {...props} />;
|
|
28
|
+
|
|
29
|
+
export const ScreenStackHeaderSearchBarView = (
|
|
30
|
+
props: React.PropsWithChildren<Omit<SearchBarProps, 'ref'>>
|
|
31
|
+
): JSX.Element => <View {...props} />;
|
|
32
|
+
|
|
33
|
+
export const ScreenStackHeaderConfig = (
|
|
34
|
+
props: React.PropsWithChildren<ScreenStackHeaderConfigProps>
|
|
35
|
+
): JSX.Element => <View {...props} />;
|
|
36
|
+
|
|
37
|
+
export const ScreenStackHeaderSubview: React.ComponentType<
|
|
38
|
+
React.PropsWithChildren<ViewProps & { type?: HeaderSubviewTypes }>
|
|
39
|
+
> = View;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
isSearchBarAvailableForCurrentPlatform,
|
|
4
|
+
SearchBarCommands,
|
|
5
|
+
SearchBarProps,
|
|
6
|
+
} from 'react-native-screens';
|
|
7
|
+
import { View } from 'react-native';
|
|
8
|
+
|
|
9
|
+
// Native components
|
|
10
|
+
import SearchBarNativeComponent, {
|
|
11
|
+
Commands as SearchBarNativeCommands,
|
|
12
|
+
} from '../fabric/SearchBarNativeComponent';
|
|
13
|
+
|
|
14
|
+
export const NativeSearchBar: React.ComponentType<SearchBarProps> &
|
|
15
|
+
typeof NativeSearchBarCommands = SearchBarNativeComponent as any;
|
|
16
|
+
export const NativeSearchBarCommands: SearchBarCommandsType =
|
|
17
|
+
SearchBarNativeCommands as any;
|
|
18
|
+
|
|
19
|
+
type SearchBarCommandsType = {
|
|
20
|
+
blur: (viewRef: React.ElementRef<typeof NativeSearchBar>) => void;
|
|
21
|
+
focus: (viewRef: React.ElementRef<typeof NativeSearchBar>) => void;
|
|
22
|
+
clearText: (viewRef: React.ElementRef<typeof NativeSearchBar>) => void;
|
|
23
|
+
toggleCancelButton: (
|
|
24
|
+
viewRef: React.ElementRef<typeof NativeSearchBar>,
|
|
25
|
+
flag: boolean
|
|
26
|
+
) => void;
|
|
27
|
+
setText: (
|
|
28
|
+
viewRef: React.ElementRef<typeof NativeSearchBar>,
|
|
29
|
+
text: string
|
|
30
|
+
) => void;
|
|
31
|
+
cancelSearch: (viewRef: React.ElementRef<typeof NativeSearchBar>) => void;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
class SearchBar extends React.Component<SearchBarProps> {
|
|
35
|
+
nativeSearchBarRef: React.RefObject<SearchBarCommands>;
|
|
36
|
+
|
|
37
|
+
constructor(props: SearchBarProps) {
|
|
38
|
+
super(props);
|
|
39
|
+
this.nativeSearchBarRef = React.createRef();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
_callMethodWithRef(method: (ref: SearchBarCommands) => void) {
|
|
43
|
+
const ref = this.nativeSearchBarRef.current;
|
|
44
|
+
if (ref) {
|
|
45
|
+
method(ref);
|
|
46
|
+
} else {
|
|
47
|
+
console.warn(
|
|
48
|
+
'Reference to native search bar component has not been updated yet'
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
blur() {
|
|
54
|
+
this._callMethodWithRef(ref => NativeSearchBarCommands.blur(ref));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
focus() {
|
|
58
|
+
this._callMethodWithRef(ref => NativeSearchBarCommands.focus(ref));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
toggleCancelButton(flag: boolean) {
|
|
62
|
+
this._callMethodWithRef(ref =>
|
|
63
|
+
NativeSearchBarCommands.toggleCancelButton(ref, flag)
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
clearText() {
|
|
68
|
+
this._callMethodWithRef(ref => NativeSearchBarCommands.clearText(ref));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
setText(text: string) {
|
|
72
|
+
this._callMethodWithRef(ref => NativeSearchBarCommands.setText(ref, text));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
cancelSearch() {
|
|
76
|
+
this._callMethodWithRef(ref => NativeSearchBarCommands.cancelSearch(ref));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
render() {
|
|
80
|
+
if (!isSearchBarAvailableForCurrentPlatform) {
|
|
81
|
+
console.warn(
|
|
82
|
+
'Importing SearchBar is only valid on iOS and Android devices.'
|
|
83
|
+
);
|
|
84
|
+
return View as any as ReactNode;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return <NativeSearchBar {...this.props} ref={this.nativeSearchBarRef} />;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default SearchBar;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Freeze } from 'react-freeze';
|
|
3
|
+
|
|
4
|
+
interface FreezeWrapperProps {
|
|
5
|
+
freeze: boolean;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// This component allows one more render before freezing the screen.
|
|
10
|
+
// Allows activityState to reach the native side and useIsFocused to work correctly.
|
|
11
|
+
function DelayedFreeze({ freeze, children }: FreezeWrapperProps) {
|
|
12
|
+
// flag used for determining whether freeze should be enabled
|
|
13
|
+
const [freezeState, setFreezeState] = React.useState(false);
|
|
14
|
+
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
const id = setImmediate(() => {
|
|
17
|
+
setFreezeState(freeze);
|
|
18
|
+
});
|
|
19
|
+
return () => {
|
|
20
|
+
clearImmediate(id);
|
|
21
|
+
};
|
|
22
|
+
}, [freeze]);
|
|
23
|
+
|
|
24
|
+
return <Freeze freeze={freeze ? freezeState : false}>{children}</Freeze>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default DelayedFreeze;
|
package/src/core.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Platform, UIManager } from 'react-native';
|
|
2
|
+
|
|
3
|
+
// const that tells if the library should use new implementation, will be undefined for older versions
|
|
4
|
+
export const shouldUseActivityState = true;
|
|
5
|
+
|
|
6
|
+
export const isNativePlatformSupported =
|
|
7
|
+
Platform.OS === 'ios' ||
|
|
8
|
+
Platform.OS === 'android' ||
|
|
9
|
+
Platform.OS === 'windows';
|
|
10
|
+
|
|
11
|
+
let ENABLE_SCREENS = isNativePlatformSupported;
|
|
12
|
+
|
|
13
|
+
export function enableScreens(shouldEnableScreens = true) {
|
|
14
|
+
ENABLE_SCREENS = shouldEnableScreens;
|
|
15
|
+
|
|
16
|
+
if (!isNativePlatformSupported) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (ENABLE_SCREENS && !UIManager.getViewManagerConfig('RNSScreen')) {
|
|
21
|
+
console.error(
|
|
22
|
+
`Screen native module hasn't been linked. Please check the react-native-screens README for more details`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let ENABLE_FREEZE = false;
|
|
28
|
+
|
|
29
|
+
export function enableFreeze(shouldEnableReactFreeze = true) {
|
|
30
|
+
if (!isNativePlatformSupported) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
ENABLE_FREEZE = shouldEnableReactFreeze;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function screensEnabled() {
|
|
38
|
+
return ENABLE_SCREENS;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function freezeEnabled() {
|
|
42
|
+
return ENABLE_FREEZE;
|
|
43
|
+
}
|