react-native-screens 4.7.0-beta.4 → 4.8.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.
@@ -130,7 +130,8 @@ android {
130
130
  externalNativeBuild {
131
131
  cmake {
132
132
  arguments "-DANDROID_STL=c++_shared",
133
- "-DRNS_NEW_ARCH_ENABLED=${IS_NEW_ARCHITECTURE_ENABLED}"
133
+ "-DRNS_NEW_ARCH_ENABLED=${IS_NEW_ARCHITECTURE_ENABLED}",
134
+ "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
134
135
  }
135
136
  }
136
137
  }
@@ -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
  }
@@ -17,6 +17,7 @@ add_compile_options(
17
17
  -Wall
18
18
  -Wpedantic
19
19
  -Wno-gnu-zero-variadic-macro-arguments
20
+ -Wno-dollar-in-identifier-extension
20
21
  )
21
22
 
22
23
  file(GLOB LIB_CUSTOM_SRCS CONFIGURE_DEPENDS *.cpp ${LIB_COMMON_COMPONENTS_DIR}/*.cpp ${LIB_COMMON_COMPONENTS_DIR}/utils/*.cpp)
@@ -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,
@@ -32,12 +32,11 @@ class RNSScreenStackHeaderSubviewComponentDescriptor final
32
32
 
33
33
  auto state = std::static_pointer_cast<
34
34
  const RNSScreenStackHeaderSubviewShadowNode::ConcreteState>(
35
- shadowNode.getState());
35
+ shadowNode.getMostRecentState());
36
36
  auto stateData = state->getData();
37
37
 
38
- if (stateData.frameSize.width != 0 && stateData.frameSize.height != 0) {
39
- layoutableShadowNode.setSize(
40
- Size{stateData.frameSize.width, stateData.frameSize.height});
38
+ if (!isSizeEmpty(stateData.frameSize)) {
39
+ layoutableShadowNode.setSize(stateData.frameSize);
41
40
  }
42
41
 
43
42
  ConcreteComponentDescriptor::adopt(shadowNode);
@@ -44,7 +44,7 @@ class JSI_EXPORT RNSScreenStackHeaderSubviewState final {
44
44
 
45
45
  #endif // ANDROID
46
46
 
47
- const Size frameSize{};
47
+ const Size frameSize{-1.f, -1.f};
48
48
  Point contentOffset{};
49
49
 
50
50
  #pragma mark - Getters
@@ -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-beta.4",
3
+ "version": "4.8.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.