react-native-screens 4.7.0-beta.4 → 4.7.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/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewViewGroup.kt +25 -0
- package/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigComponentDescriptor.h +1 -2
- package/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewComponentDescriptor.h +4 -4
- package/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.h +1 -1
- package/common/cpp/react/renderer/components/rnscreens/utils/RectUtil.h +7 -0
- package/lib/typescript/types.d.ts +1 -1
- package/package.json +1 -1
- package/src/types.tsx +1 -1
package/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewViewGroup.kt
CHANGED
|
@@ -7,12 +7,18 @@ import com.facebook.react.bridge.WritableMap
|
|
|
7
7
|
import com.facebook.react.bridge.WritableNativeMap
|
|
8
8
|
import com.facebook.react.uimanager.PixelUtil
|
|
9
9
|
import com.facebook.react.uimanager.StateWrapper
|
|
10
|
+
import kotlin.math.abs
|
|
10
11
|
|
|
11
12
|
abstract class FabricEnabledHeaderSubviewViewGroup(
|
|
12
13
|
context: Context?,
|
|
13
14
|
) : ViewGroup(context) {
|
|
14
15
|
private var mStateWrapper: StateWrapper? = null
|
|
15
16
|
|
|
17
|
+
private var lastWidth = 0f
|
|
18
|
+
private var lastHeight = 0f
|
|
19
|
+
private var lastOffsetX = 0f
|
|
20
|
+
private var lastOffsetY = 0f
|
|
21
|
+
|
|
16
22
|
fun setStateWrapper(wrapper: StateWrapper?) {
|
|
17
23
|
mStateWrapper = wrapper
|
|
18
24
|
}
|
|
@@ -38,6 +44,21 @@ abstract class FabricEnabledHeaderSubviewViewGroup(
|
|
|
38
44
|
val offsetXDip: Float = PixelUtil.toDIPFromPixel(offsetX.toFloat())
|
|
39
45
|
val offsetYDip: Float = PixelUtil.toDIPFromPixel(offsetY.toFloat())
|
|
40
46
|
|
|
47
|
+
// Check incoming state values. If they're already the correct value, return early to prevent
|
|
48
|
+
// infinite UpdateState/SetState loop.
|
|
49
|
+
if (abs(lastWidth - realWidth) < DELTA &&
|
|
50
|
+
abs(lastHeight - realHeight) < DELTA &&
|
|
51
|
+
abs(lastOffsetX - offsetXDip) < DELTA &&
|
|
52
|
+
abs(lastOffsetY - offsetYDip) < DELTA
|
|
53
|
+
) {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
lastWidth = realWidth
|
|
58
|
+
lastHeight = realHeight
|
|
59
|
+
lastOffsetX = offsetXDip
|
|
60
|
+
lastOffsetY = offsetYDip
|
|
61
|
+
|
|
41
62
|
val map: WritableMap =
|
|
42
63
|
WritableNativeMap().apply {
|
|
43
64
|
putDouble("frameWidth", realWidth.toDouble())
|
|
@@ -48,4 +69,8 @@ abstract class FabricEnabledHeaderSubviewViewGroup(
|
|
|
48
69
|
|
|
49
70
|
mStateWrapper?.updateState(map)
|
|
50
71
|
}
|
|
72
|
+
|
|
73
|
+
companion object {
|
|
74
|
+
private const val DELTA = 0.9f
|
|
75
|
+
}
|
|
51
76
|
}
|
|
@@ -35,8 +35,7 @@ class RNSScreenStackHeaderConfigComponentDescriptor final
|
|
|
35
35
|
auto stateData = state->getData();
|
|
36
36
|
|
|
37
37
|
if (stateData.frameSize.width != 0 && stateData.frameSize.height != 0) {
|
|
38
|
-
layoutableShadowNode.setSize(
|
|
39
|
-
{stateData.frameSize.width, stateData.frameSize.height});
|
|
38
|
+
layoutableShadowNode.setSize(stateData.frameSize);
|
|
40
39
|
#ifdef ANDROID
|
|
41
40
|
layoutableShadowNode.setPadding({
|
|
42
41
|
stateData.paddingStart,
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#include <react/renderer/components/rnscreens/utils/RectUtil.h>
|
|
9
9
|
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
10
10
|
#include "RNSScreenStackHeaderSubviewShadowNode.h"
|
|
11
|
+
#include "utils/RectUtil.h"
|
|
11
12
|
|
|
12
13
|
namespace facebook::react {
|
|
13
14
|
|
|
@@ -32,12 +33,11 @@ class RNSScreenStackHeaderSubviewComponentDescriptor final
|
|
|
32
33
|
|
|
33
34
|
auto state = std::static_pointer_cast<
|
|
34
35
|
const RNSScreenStackHeaderSubviewShadowNode::ConcreteState>(
|
|
35
|
-
shadowNode.
|
|
36
|
+
shadowNode.getMostRecentState());
|
|
36
37
|
auto stateData = state->getData();
|
|
37
38
|
|
|
38
|
-
if (stateData.frameSize
|
|
39
|
-
layoutableShadowNode.setSize(
|
|
40
|
-
Size{stateData.frameSize.width, stateData.frameSize.height});
|
|
39
|
+
if (!isSizeEmpty(stateData.frameSize)) {
|
|
40
|
+
layoutableShadowNode.setSize(stateData.frameSize);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
ConcreteComponentDescriptor::adopt(shadowNode);
|
|
@@ -33,4 +33,11 @@ inline constexpr bool checkFrameSizesEqualWithEps(
|
|
|
33
33
|
equalWithRespectToEps(first.height, second.height, eps);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* @return false if any component value is less than 0
|
|
38
|
+
*/
|
|
39
|
+
inline constexpr bool isSizeEmpty(const react::Size &size) {
|
|
40
|
+
return size.width < 0 || size.height < 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
36
43
|
} // namespace rnscreens
|
|
@@ -235,7 +235,7 @@ export interface ScreenProps extends ViewProps {
|
|
|
235
235
|
* while **Android is limited to three**.
|
|
236
236
|
*
|
|
237
237
|
* There is also possibility to specify `fitToContents` literal, which intents to set the sheet height
|
|
238
|
-
* to the height of its contents.
|
|
238
|
+
* to the height of its contents. On iOS `fitToContents` currently also includes small padding accounting for bottom inset.
|
|
239
239
|
*
|
|
240
240
|
* Please note that the array **must** be sorted in ascending order. This invariant is verified only in developement mode,
|
|
241
241
|
* where violation results in error.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-screens",
|
|
3
|
-
"version": "4.7.0
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "Native navigation primitives for your React Native app.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"submodules": "git submodule update --init --recursive && (cd react-navigation && yarn && yarn build && cd ../)",
|
package/src/types.tsx
CHANGED
|
@@ -303,7 +303,7 @@ export interface ScreenProps extends ViewProps {
|
|
|
303
303
|
* while **Android is limited to three**.
|
|
304
304
|
*
|
|
305
305
|
* There is also possibility to specify `fitToContents` literal, which intents to set the sheet height
|
|
306
|
-
* to the height of its contents.
|
|
306
|
+
* to the height of its contents. On iOS `fitToContents` currently also includes small padding accounting for bottom inset.
|
|
307
307
|
*
|
|
308
308
|
* Please note that the array **must** be sorted in ascending order. This invariant is verified only in developement mode,
|
|
309
309
|
* where violation results in error.
|