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
|
@@ -2,6 +2,7 @@ package com.swmansion.rnscreens
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import android.graphics.Canvas
|
|
5
|
+
import android.os.Build
|
|
5
6
|
import android.view.View
|
|
6
7
|
import com.facebook.react.bridge.ReactContext
|
|
7
8
|
import com.facebook.react.uimanager.UIManagerHelper
|
|
@@ -12,30 +13,33 @@ import kotlin.collections.ArrayList
|
|
|
12
13
|
import kotlin.collections.HashSet
|
|
13
14
|
|
|
14
15
|
class ScreenStack(context: Context?) : ScreenContainer(context) {
|
|
15
|
-
private val
|
|
16
|
-
private val
|
|
16
|
+
private val stack = ArrayList<ScreenStackFragmentWrapper>()
|
|
17
|
+
private val dismissedWrappers: MutableSet<ScreenStackFragmentWrapper> = HashSet()
|
|
17
18
|
private val drawingOpPool: MutableList<DrawingOp> = ArrayList()
|
|
18
19
|
private var drawingOps: MutableList<DrawingOp> = ArrayList()
|
|
19
|
-
private var
|
|
20
|
-
private var
|
|
20
|
+
private var topScreenWrapper: ScreenStackFragmentWrapper? = null
|
|
21
|
+
private var removalTransitionStarted = false
|
|
21
22
|
private var isDetachingCurrentScreen = false
|
|
22
23
|
private var reverseLastTwoChildren = false
|
|
23
24
|
private var previousChildrenCount = 0
|
|
24
25
|
var goingForward = false
|
|
25
26
|
|
|
26
27
|
fun dismiss(screenFragment: ScreenStackFragmentWrapper) {
|
|
27
|
-
|
|
28
|
+
dismissedWrappers.add(screenFragment)
|
|
28
29
|
performUpdatesNow()
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
override val topScreen: Screen?
|
|
32
|
-
get() =
|
|
33
|
+
get() = topScreenWrapper?.screen
|
|
34
|
+
|
|
35
|
+
val fragments: ArrayList<ScreenStackFragmentWrapper>
|
|
36
|
+
get() = stack
|
|
33
37
|
|
|
34
38
|
val rootScreen: Screen
|
|
35
39
|
get() {
|
|
36
40
|
for (i in 0 until screenCount) {
|
|
37
41
|
val screenWrapper = getScreenFragmentWrapperAt(i)
|
|
38
|
-
if (!
|
|
42
|
+
if (!dismissedWrappers.contains(screenWrapper)) {
|
|
39
43
|
return screenWrapper.screen
|
|
40
44
|
}
|
|
41
45
|
}
|
|
@@ -46,19 +50,19 @@ class ScreenStack(context: Context?) : ScreenContainer(context) {
|
|
|
46
50
|
|
|
47
51
|
override fun startViewTransition(view: View) {
|
|
48
52
|
super.startViewTransition(view)
|
|
49
|
-
|
|
53
|
+
removalTransitionStarted = true
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
override fun endViewTransition(view: View) {
|
|
53
57
|
super.endViewTransition(view)
|
|
54
|
-
if (
|
|
55
|
-
|
|
58
|
+
if (removalTransitionStarted) {
|
|
59
|
+
removalTransitionStarted = false
|
|
56
60
|
dispatchOnFinishTransitioning()
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
fun onViewAppearTransitionEnd() {
|
|
61
|
-
if (!
|
|
65
|
+
if (!removalTransitionStarted) {
|
|
62
66
|
dispatchOnFinishTransitioning()
|
|
63
67
|
}
|
|
64
68
|
}
|
|
@@ -71,17 +75,17 @@ class ScreenStack(context: Context?) : ScreenContainer(context) {
|
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
override fun removeScreenAt(index: Int) {
|
|
74
|
-
|
|
78
|
+
dismissedWrappers.remove(getScreenFragmentWrapperAt(index))
|
|
75
79
|
super.removeScreenAt(index)
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
override fun removeAllScreens() {
|
|
79
|
-
|
|
83
|
+
dismissedWrappers.clear()
|
|
80
84
|
super.removeAllScreens()
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
override fun hasScreen(screenFragmentWrapper: ScreenFragmentWrapper?): Boolean =
|
|
84
|
-
super.hasScreen(screenFragmentWrapper) && !
|
|
88
|
+
super.hasScreen(screenFragmentWrapper) && !dismissedWrappers.contains(screenFragmentWrapper)
|
|
85
89
|
|
|
86
90
|
override fun onUpdate() {
|
|
87
91
|
// When going back from a nested stack with a single screen on it, we may hit an edge case
|
|
@@ -90,9 +94,9 @@ class ScreenStack(context: Context?) : ScreenContainer(context) {
|
|
|
90
94
|
var newTop: ScreenFragmentWrapper? = null // newTop is nullable, see the above comment ^
|
|
91
95
|
var visibleBottom: ScreenFragmentWrapper? = null // this is only set if newTop has TRANSPARENT_MODAL presentation mode
|
|
92
96
|
isDetachingCurrentScreen = false // we reset it so the previous value is not used by mistake
|
|
93
|
-
for (i in
|
|
97
|
+
for (i in screenWrappers.indices.reversed()) {
|
|
94
98
|
val screen = getScreenFragmentWrapperAt(i)
|
|
95
|
-
if (!
|
|
99
|
+
if (!dismissedWrappers.contains(screen)) {
|
|
96
100
|
if (newTop == null) {
|
|
97
101
|
newTop = screen
|
|
98
102
|
} else {
|
|
@@ -105,29 +109,29 @@ class ScreenStack(context: Context?) : ScreenContainer(context) {
|
|
|
105
109
|
}
|
|
106
110
|
var shouldUseOpenAnimation = true
|
|
107
111
|
var stackAnimation: StackAnimation? = null
|
|
108
|
-
if (!
|
|
112
|
+
if (!stack.contains(newTop)) {
|
|
109
113
|
// if new top screen wasn't on stack we do "open animation" so long it is not the very first
|
|
110
114
|
// screen on stack
|
|
111
|
-
if (
|
|
115
|
+
if (topScreenWrapper != null && newTop != null) {
|
|
112
116
|
// there was some other screen attached before
|
|
113
117
|
// if the previous top screen does not exist anymore and the new top was not on the stack
|
|
114
118
|
// before, probably replace or reset was called, so we play the "close animation".
|
|
115
119
|
// Otherwise it's open animation
|
|
116
|
-
val containsTopScreen =
|
|
120
|
+
val containsTopScreen = topScreenWrapper?.let { screenWrappers.contains(it) } == true
|
|
117
121
|
val isPushReplace = newTop.screen.replaceAnimation === Screen.ReplaceAnimation.PUSH
|
|
118
122
|
shouldUseOpenAnimation = containsTopScreen || isPushReplace
|
|
119
123
|
// if the replace animation is `push`, the new top screen provides the animation, otherwise the previous one
|
|
120
|
-
stackAnimation = if (shouldUseOpenAnimation) newTop.screen.stackAnimation else
|
|
121
|
-
} else if (
|
|
124
|
+
stackAnimation = if (shouldUseOpenAnimation) newTop.screen.stackAnimation else topScreenWrapper?.screen?.stackAnimation
|
|
125
|
+
} else if (topScreenWrapper == null && newTop != null) {
|
|
122
126
|
// mTopScreen was not present before so newTop is the first screen added to a stack
|
|
123
127
|
// and we don't want the animation when it is entering
|
|
124
128
|
stackAnimation = StackAnimation.NONE
|
|
125
129
|
goingForward = true
|
|
126
130
|
}
|
|
127
|
-
} else if (
|
|
131
|
+
} else if (topScreenWrapper != null && topScreenWrapper != newTop) {
|
|
128
132
|
// otherwise if we are performing top screen change we do "close animation"
|
|
129
133
|
shouldUseOpenAnimation = false
|
|
130
|
-
stackAnimation =
|
|
134
|
+
stackAnimation = topScreenWrapper?.screen?.stackAnimation
|
|
131
135
|
}
|
|
132
136
|
|
|
133
137
|
createTransaction().let {
|
|
@@ -180,19 +184,19 @@ class ScreenStack(context: Context?) : ScreenContainer(context) {
|
|
|
180
184
|
}
|
|
181
185
|
|
|
182
186
|
// remove all screens previously on stack
|
|
183
|
-
for (fragmentWrapper in
|
|
184
|
-
if (!
|
|
187
|
+
for (fragmentWrapper in stack) {
|
|
188
|
+
if (!screenWrappers.contains(fragmentWrapper) || dismissedWrappers.contains(fragmentWrapper)) {
|
|
185
189
|
it.remove(fragmentWrapper.fragment)
|
|
186
190
|
}
|
|
187
191
|
}
|
|
188
|
-
for (fragmentWrapper in
|
|
192
|
+
for (fragmentWrapper in screenWrappers) {
|
|
189
193
|
// Stop detaching screens when reaching visible bottom. All screens above bottom should be
|
|
190
194
|
// visible.
|
|
191
195
|
if (fragmentWrapper === visibleBottom) {
|
|
192
196
|
break
|
|
193
197
|
}
|
|
194
198
|
// detach all screens that should not be visible
|
|
195
|
-
if (fragmentWrapper !== newTop && !
|
|
199
|
+
if (fragmentWrapper !== newTop && !dismissedWrappers.contains(fragmentWrapper)) {
|
|
196
200
|
it.remove(fragmentWrapper.fragment)
|
|
197
201
|
}
|
|
198
202
|
}
|
|
@@ -201,7 +205,7 @@ class ScreenStack(context: Context?) : ScreenContainer(context) {
|
|
|
201
205
|
if (visibleBottom != null && !visibleBottom.fragment.isAdded) {
|
|
202
206
|
val top = newTop
|
|
203
207
|
var beneathVisibleBottom = true
|
|
204
|
-
for (fragmentWrapper in
|
|
208
|
+
for (fragmentWrapper in screenWrappers) {
|
|
205
209
|
// ignore all screens beneath the visible bottom
|
|
206
210
|
if (beneathVisibleBottom) {
|
|
207
211
|
beneathVisibleBottom = if (fragmentWrapper === visibleBottom) {
|
|
@@ -214,9 +218,9 @@ class ScreenStack(context: Context?) : ScreenContainer(context) {
|
|
|
214
218
|
} else if (newTop != null && !newTop.fragment.isAdded) {
|
|
215
219
|
it.add(id, newTop.fragment)
|
|
216
220
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
221
|
+
topScreenWrapper = newTop as? ScreenStackFragmentWrapper
|
|
222
|
+
stack.clear()
|
|
223
|
+
stack.addAll(screenWrappers.map { it as ScreenStackFragmentWrapper })
|
|
220
224
|
|
|
221
225
|
turnOffA11yUnderTransparentScreen(visibleBottom)
|
|
222
226
|
|
|
@@ -226,10 +230,10 @@ class ScreenStack(context: Context?) : ScreenContainer(context) {
|
|
|
226
230
|
|
|
227
231
|
// only top visible screen should be accessible
|
|
228
232
|
private fun turnOffA11yUnderTransparentScreen(visibleBottom: ScreenFragmentWrapper?) {
|
|
229
|
-
if (
|
|
230
|
-
|
|
233
|
+
if (screenWrappers.size > 1 && visibleBottom != null) {
|
|
234
|
+
topScreenWrapper?.let {
|
|
231
235
|
if (isTransparent(it)) {
|
|
232
|
-
val screenFragmentsBeneathTop =
|
|
236
|
+
val screenFragmentsBeneathTop = screenWrappers.slice(0 until screenWrappers.size - 1).asReversed()
|
|
233
237
|
// go from the top of the stack excluding the top screen
|
|
234
238
|
for (fragmentWrapper in screenFragmentsBeneathTop) {
|
|
235
239
|
fragmentWrapper.screen.changeAccessibilityMode(IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS)
|
|
@@ -247,7 +251,7 @@ class ScreenStack(context: Context?) : ScreenContainer(context) {
|
|
|
247
251
|
}
|
|
248
252
|
|
|
249
253
|
override fun notifyContainerUpdate() {
|
|
250
|
-
|
|
254
|
+
stack.forEach { it.onContainerUpdate() }
|
|
251
255
|
}
|
|
252
256
|
|
|
253
257
|
// below methods are taken from
|
|
@@ -332,8 +336,10 @@ class ScreenStack(context: Context?) : ScreenContainer(context) {
|
|
|
332
336
|
fragmentWrapper.screen.stackPresentation === Screen.StackPresentation.TRANSPARENT_MODAL
|
|
333
337
|
|
|
334
338
|
private fun needsDrawReordering(fragmentWrapper: ScreenFragmentWrapper): Boolean =
|
|
335
|
-
|
|
339
|
+
// On Android sdk 33 and above the animation is different and requires draw reordering.
|
|
340
|
+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU ||
|
|
341
|
+
fragmentWrapper.screen.stackAnimation === StackAnimation.SLIDE_FROM_BOTTOM ||
|
|
336
342
|
fragmentWrapper.screen.stackAnimation === StackAnimation.FADE_FROM_BOTTOM ||
|
|
337
|
-
|
|
343
|
+
fragmentWrapper.screen.stackAnimation === StackAnimation.IOS
|
|
338
344
|
}
|
|
339
345
|
}
|
|
@@ -22,12 +22,12 @@ import com.google.android.material.appbar.AppBarLayout.ScrollingViewBehavior
|
|
|
22
22
|
import com.swmansion.rnscreens.utils.DeviceUtils
|
|
23
23
|
|
|
24
24
|
class ScreenStackFragment : ScreenFragment, ScreenStackFragmentWrapper {
|
|
25
|
-
private var
|
|
26
|
-
private var
|
|
27
|
-
private var
|
|
28
|
-
private var
|
|
25
|
+
private var appBarLayout: AppBarLayout? = null
|
|
26
|
+
private var toolbar: Toolbar? = null
|
|
27
|
+
private var isToolbarShadowHidden = false
|
|
28
|
+
private var isToolbarTranslucent = false
|
|
29
29
|
|
|
30
|
-
private var
|
|
30
|
+
private var lastFocusedChild: View? = null
|
|
31
31
|
|
|
32
32
|
var searchView: CustomSearchView? = null
|
|
33
33
|
var onSearchViewCreate: ((searchView: CustomSearchView) -> Unit)? = null
|
|
@@ -42,37 +42,37 @@ class ScreenStackFragment : ScreenFragment, ScreenStackFragmentWrapper {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
override fun removeToolbar() {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
appBarLayout?.let {
|
|
46
|
+
toolbar?.let { toolbar ->
|
|
47
47
|
if (toolbar.parent === it) {
|
|
48
48
|
it.removeView(toolbar)
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
toolbar = null
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
override fun setToolbar(toolbar: Toolbar) {
|
|
56
|
-
|
|
56
|
+
appBarLayout?.addView(toolbar)
|
|
57
57
|
toolbar.layoutParams = AppBarLayout.LayoutParams(
|
|
58
58
|
AppBarLayout.LayoutParams.MATCH_PARENT, AppBarLayout.LayoutParams.WRAP_CONTENT
|
|
59
59
|
).apply { scrollFlags = 0 }
|
|
60
|
-
|
|
60
|
+
this.toolbar = toolbar
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
override fun setToolbarShadowHidden(hidden: Boolean) {
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
if (isToolbarShadowHidden != hidden) {
|
|
65
|
+
appBarLayout?.targetElevation = if (hidden) 0f else PixelUtil.toPixelFromDIP(4f)
|
|
66
|
+
isToolbarShadowHidden = hidden
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
override fun setToolbarTranslucent(translucent: Boolean) {
|
|
71
|
-
if (
|
|
71
|
+
if (isToolbarTranslucent != translucent) {
|
|
72
72
|
val params = screen.layoutParams
|
|
73
73
|
(params as CoordinatorLayout.LayoutParams).behavior =
|
|
74
74
|
if (translucent) null else ScrollingViewBehavior()
|
|
75
|
-
|
|
75
|
+
isToolbarTranslucent = translucent
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -94,7 +94,7 @@ class ScreenStackFragment : ScreenFragment, ScreenStackFragmentWrapper {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
override fun onStart() {
|
|
97
|
-
|
|
97
|
+
lastFocusedChild?.requestFocus()
|
|
98
98
|
super.onStart()
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -108,11 +108,11 @@ class ScreenStackFragment : ScreenFragment, ScreenStackFragmentWrapper {
|
|
|
108
108
|
|
|
109
109
|
screen.layoutParams = CoordinatorLayout.LayoutParams(
|
|
110
110
|
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT
|
|
111
|
-
).apply { behavior = if (
|
|
111
|
+
).apply { behavior = if (isToolbarTranslucent) null else ScrollingViewBehavior() }
|
|
112
112
|
|
|
113
113
|
view?.addView(recycleView(screen))
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
appBarLayout = context?.let { AppBarLayout(it) }?.apply {
|
|
116
116
|
// By default AppBarLayout will have a background color set but since we cover the whole layout
|
|
117
117
|
// with toolbar (that can be semi-transparent) the bar layout background color does not pay a
|
|
118
118
|
// role. On top of that it breaks screens animations when alfa offscreen compositing is off
|
|
@@ -123,18 +123,18 @@ class ScreenStackFragment : ScreenFragment, ScreenStackFragmentWrapper {
|
|
|
123
123
|
)
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
view?.addView(
|
|
127
|
-
if (
|
|
128
|
-
|
|
126
|
+
view?.addView(appBarLayout)
|
|
127
|
+
if (isToolbarShadowHidden) {
|
|
128
|
+
appBarLayout?.targetElevation = 0f
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
toolbar?.let { appBarLayout?.addView(recycleView(it)) }
|
|
131
131
|
setHasOptionsMenu(true)
|
|
132
132
|
return view
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
override fun onStop() {
|
|
136
136
|
if (DeviceUtils.isPlatformAndroidTV(context))
|
|
137
|
-
|
|
137
|
+
lastFocusedChild = findLastFocusedChild()
|
|
138
138
|
|
|
139
139
|
super.onStop()
|
|
140
140
|
}
|
|
@@ -22,28 +22,28 @@ import com.swmansion.rnscreens.events.HeaderAttachedEvent
|
|
|
22
22
|
import com.swmansion.rnscreens.events.HeaderDetachedEvent
|
|
23
23
|
|
|
24
24
|
class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) {
|
|
25
|
-
private val
|
|
25
|
+
private val configSubviews = ArrayList<ScreenStackHeaderSubview>(3)
|
|
26
26
|
val toolbar: CustomToolbar
|
|
27
|
-
var
|
|
27
|
+
var isHeaderHidden = false // named this way to avoid conflict with platform's isHidden
|
|
28
|
+
var isHeaderTranslucent = false // named this way to avoid conflict with platform's isTranslucent
|
|
28
29
|
private var headerTopInset: Int? = null
|
|
29
|
-
private var
|
|
30
|
-
private var
|
|
31
|
-
private var
|
|
32
|
-
private var
|
|
33
|
-
private var
|
|
34
|
-
private var
|
|
35
|
-
private var
|
|
36
|
-
private var
|
|
37
|
-
private var
|
|
38
|
-
private var
|
|
39
|
-
private var
|
|
40
|
-
private var
|
|
41
|
-
private var
|
|
42
|
-
private var
|
|
43
|
-
private
|
|
44
|
-
private val
|
|
45
|
-
private val
|
|
46
|
-
private val mBackClickListener = OnClickListener {
|
|
30
|
+
private var title: String? = null
|
|
31
|
+
private var titleColor = 0
|
|
32
|
+
private var titleFontFamily: String? = null
|
|
33
|
+
private var direction: String? = null
|
|
34
|
+
private var titleFontSize = 0f
|
|
35
|
+
private var titleFontWeight = 0
|
|
36
|
+
private var backgroundColor: Int? = null
|
|
37
|
+
private var isBackButtonHidden = false
|
|
38
|
+
private var isShadowHidden = false
|
|
39
|
+
private var isDestroyed = false
|
|
40
|
+
private var backButtonInCustomView = false
|
|
41
|
+
private var isTopInsetEnabled = true
|
|
42
|
+
private var tintColor = 0
|
|
43
|
+
private var isAttachedToWindow = false
|
|
44
|
+
private val defaultStartInset: Int
|
|
45
|
+
private val defaultStartInsetWithNavigation: Int
|
|
46
|
+
private val backClickListener = OnClickListener {
|
|
47
47
|
screenFragment?.let {
|
|
48
48
|
val stack = screenStack
|
|
49
49
|
if (stack != null && stack.rootScreen == it.screen) {
|
|
@@ -70,12 +70,12 @@ class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
fun destroy() {
|
|
73
|
-
|
|
73
|
+
isDestroyed = true
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
override fun onAttachedToWindow() {
|
|
77
77
|
super.onAttachedToWindow()
|
|
78
|
-
|
|
78
|
+
isAttachedToWindow = true
|
|
79
79
|
val surfaceId = UIManagerHelper.getSurfaceId(this)
|
|
80
80
|
UIManagerHelper.getEventDispatcherForReactTag(context as ReactContext, id)
|
|
81
81
|
?.dispatchEvent(HeaderAttachedEvent(surfaceId, id))
|
|
@@ -93,7 +93,7 @@ class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) {
|
|
|
93
93
|
|
|
94
94
|
override fun onDetachedFromWindow() {
|
|
95
95
|
super.onDetachedFromWindow()
|
|
96
|
-
|
|
96
|
+
isAttachedToWindow = false
|
|
97
97
|
val surfaceId = UIManagerHelper.getSurfaceId(this)
|
|
98
98
|
UIManagerHelper.getEventDispatcherForReactTag(context as ReactContext, id)
|
|
99
99
|
?.dispatchEvent(HeaderDetachedEvent(surfaceId, id))
|
|
@@ -101,8 +101,10 @@ class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) {
|
|
|
101
101
|
|
|
102
102
|
private val screen: Screen?
|
|
103
103
|
get() = parent as? Screen
|
|
104
|
+
|
|
104
105
|
private val screenStack: ScreenStack?
|
|
105
106
|
get() = screen?.container as? ScreenStack
|
|
107
|
+
|
|
106
108
|
val screenFragment: ScreenStackFragment?
|
|
107
109
|
get() {
|
|
108
110
|
val screen = parent
|
|
@@ -119,15 +121,15 @@ class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) {
|
|
|
119
121
|
val stack = screenStack
|
|
120
122
|
val isTop = stack == null || stack.topScreen == parent
|
|
121
123
|
|
|
122
|
-
if (!
|
|
124
|
+
if (!isAttachedToWindow || !isTop || isDestroyed) {
|
|
123
125
|
return
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
val activity = screenFragment?.activity as AppCompatActivity? ?: return
|
|
127
|
-
if (
|
|
128
|
-
if (
|
|
129
|
+
if (direction != null) {
|
|
130
|
+
if (direction == "rtl") {
|
|
129
131
|
toolbar.layoutDirection = LAYOUT_DIRECTION_RTL
|
|
130
|
-
} else if (
|
|
132
|
+
} else if (direction == "ltr") {
|
|
131
133
|
toolbar.layoutDirection = LAYOUT_DIRECTION_LTR
|
|
132
134
|
}
|
|
133
135
|
}
|
|
@@ -146,7 +148,7 @@ class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) {
|
|
|
146
148
|
ScreenWindowTraits.trySetWindowTraits(it, activity, reactContext)
|
|
147
149
|
}
|
|
148
150
|
|
|
149
|
-
if (
|
|
151
|
+
if (isHeaderHidden) {
|
|
150
152
|
if (toolbar.parent != null) {
|
|
151
153
|
screenFragment?.removeToolbar()
|
|
152
154
|
}
|
|
@@ -157,7 +159,7 @@ class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) {
|
|
|
157
159
|
screenFragment?.setToolbar(toolbar)
|
|
158
160
|
}
|
|
159
161
|
|
|
160
|
-
if (
|
|
162
|
+
if (isTopInsetEnabled) {
|
|
161
163
|
headerTopInset.let {
|
|
162
164
|
toolbar.setPadding(0, it ?: 0, 0, 0)
|
|
163
165
|
}
|
|
@@ -176,28 +178,28 @@ class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) {
|
|
|
176
178
|
// reset startWithNavigation inset which corresponds to the distance between navigation icon and
|
|
177
179
|
// title. If title isn't set we clear that value few lines below to give more space to custom
|
|
178
180
|
// center-mounted views.
|
|
179
|
-
toolbar.contentInsetStartWithNavigation =
|
|
180
|
-
toolbar.setContentInsetsRelative(
|
|
181
|
+
toolbar.contentInsetStartWithNavigation = defaultStartInsetWithNavigation
|
|
182
|
+
toolbar.setContentInsetsRelative(defaultStartInset, defaultStartInset)
|
|
181
183
|
|
|
182
184
|
// hide back button
|
|
183
185
|
actionBar.setDisplayHomeAsUpEnabled(
|
|
184
|
-
screenFragment?.canNavigateBack() == true && !
|
|
186
|
+
screenFragment?.canNavigateBack() == true && !isBackButtonHidden
|
|
185
187
|
)
|
|
186
188
|
|
|
187
189
|
// when setSupportActionBar is called a toolbar wrapper gets initialized that overwrites
|
|
188
190
|
// navigation click listener. The default behavior set in the wrapper is to call into
|
|
189
191
|
// menu options handlers, but we prefer the back handling logic to stay here instead.
|
|
190
|
-
toolbar.setNavigationOnClickListener(
|
|
192
|
+
toolbar.setNavigationOnClickListener(backClickListener)
|
|
191
193
|
|
|
192
194
|
// shadow
|
|
193
|
-
screenFragment?.setToolbarShadowHidden(
|
|
195
|
+
screenFragment?.setToolbarShadowHidden(isShadowHidden)
|
|
194
196
|
|
|
195
197
|
// translucent
|
|
196
|
-
screenFragment?.setToolbarTranslucent(
|
|
198
|
+
screenFragment?.setToolbarTranslucent(isHeaderTranslucent)
|
|
197
199
|
|
|
198
200
|
// title
|
|
199
|
-
actionBar.title =
|
|
200
|
-
if (TextUtils.isEmpty(
|
|
201
|
+
actionBar.title = title
|
|
202
|
+
if (TextUtils.isEmpty(title)) {
|
|
201
203
|
// if title is empty we set start navigation inset to 0 to give more space to custom rendered
|
|
202
204
|
// views. When it is set to default it'd take up additional distance from the back button
|
|
203
205
|
// which would impact the position of custom header views rendered at the center.
|
|
@@ -205,28 +207,28 @@ class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) {
|
|
|
205
207
|
}
|
|
206
208
|
|
|
207
209
|
val titleTextView = titleTextView
|
|
208
|
-
if (
|
|
209
|
-
toolbar.setTitleTextColor(
|
|
210
|
+
if (titleColor != 0) {
|
|
211
|
+
toolbar.setTitleTextColor(titleColor)
|
|
210
212
|
}
|
|
211
213
|
|
|
212
214
|
if (titleTextView != null) {
|
|
213
|
-
if (
|
|
215
|
+
if (titleFontFamily != null || titleFontWeight > 0) {
|
|
214
216
|
val titleTypeface = ReactTypefaceUtils.applyStyles(
|
|
215
|
-
null, 0,
|
|
217
|
+
null, 0, titleFontWeight, titleFontFamily, context.assets
|
|
216
218
|
)
|
|
217
219
|
titleTextView.typeface = titleTypeface
|
|
218
220
|
}
|
|
219
|
-
if (
|
|
220
|
-
titleTextView.textSize =
|
|
221
|
+
if (titleFontSize > 0) {
|
|
222
|
+
titleTextView.textSize = titleFontSize
|
|
221
223
|
}
|
|
222
224
|
}
|
|
223
225
|
|
|
224
226
|
// background
|
|
225
|
-
|
|
227
|
+
backgroundColor?.let { toolbar.setBackgroundColor(it) }
|
|
226
228
|
|
|
227
229
|
// color
|
|
228
|
-
if (
|
|
229
|
-
toolbar.navigationIcon?.setColorFilter(
|
|
230
|
+
if (tintColor != 0) {
|
|
231
|
+
toolbar.navigationIcon?.setColorFilter(tintColor, PorterDuff.Mode.SRC_ATOP)
|
|
230
232
|
}
|
|
231
233
|
|
|
232
234
|
// subviews
|
|
@@ -237,9 +239,9 @@ class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) {
|
|
|
237
239
|
}
|
|
238
240
|
|
|
239
241
|
var i = 0
|
|
240
|
-
val size =
|
|
242
|
+
val size = configSubviews.size
|
|
241
243
|
while (i < size) {
|
|
242
|
-
val view =
|
|
244
|
+
val view = configSubviews[i]
|
|
243
245
|
val type = view.type
|
|
244
246
|
if (type === ScreenStackHeaderSubview.Type.BACK) {
|
|
245
247
|
// we special case BACK button header config type as we don't add it as a view into toolbar
|
|
@@ -257,7 +259,7 @@ class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) {
|
|
|
257
259
|
ScreenStackHeaderSubview.Type.LEFT -> {
|
|
258
260
|
// when there is a left item we need to disable navigation icon by default
|
|
259
261
|
// we also hide title as there is no other way to display left side items
|
|
260
|
-
if (!
|
|
262
|
+
if (!backButtonInCustomView) {
|
|
261
263
|
toolbar.navigationIcon = null
|
|
262
264
|
}
|
|
263
265
|
toolbar.title = null
|
|
@@ -278,28 +280,28 @@ class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) {
|
|
|
278
280
|
}
|
|
279
281
|
|
|
280
282
|
private fun maybeUpdate() {
|
|
281
|
-
if (parent != null && !
|
|
283
|
+
if (parent != null && !isDestroyed) {
|
|
282
284
|
onUpdate()
|
|
283
285
|
}
|
|
284
286
|
}
|
|
285
287
|
|
|
286
|
-
fun getConfigSubview(index: Int): ScreenStackHeaderSubview =
|
|
288
|
+
fun getConfigSubview(index: Int): ScreenStackHeaderSubview = configSubviews[index]
|
|
287
289
|
|
|
288
290
|
val configSubviewsCount: Int
|
|
289
|
-
get() =
|
|
291
|
+
get() = configSubviews.size
|
|
290
292
|
|
|
291
293
|
fun removeConfigSubview(index: Int) {
|
|
292
|
-
|
|
294
|
+
configSubviews.removeAt(index)
|
|
293
295
|
maybeUpdate()
|
|
294
296
|
}
|
|
295
297
|
|
|
296
298
|
fun removeAllConfigSubviews() {
|
|
297
|
-
|
|
299
|
+
configSubviews.clear()
|
|
298
300
|
maybeUpdate()
|
|
299
301
|
}
|
|
300
302
|
|
|
301
303
|
fun addConfigSubview(child: ScreenStackHeaderSubview, index: Int) {
|
|
302
|
-
|
|
304
|
+
configSubviews.add(index, child)
|
|
303
305
|
maybeUpdate()
|
|
304
306
|
}
|
|
305
307
|
|
|
@@ -317,59 +319,59 @@ class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) {
|
|
|
317
319
|
}
|
|
318
320
|
|
|
319
321
|
fun setTitle(title: String?) {
|
|
320
|
-
|
|
322
|
+
this.title = title
|
|
321
323
|
}
|
|
322
324
|
|
|
323
325
|
fun setTitleFontFamily(titleFontFamily: String?) {
|
|
324
|
-
|
|
326
|
+
this.titleFontFamily = titleFontFamily
|
|
325
327
|
}
|
|
326
328
|
|
|
327
329
|
fun setTitleFontWeight(fontWeightString: String?) {
|
|
328
|
-
|
|
330
|
+
titleFontWeight = ReactTypefaceUtils.parseFontWeight(fontWeightString)
|
|
329
331
|
}
|
|
330
332
|
|
|
331
333
|
fun setTitleFontSize(titleFontSize: Float) {
|
|
332
|
-
|
|
334
|
+
this.titleFontSize = titleFontSize
|
|
333
335
|
}
|
|
334
336
|
|
|
335
337
|
fun setTitleColor(color: Int) {
|
|
336
|
-
|
|
338
|
+
titleColor = color
|
|
337
339
|
}
|
|
338
340
|
|
|
339
341
|
fun setTintColor(color: Int) {
|
|
340
|
-
|
|
342
|
+
tintColor = color
|
|
341
343
|
}
|
|
342
344
|
|
|
343
345
|
fun setTopInsetEnabled(topInsetEnabled: Boolean) {
|
|
344
|
-
|
|
346
|
+
isTopInsetEnabled = topInsetEnabled
|
|
345
347
|
}
|
|
346
348
|
|
|
347
349
|
fun setBackgroundColor(color: Int?) {
|
|
348
|
-
|
|
350
|
+
backgroundColor = color
|
|
349
351
|
}
|
|
350
352
|
|
|
351
353
|
fun setHideShadow(hideShadow: Boolean) {
|
|
352
|
-
|
|
354
|
+
isShadowHidden = hideShadow
|
|
353
355
|
}
|
|
354
356
|
|
|
355
357
|
fun setHideBackButton(hideBackButton: Boolean) {
|
|
356
|
-
|
|
358
|
+
isBackButtonHidden = hideBackButton
|
|
357
359
|
}
|
|
358
360
|
|
|
359
361
|
fun setHidden(hidden: Boolean) {
|
|
360
|
-
|
|
362
|
+
isHeaderHidden = hidden
|
|
361
363
|
}
|
|
362
364
|
|
|
363
365
|
fun setTranslucent(translucent: Boolean) {
|
|
364
|
-
|
|
366
|
+
isHeaderTranslucent = translucent
|
|
365
367
|
}
|
|
366
368
|
|
|
367
369
|
fun setBackButtonInCustomView(backButtonInCustomView: Boolean) {
|
|
368
|
-
|
|
370
|
+
this.backButtonInCustomView = backButtonInCustomView
|
|
369
371
|
}
|
|
370
372
|
|
|
371
373
|
fun setDirection(direction: String?) {
|
|
372
|
-
|
|
374
|
+
this.direction = direction
|
|
373
375
|
}
|
|
374
376
|
|
|
375
377
|
private class DebugMenuToolbar(context: Context, config: ScreenStackHeaderConfig) : CustomToolbar(context, config) {
|
|
@@ -385,8 +387,8 @@ class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) {
|
|
|
385
387
|
init {
|
|
386
388
|
visibility = GONE
|
|
387
389
|
toolbar = if (BuildConfig.DEBUG) DebugMenuToolbar(context, this) else CustomToolbar(context, this)
|
|
388
|
-
|
|
389
|
-
|
|
390
|
+
defaultStartInset = toolbar.contentInsetStart
|
|
391
|
+
defaultStartInsetWithNavigation = toolbar.contentInsetStartWithNavigation
|
|
390
392
|
|
|
391
393
|
// set primary color as background by default
|
|
392
394
|
val tv = TypedValue()
|