react-native-screens 3.21.1 → 3.22.1
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/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +11 -10
- package/ios/RNSScreenWindowTraits.mm +6 -2
- package/lib/commonjs/TransitionProgressContext.js.map +1 -1
- package/lib/commonjs/fabric/ScreenNativeComponent.js +1 -0
- package/lib/commonjs/fabric/ScreenNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenStackHeaderSubviewNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenStackNativeComponent.js +1 -0
- package/lib/commonjs/fabric/ScreenStackNativeComponent.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.native.js +16 -2
- package/lib/commonjs/index.native.js.map +1 -1
- package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/commonjs/native-stack/utils/SafeAreaProviderCompat.js.map +1 -1
- package/lib/commonjs/native-stack/utils/useBackPressSubscription.js.map +1 -1
- package/lib/commonjs/native-stack/utils/useHeaderHeight.js.map +1 -1
- package/lib/commonjs/native-stack/views/HeaderConfig.js.map +1 -1
- package/lib/commonjs/native-stack/views/NativeStackView.js +2 -1
- package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js +1 -1
- package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedScreen.js +1 -1
- package/lib/commonjs/reanimated/ReanimatedScreen.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedScreenProvider.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedTransitionProgressContext.js +1 -0
- package/lib/commonjs/reanimated/ReanimatedTransitionProgressContext.js.map +1 -1
- package/lib/commonjs/reanimated/useReanimatedTransitionProgress.js.map +1 -1
- package/lib/commonjs/useTransitionProgress.js.map +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/TransitionProgressContext.js.map +1 -1
- package/lib/module/fabric/ScreenNativeComponent.js +3 -0
- 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 +3 -0
- package/lib/module/fabric/ScreenStackNativeComponent.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.native.js +15 -1
- package/lib/module/index.native.js.map +1 -1
- package/lib/module/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/module/native-stack/utils/SafeAreaProviderCompat.js.map +1 -1
- 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/HeaderConfig.js.map +1 -1
- package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/module/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
- package/lib/module/reanimated/ReanimatedScreen.js.map +1 -1
- package/lib/module/reanimated/ReanimatedScreenProvider.js.map +1 -1
- package/lib/module/reanimated/useReanimatedTransitionProgress.js.map +1 -1
- package/lib/module/useTransitionProgress.js.map +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/native-stack/navigators/createNativeStackNavigator.d.ts +2 -2
- package/lib/typescript/native-stack/utils/SafeAreaProviderCompat.d.ts +1 -1
- package/lib/typescript/native-stack/views/NativeStackView.d.ts +2 -2
- package/lib/typescript/reanimated/ReanimatedScreenProvider.d.ts +2 -2
- package/package.json +1 -1
- package/src/index.native.tsx +15 -0
- package/android/src/main/java/com/swmansion/rnscreens/LifecycleHelper.kt +0 -60
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
package com.swmansion.rnscreens
|
|
2
|
-
|
|
3
|
-
import android.view.View
|
|
4
|
-
import androidx.fragment.app.Fragment
|
|
5
|
-
import androidx.lifecycle.Lifecycle
|
|
6
|
-
import androidx.lifecycle.LifecycleObserver
|
|
7
|
-
|
|
8
|
-
class LifecycleHelper {
|
|
9
|
-
private val mViewToLifecycleMap: MutableMap<View, Lifecycle> = HashMap()
|
|
10
|
-
private val mRegisterOnLayoutChange: View.OnLayoutChangeListener = object : View.OnLayoutChangeListener {
|
|
11
|
-
override fun onLayoutChange(
|
|
12
|
-
view: View,
|
|
13
|
-
i: Int,
|
|
14
|
-
i1: Int,
|
|
15
|
-
i2: Int,
|
|
16
|
-
i3: Int,
|
|
17
|
-
i4: Int,
|
|
18
|
-
i5: Int,
|
|
19
|
-
i6: Int,
|
|
20
|
-
i7: Int
|
|
21
|
-
) {
|
|
22
|
-
registerViewWithLifecycleOwner(view)
|
|
23
|
-
view.removeOnLayoutChangeListener(this)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
private fun registerViewWithLifecycleOwner(view: View) {
|
|
28
|
-
val parent = findNearestScreenFragmentAncestor(view)
|
|
29
|
-
if (parent != null && view is LifecycleObserver) {
|
|
30
|
-
val lifecycle = parent.lifecycle
|
|
31
|
-
lifecycle.addObserver((view as LifecycleObserver))
|
|
32
|
-
mViewToLifecycleMap[view] = lifecycle
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
fun <T> register(view: T) where T : View, T : LifecycleObserver? {
|
|
37
|
-
// we need to wait until view is mounted in the hierarchy as this method is called only at the
|
|
38
|
-
// moment of the view creation. In order to register lifecycle observer we need to find ancestor
|
|
39
|
-
// of type Screen and this can only happen when the view is properly attached. We rely on
|
|
40
|
-
// Android's onLayout callback being triggered when the view gets added to the hierarchy and
|
|
41
|
-
// only then we attempt to locate lifecycle owner ancestor.
|
|
42
|
-
view.addOnLayoutChangeListener(mRegisterOnLayoutChange)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
fun <T> unregister(view: T) where T : View, T : LifecycleObserver? {
|
|
46
|
-
mViewToLifecycleMap[view]?.removeObserver(view)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
companion object {
|
|
50
|
-
fun findNearestScreenFragmentAncestor(view: View): Fragment? {
|
|
51
|
-
var parent = view.parent
|
|
52
|
-
while (parent != null && parent !is Screen) {
|
|
53
|
-
parent = parent.parent
|
|
54
|
-
}
|
|
55
|
-
return if (parent != null) {
|
|
56
|
-
(parent as Screen).fragment
|
|
57
|
-
} else null
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|