From 00445828b8f0add9e99e581239bac06ca6185042 Mon Sep 17 00:00:00 2001 From: Dawid Date: Tue, 29 Oct 2024 14:34:56 +0100 Subject: [PATCH 01/26] remove header offset from RNSScreenStackHeaderConfigShadowNode --- .../components/rnscreens/RNSScreenShadowNode.cpp | 12 +++++++++++- .../RNSScreenStackHeaderConfigShadowNode.cpp | 10 ++++++++++ .../rnscreens/RNSScreenStackHeaderConfigShadowNode.h | 2 ++ .../rnscreens/RNSScreenStackHeaderConfigState.cpp | 5 +++++ .../rnscreens/RNSScreenStackHeaderConfigState.h | 7 +++++-- ios/RNSScreenStack.mm | 1 + ios/RNSScreenStackHeaderConfig.mm | 4 ++-- 7 files changed, 36 insertions(+), 5 deletions(-) diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp index 506babc08b..b3ccebdddb 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp @@ -1,4 +1,5 @@ #include "RNSScreenShadowNode.h" +#include "RNSScreenStackHeaderConfigShadowNode.h" namespace facebook { namespace react { @@ -118,7 +119,16 @@ void RNSScreenShadowNode::appendChild(const ShadowNode::Shared &child) { void RNSScreenShadowNode::layout(facebook::react::LayoutContext layoutContext) { YogaLayoutableShadowNode::layout(layoutContext); - + + auto headerConfigChildOpt = findHeaderConfigChild(*this); + if (headerConfigChildOpt) { + auto headerConfigChildConst = std::dynamic_pointer_cast(headerConfigChildOpt->get()); + auto headerConfigChild = std::const_pointer_cast(headerConfigChildConst); + auto stateData = getStateData(); + auto contentOffset = stateData.contentOffset; + headerConfigChild->layoutMetrics_.frame.origin.y = -contentOffset.y; + } + #ifdef ANDROID applyFrameCorrections(); #endif // ANDROID diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp index c13cc3a02f..01629d369e 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp @@ -4,5 +4,15 @@ namespace facebook::react { extern const char RNSScreenStackHeaderConfigComponentName[] = "RNSScreenStackHeaderConfig"; +} +namespace facebook { + namespace react { + Point RNSScreenStackHeaderConfigShadowNode::getContentOriginOffset( + bool /*includeTransform*/) const { + auto stateData = getStateData(); + auto topInsetOffset = stateData.getPaddingTop(); + return {0, topInsetOffset}; + } + } } diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.h index bdbe3ec11f..535d3e04a0 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.h @@ -26,6 +26,8 @@ class JSI_EXPORT RNSScreenStackHeaderConfigShadowNode final #pragma mark - ShadowNode overrides + Point getContentOriginOffset(bool includeTransform) const override; + #pragma mark - Custom interface }; diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.cpp index 49422783e5..0b33f85c80 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.cpp +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.cpp @@ -1,3 +1,4 @@ + #include "RNSScreenStackHeaderConfigState.h" namespace facebook { @@ -19,5 +20,9 @@ Float RNSScreenStackHeaderConfigState::getPaddingEnd() const noexcept { return paddingEnd_; } +Float RNSScreenStackHeaderConfigState::getPaddingTop() const noexcept { + return paddingTop_; +} + } // namespace react } // namespace facebook diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h index c1738b177a..1770e66bf4 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h @@ -17,8 +17,8 @@ class JSI_EXPORT RNSScreenStackHeaderConfigState final { RNSScreenStackHeaderConfigState() = default; - RNSScreenStackHeaderConfigState(Float paddingStart, Float paddingEnd) - : paddingStart_{paddingStart}, paddingEnd_{paddingEnd} {} + RNSScreenStackHeaderConfigState(Float paddingStart, Float paddingEnd, Float paddingTop) + : paddingStart_{paddingStart}, paddingEnd_{paddingEnd}, paddingTop_{paddingTop} {} #ifdef ANDROID RNSScreenStackHeaderConfigState( @@ -41,10 +41,13 @@ class JSI_EXPORT RNSScreenStackHeaderConfigState final { [[nodiscard]] Float getPaddingStart() const noexcept; [[nodiscard]] Float getPaddingEnd() const noexcept; + + [[nodiscard]] Float getPaddingTop() const noexcept; private: Float paddingStart_{0.f}; Float paddingEnd_{0.f}; + Float paddingTop_{0.f}; }; } // namespace facebook::react diff --git a/ios/RNSScreenStack.mm b/ios/RNSScreenStack.mm index dacdc5f355..beb116eac8 100644 --- a/ios/RNSScreenStack.mm +++ b/ios/RNSScreenStack.mm @@ -124,6 +124,7 @@ - (void)maybeUpdateHeaderInsetsInShadowTreeForScreen:(RNSScreen *)screenControll .leading = navBarMargins.leading + navBarContentMargins.leading + (isDisplayingBackButton ? platformBackButtonWidth : 0), .trailing = navBarMargins.trailing + navBarContentMargins.trailing, + .top = self.navigationBar.frame.origin.y }]; } #endif diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index 63cb4efd91..659f5439db 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -187,9 +187,9 @@ - (void)layoutNavigationControllerView - (void)updateHeaderInsetsInShadowTreeTo:(NSDirectionalEdgeInsets)insets { - if (_lastHeaderInsets.leading != insets.leading || _lastHeaderInsets.trailing != insets.trailing) { + if (_lastHeaderInsets.leading != insets.leading || _lastHeaderInsets.trailing != insets.trailing || _lastHeaderInsets.top != insets.top) { #ifdef RCT_NEW_ARCH_ENABLED - auto newState = react::RNSScreenStackHeaderConfigState{insets.leading, insets.trailing}; + auto newState = react::RNSScreenStackHeaderConfigState{insets.leading, insets.trailing, insets.top}; _state->updateState(std::move(newState)); _lastHeaderInsets = std::move(insets); #else From fa6ba8ce883bbef81104f1184fc81d85590e5ffe Mon Sep 17 00:00:00 2001 From: Dawid Date: Tue, 29 Oct 2024 14:56:56 +0100 Subject: [PATCH 02/26] remove top: '-100%' from ScreenStackHeaderConfig --- src/components/ScreenStackHeaderConfig.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/ScreenStackHeaderConfig.tsx b/src/components/ScreenStackHeaderConfig.tsx index f9f4440049..0f85cff610 100644 --- a/src/components/ScreenStackHeaderConfig.tsx +++ b/src/components/ScreenStackHeaderConfig.tsx @@ -102,7 +102,6 @@ const styles = StyleSheet.create({ }, headerConfig: { position: 'absolute', - top: '-100%', width: '100%', flexDirection: 'row', justifyContent: 'space-between', From 47212d40e9d0e2137bfe5a1a3ec6fee958352207 Mon Sep 17 00:00:00 2001 From: Dawid Date: Tue, 29 Oct 2024 15:09:42 +0100 Subject: [PATCH 03/26] rename topInsetOffset to paddingTop in RNSScreenStackHeaderConfigShadowNode --- .../rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp index 01629d369e..c1b9bad40a 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp @@ -11,8 +11,8 @@ namespace facebook { Point RNSScreenStackHeaderConfigShadowNode::getContentOriginOffset( bool /*includeTransform*/) const { auto stateData = getStateData(); - auto topInsetOffset = stateData.getPaddingTop(); - return {0, topInsetOffset}; + auto paddingTop = stateData.getPaddingTop(); + return {0, paddingTop}; } } } From 0d80a8566191e8462037647bee78bf97217d5394 Mon Sep 17 00:00:00 2001 From: Dawid Date: Wed, 13 Nov 2024 14:55:47 +0100 Subject: [PATCH 04/26] header config frame --- .../FabricEnabledHeaderConfigViewGroup.kt | 22 +++++++++++++++---- .../com/swmansion/rnscreens/CustomToolbar.kt | 4 +++- ...reenStackHeaderConfigComponentDescriptor.h | 4 ++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt b/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt index cf1a2aa387..df8107fb2f 100644 --- a/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt +++ b/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt @@ -16,41 +16,55 @@ abstract class FabricEnabledHeaderConfigViewGroup( private var lastPaddingStart = 0f private var lastPaddingEnd = 0f + private var lastWidth = 0f + private var lastHeight = 0f fun setStateWrapper(wrapper: StateWrapper?) { mStateWrapper = wrapper } - fun updatePaddingsFabric( + fun updateHeaderConfigState( paddingStart: Int, paddingEnd: Int, + width: Int, + height: Int, ) { - updateState(paddingStart, paddingEnd) + updateState(paddingStart, paddingEnd, width, height) } @UiThread fun updateState( paddingStart: Int, paddingEnd: Int, + width: Int, + height: Int, ) { val paddingStartDip: Float = PixelUtil.toDIPFromPixel(paddingStart.toFloat()) val paddingEndDip: Float = PixelUtil.toDIPFromPixel(paddingEnd.toFloat()) + val realWidth: Float = PixelUtil.toDIPFromPixel(width.toFloat()) + val realHeight: Float = PixelUtil.toDIPFromPixel(height.toFloat()) // Check incoming state values. If they're already the correct value, return early to prevent // infinite UpdateState/SetState loop. - if (abs(lastPaddingStart - paddingStart) < DELTA && - abs(lastPaddingEnd - paddingEnd) < DELTA + if (abs(lastPaddingStart - paddingStartDip) < DELTA && + abs(lastPaddingEnd - paddingEndDip) < DELTA && + abs(lastWidth - realWidth) < DELTA && + abs(lastHeight - realHeight) < DELTA ) { return } lastPaddingStart = paddingStartDip lastPaddingEnd = paddingEndDip + lastWidth = realWidth + lastHeight = realHeight val map: WritableMap = WritableNativeMap().apply { putDouble("paddingStart", paddingStartDip.toDouble()) putDouble("paddingEnd", paddingEndDip.toDouble()) + putDouble("frameWidth", realWidth.toDouble()) + putDouble("frameHeight", realHeight.toDouble()) } mStateWrapper?.updateState(map) } diff --git a/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt b/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt index d581cd6ed7..79357bd005 100644 --- a/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt +++ b/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt @@ -67,9 +67,11 @@ open class CustomToolbar( b: Int, ) { super.onLayout(changed, l, t, r, b) + val width = r - l; + val height = b - t; // our children are already laid out val contentInsetStart = if (navigationIcon != null) contentInsetStartWithNavigation else contentInsetStart - config.updatePaddingsFabric(contentInsetStart, contentInsetEnd) + config.updateHeaderConfigState(contentInsetStart, contentInsetEnd, width, height) } } diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigComponentDescriptor.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigComponentDescriptor.h index 3cf734c8fd..66b134693e 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigComponentDescriptor.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigComponentDescriptor.h @@ -37,6 +37,10 @@ class RNSScreenStackHeaderConfigComponentDescriptor final layoutableShadowNode.setPadding( {stateData.getPaddingStart(), 0, stateData.getPaddingEnd(), 0}); + if (stateData.frameSize.width != 0 && stateData.frameSize.height != 0) { + layoutableShadowNode.setSize(Size{stateData.frameSize.width, stateData.frameSize.height}); + } + ConcreteComponentDescriptor::adopt(shadowNode); } }; From 8047046c6b2e0d4ff95ee3563a97a4cd04fe54dd Mon Sep 17 00:00:00 2001 From: Dawid Date: Wed, 13 Nov 2024 15:30:14 +0100 Subject: [PATCH 05/26] header config state --- .../rnscreens/RNSScreenStackHeaderConfigState.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h index 1770e66bf4..9130587826 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h @@ -24,8 +24,11 @@ class JSI_EXPORT RNSScreenStackHeaderConfigState final { RNSScreenStackHeaderConfigState( RNSScreenStackHeaderConfigState const &previousState, folly::dynamic data) - : paddingStart_{static_cast(data["paddingStart"].getDouble())}, - paddingEnd_{static_cast(data["paddingEnd"].getDouble())} {} + : frameSize(Size{ + (Float)data["frameWidth"].getDouble(), + (Float)data["frameHeight"].getDouble()}), + paddingStart_{static_cast(data["paddingStart"].getDouble())}, + paddingEnd_{static_cast(data["paddingEnd"].getDouble())} {} #endif #ifdef ANDROID @@ -36,6 +39,8 @@ class JSI_EXPORT RNSScreenStackHeaderConfigState final { #endif + const Size frameSize{}; + #pragma mark - Getters [[nodiscard]] Float getPaddingStart() const noexcept; From 76681bbabdbd3efa16d7c41b665a902616c8c10c Mon Sep 17 00:00:00 2001 From: Dawid Date: Wed, 13 Nov 2024 15:35:36 +0100 Subject: [PATCH 06/26] header subview frame size update --- .../FabricEnabledHeaderSubviewGroup.kt | 40 +++++++++++++++++++ .../rnscreens/ScreenStackHeaderSubview.kt | 18 ++++++--- .../ScreenStackHeaderSubviewManager.kt | 13 ++++++ ...eenStackHeaderSubviewComponentDescriptor.h | 19 +++++++++ .../RNSScreenStackHeaderSubviewState.h | 7 +++- 5 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt diff --git a/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt b/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt new file mode 100644 index 0000000000..450a0d65c6 --- /dev/null +++ b/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt @@ -0,0 +1,40 @@ +package com.swmansion.rnscreens + +import android.content.Context +import android.view.ViewGroup +import androidx.annotation.UiThread +import com.facebook.react.bridge.WritableMap +import com.facebook.react.bridge.WritableNativeMap +import com.facebook.react.uimanager.StateWrapper +import com.facebook.react.uimanager.PixelUtil + +abstract class FabricEnabledHeaderSubviewGroup(context: Context?): ViewGroup(context) { + private var mStateWrapper: StateWrapper? = null + + fun setStateWrapper(wrapper: StateWrapper?) { + mStateWrapper = wrapper + } + + fun updateSubviewFrameState( + width: Int, + height: Int + ) { + updateState(width, height) + } + + @UiThread + fun updateState( + width: Int, + height: Int + ) { + val realWidth: Float = PixelUtil.toDIPFromPixel(width.toFloat()) + val realHeight: Float = PixelUtil.toDIPFromPixel(height.toFloat()) + val map: WritableMap = WritableNativeMap().apply { + putDouble("frameWidth", realWidth.toDouble()) + putDouble("frameHeight", realHeight.toDouble()) + } + + mStateWrapper?.updateState(map) + } + +} \ No newline at end of file diff --git a/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubview.kt b/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubview.kt index b7d6afc8af..2a81a32e06 100644 --- a/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubview.kt +++ b/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubview.kt @@ -8,7 +8,7 @@ import com.facebook.react.views.view.ReactViewGroup @SuppressLint("ViewConstructor") class ScreenStackHeaderSubview( context: ReactContext?, -) : ReactViewGroup(context) { +) : FabricEnabledHeaderSubviewGroup(context) { private var reactWidth = 0 private var reactHeight = 0 var type = Type.RIGHT @@ -37,11 +37,17 @@ class ScreenStackHeaderSubview( override fun onLayout( changed: Boolean, - left: Int, - top: Int, - right: Int, - bottom: Int, - ) = Unit + l: Int, + t: Int, + r: Int, + b: Int, + ) { + if (changed && BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { + val width = r - l; + val height = b - t; + updateSubviewFrameState(width, height) + } + } enum class Type { LEFT, diff --git a/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubviewManager.kt b/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubviewManager.kt index ab781a880e..68c0e1ef04 100644 --- a/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubviewManager.kt +++ b/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubviewManager.kt @@ -2,6 +2,8 @@ package com.swmansion.rnscreens import com.facebook.react.bridge.JSApplicationIllegalArgumentException import com.facebook.react.module.annotations.ReactModule +import com.facebook.react.uimanager.ReactStylesDiffMap +import com.facebook.react.uimanager.StateWrapper import com.facebook.react.uimanager.ThemedReactContext import com.facebook.react.uimanager.ViewGroupManager import com.facebook.react.uimanager.ViewManagerDelegate @@ -39,6 +41,17 @@ class ScreenStackHeaderSubviewManager : } } + override fun updateState( + view: ScreenStackHeaderSubview, + props: ReactStylesDiffMap?, + stateWrapper: StateWrapper? + ): Any? { + if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { + view.setStateWrapper(stateWrapper) + } + return super.updateState(view, props, stateWrapper) + } + protected override fun getDelegate(): ViewManagerDelegate = delegate companion object { diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewComponentDescriptor.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewComponentDescriptor.h index 2228c1170a..c1eeeb8042 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewComponentDescriptor.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewComponentDescriptor.h @@ -20,6 +20,25 @@ class RNSScreenStackHeaderSubviewComponentDescriptor final using ConcreteComponentDescriptor::ConcreteComponentDescriptor; void adopt(ShadowNode &shadowNode) const override { + react_native_assert( + dynamic_cast(&shadowNode)); + auto &subviewShadowNode = + static_cast(shadowNode); + + react_native_assert( + dynamic_cast(&subviewShadowNode)); + auto &layoutableShadowNode = + dynamic_cast(subviewShadowNode); + + auto state = std::static_pointer_cast< + const RNSScreenStackHeaderSubviewShadowNode::ConcreteState>( + shadowNode.getState()); + auto stateData = state->getData(); + + if (stateData.frameSize.width != 0 && stateData.frameSize.height != 0) { + layoutableShadowNode.setSize(Size{stateData.frameSize.width, stateData.frameSize.height}); + } + ConcreteComponentDescriptor::adopt(shadowNode); } }; diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.h index 32fdae2694..08a9a3656c 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.h @@ -24,7 +24,10 @@ class JSI_EXPORT RNSScreenStackHeaderSubviewState final { #ifdef ANDROID RNSScreenStackHeaderSubviewState( RNSScreenStackHeaderSubviewState const &previousState, - folly::dynamic data) {} + folly::dynamic data) + : frameSize(Size{ + (Float)data["frameWidth"].getDouble(), + (Float)data["frameHeight"].getDouble()}) {} #endif #ifdef ANDROID @@ -34,6 +37,8 @@ class JSI_EXPORT RNSScreenStackHeaderSubviewState final { }; #endif + const Size frameSize{}; + #pragma mark - Getters }; From 92b899a98502e862d1e7a0440af8543a0eb9b055 Mon Sep 17 00:00:00 2001 From: Dawid Date: Thu, 14 Nov 2024 12:20:27 +0100 Subject: [PATCH 07/26] header subview frame corrections --- .../FabricEnabledHeaderSubviewGroup.kt | 15 ++++++++++++--- .../rnscreens/ScreenStackHeaderSubview.kt | 2 +- .../RNSScreenStackHeaderSubviewShadowNode.cpp | 19 +++++++++++++++++++ .../RNSScreenStackHeaderSubviewShadowNode.h | 5 +++++ .../RNSScreenStackHeaderSubviewState.h | 6 +++++- 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt b/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt index 450a0d65c6..926a36ba47 100644 --- a/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt +++ b/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt @@ -17,21 +17,30 @@ abstract class FabricEnabledHeaderSubviewGroup(context: Context?): ViewGroup(con fun updateSubviewFrameState( width: Int, - height: Int + height: Int, + offsetX: Int, + offsetY: Int ) { - updateState(width, height) + updateState(width, height, offsetX, offsetY) } @UiThread fun updateState( width: Int, - height: Int + height: Int, + offsetX: Int, + offsetY: Int ) { val realWidth: Float = PixelUtil.toDIPFromPixel(width.toFloat()) val realHeight: Float = PixelUtil.toDIPFromPixel(height.toFloat()) + val offsetXDip: Float = PixelUtil.toDIPFromPixel(offsetX.toFloat()) + val offsetYDip: Float = PixelUtil.toDIPFromPixel(offsetY.toFloat()) + val map: WritableMap = WritableNativeMap().apply { putDouble("frameWidth", realWidth.toDouble()) putDouble("frameHeight", realHeight.toDouble()) + putDouble("contentOffsetX", offsetXDip.toDouble()) + putDouble("contentOffsetY", offsetYDip.toDouble()) } mStateWrapper?.updateState(map) diff --git a/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubview.kt b/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubview.kt index 2a81a32e06..add6eea5aa 100644 --- a/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubview.kt +++ b/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubview.kt @@ -45,7 +45,7 @@ class ScreenStackHeaderSubview( if (changed && BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { val width = r - l; val height = b - t; - updateSubviewFrameState(width, height) + updateSubviewFrameState(width, height, l, t) } } diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.cpp index e0d6988e91..2e30c54d10 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.cpp +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.cpp @@ -1,8 +1,27 @@ #include "RNSScreenStackHeaderSubviewShadowNode.h" +#include namespace facebook::react { extern const char RNSScreenStackHeaderSubviewComponentName[] = "RNSScreenStackHeaderSubview"; +void RNSScreenStackHeaderSubviewShadowNode::layout(LayoutContext layoutContext) { + YogaLayoutableShadowNode::layout(layoutContext); + +#ifdef ANDROID + applyFrameCorrections(); +#endif // ANDROID +} + +#ifdef ANDROID +void RNSScreenStackHeaderSubviewShadowNode::applyFrameCorrections() { + ensureUnsealed(); + + const auto &stateData = getStateData(); + layoutMetrics_.frame.origin.x = stateData.contentOffset.x; + layoutMetrics_.frame.origin.y = stateData.contentOffset.y; +} +#endif // ANDROID + } diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.h index e91cb63f73..c80d5b381f 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.h @@ -24,9 +24,14 @@ class JSI_EXPORT RNSScreenStackHeaderSubviewShadowNode final using ConcreteViewShadowNode::ConcreteViewShadowNode; using StateData = ConcreteViewShadowNode::ConcreteStateData; + void layout(LayoutContext layoutContext) override; + #pragma mark - ShadowNode overrides #pragma mark - Custom interface +#ifdef ANDROID + void applyFrameCorrections(); +#endif }; } // namespace facebook::react diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.h index 08a9a3656c..3e6de453b7 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.h @@ -27,7 +27,10 @@ class JSI_EXPORT RNSScreenStackHeaderSubviewState final { folly::dynamic data) : frameSize(Size{ (Float)data["frameWidth"].getDouble(), - (Float)data["frameHeight"].getDouble()}) {} + (Float)data["frameHeight"].getDouble()}), + contentOffset(Point{ + (Float)data["contentOffsetX"].getDouble(), + (Float)data["contentOffsetY"].getDouble()}) {} #endif #ifdef ANDROID @@ -38,6 +41,7 @@ class JSI_EXPORT RNSScreenStackHeaderSubviewState final { #endif const Size frameSize{}; + Point contentOffset; #pragma mark - Getters }; From cfb237eb8580cc14a7a13daa927e5a8a5a01f1a2 Mon Sep 17 00:00:00 2001 From: Dawid Date: Thu, 14 Nov 2024 13:01:22 +0100 Subject: [PATCH 08/26] remove unused import --- .../rnscreens/RNSScreenStackHeaderSubviewShadowNode.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.cpp index 2e30c54d10..52c1d4d415 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.cpp +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.cpp @@ -1,5 +1,4 @@ #include "RNSScreenStackHeaderSubviewShadowNode.h" -#include namespace facebook::react { From 83fb6f4ef11c734987e4a7076f42d4df2de1bc5d Mon Sep 17 00:00:00 2001 From: Dawid Date: Fri, 15 Nov 2024 12:35:28 +0100 Subject: [PATCH 09/26] flattened header subviews --- ios/RNSScreenStackHeaderConfig.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index 3614f2edb8..cb1cafa80f 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -134,10 +134,15 @@ - (void)removeFromSuperview - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { for (RNSScreenStackHeaderSubview *subview in _reactSubviews) { + if (subview.type == RNSScreenStackHeaderSubviewTypeLeft || subview.type == RNSScreenStackHeaderSubviewTypeRight) { + // we wrap the headerLeft/Right component in a UIBarButtonItem // so we need to use the only subview of it to retrieve the correct view - UIView *headerComponent = subview.subviews.firstObject; + UIView *headerComponent = subview.subviews.count > 1 ? + headerComponent = subview.subviews[subview.subviews.count - 1] : + subview.subviews.firstObject; + // we convert the point to RNSScreenStackView since it always contains the header inside it CGPoint convertedPoint = [_screenView.reactSuperview convertPoint:point toView:headerComponent]; From 5d6716d20f4eda022bbe3008406f28943a2dfd21 Mon Sep 17 00:00:00 2001 From: Dawid Date: Fri, 15 Nov 2024 17:13:06 +0100 Subject: [PATCH 10/26] iOS frame metrics --- ...reenStackHeaderConfigComponentDescriptor.h | 2 -- .../RNSScreenStackHeaderConfigShadowNode.cpp | 21 +++++++------ .../RNSScreenStackHeaderConfigShadowNode.h | 4 +-- .../RNSScreenStackHeaderConfigState.cpp | 14 --------- .../RNSScreenStackHeaderConfigState.h | 21 ++++--------- .../RNSScreenStackHeaderSubviewShadowNode.cpp | 5 --- .../RNSScreenStackHeaderSubviewShadowNode.h | 7 ++--- .../RNSScreenStackHeaderSubviewState.h | 9 ++++-- ios/RNSScreenStack.mm | 17 +--------- ios/RNSScreenStackHeaderConfig.h | 3 +- ios/RNSScreenStackHeaderConfig.mm | 21 +++++++------ ios/RNSScreenStackHeaderSubview.mm | 31 ++++++++++++++++++- 12 files changed, 72 insertions(+), 83 deletions(-) diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigComponentDescriptor.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigComponentDescriptor.h index 66b134693e..f5c5977ed3 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigComponentDescriptor.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigComponentDescriptor.h @@ -34,8 +34,6 @@ class RNSScreenStackHeaderConfigComponentDescriptor final shadowNode.getState()); auto stateData = state->getData(); - layoutableShadowNode.setPadding( - {stateData.getPaddingStart(), 0, stateData.getPaddingEnd(), 0}); if (stateData.frameSize.width != 0 && stateData.frameSize.height != 0) { layoutableShadowNode.setSize(Size{stateData.frameSize.width, stateData.frameSize.height}); diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp index c1b9bad40a..1e176f9603 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp @@ -4,15 +4,18 @@ namespace facebook::react { extern const char RNSScreenStackHeaderConfigComponentName[] = "RNSScreenStackHeaderConfig"; + +void RNSScreenStackHeaderConfigShadowNode::layout(LayoutContext layoutContext) { + YogaLayoutableShadowNode::layout(layoutContext); + applyFrameCorrections(); +} + +void RNSScreenStackHeaderConfigShadowNode::applyFrameCorrections() { + ensureUnsealed(); + + const auto &stateData = getStateData(); + layoutMetrics_.frame.origin.x = stateData.contentOffset.x; + layoutMetrics_.frame.origin.y = stateData.contentOffset.y; } -namespace facebook { - namespace react { - Point RNSScreenStackHeaderConfigShadowNode::getContentOriginOffset( - bool /*includeTransform*/) const { - auto stateData = getStateData(); - auto paddingTop = stateData.getPaddingTop(); - return {0, paddingTop}; - } - } } diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.h index 535d3e04a0..b053ea9f32 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.h @@ -25,10 +25,10 @@ class JSI_EXPORT RNSScreenStackHeaderConfigShadowNode final using StateData = ConcreteViewShadowNode::ConcreteStateData; #pragma mark - ShadowNode overrides - - Point getContentOriginOffset(bool includeTransform) const override; + void layout(LayoutContext layoutContext) override; #pragma mark - Custom interface + void applyFrameCorrections(); }; } // namespace facebook::react diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.cpp index 0b33f85c80..de31f14773 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.cpp +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.cpp @@ -9,20 +9,6 @@ folly::dynamic RNSScreenStackHeaderConfigState::getDynamic() const { return folly::dynamic::object("paddingStart", paddingStart_)( "paddingEnd_", paddingEnd_); } - #endif - -Float RNSScreenStackHeaderConfigState::getPaddingStart() const noexcept { - return paddingStart_; -} - -Float RNSScreenStackHeaderConfigState::getPaddingEnd() const noexcept { - return paddingEnd_; -} - -Float RNSScreenStackHeaderConfigState::getPaddingTop() const noexcept { - return paddingTop_; -} - } // namespace react } // namespace facebook diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h index 9130587826..21d1cb3ff8 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h @@ -17,8 +17,8 @@ class JSI_EXPORT RNSScreenStackHeaderConfigState final { RNSScreenStackHeaderConfigState() = default; - RNSScreenStackHeaderConfigState(Float paddingStart, Float paddingEnd, Float paddingTop) - : paddingStart_{paddingStart}, paddingEnd_{paddingEnd}, paddingTop_{paddingTop} {} + RNSScreenStackHeaderConfigState(Size frameSize_, Point contentOffset_) + : frameSize(frameSize_), contentOffset(contentOffset_) {} #ifdef ANDROID RNSScreenStackHeaderConfigState( @@ -27,8 +27,9 @@ class JSI_EXPORT RNSScreenStackHeaderConfigState final { : frameSize(Size{ (Float)data["frameWidth"].getDouble(), (Float)data["frameHeight"].getDouble()}), - paddingStart_{static_cast(data["paddingStart"].getDouble())}, - paddingEnd_{static_cast(data["paddingEnd"].getDouble())} {} + contentOffset(Point{ + (Float)data["contentOffsetX"].getDouble(), + (Float)data["contentOffsetY"].getDouble()}){} #endif #ifdef ANDROID @@ -40,19 +41,9 @@ class JSI_EXPORT RNSScreenStackHeaderConfigState final { #endif const Size frameSize{}; + Point contentOffset; #pragma mark - Getters - - [[nodiscard]] Float getPaddingStart() const noexcept; - - [[nodiscard]] Float getPaddingEnd() const noexcept; - - [[nodiscard]] Float getPaddingTop() const noexcept; - - private: - Float paddingStart_{0.f}; - Float paddingEnd_{0.f}; - Float paddingTop_{0.f}; }; } // namespace facebook::react diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.cpp index 52c1d4d415..4cd7e6a455 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.cpp +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.cpp @@ -7,13 +7,9 @@ extern const char RNSScreenStackHeaderSubviewComponentName[] = void RNSScreenStackHeaderSubviewShadowNode::layout(LayoutContext layoutContext) { YogaLayoutableShadowNode::layout(layoutContext); - -#ifdef ANDROID applyFrameCorrections(); -#endif // ANDROID } -#ifdef ANDROID void RNSScreenStackHeaderSubviewShadowNode::applyFrameCorrections() { ensureUnsealed(); @@ -21,6 +17,5 @@ void RNSScreenStackHeaderSubviewShadowNode::applyFrameCorrections() { layoutMetrics_.frame.origin.x = stateData.contentOffset.x; layoutMetrics_.frame.origin.y = stateData.contentOffset.y; } -#endif // ANDROID } diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.h index c80d5b381f..5e16ec54d3 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.h @@ -24,14 +24,11 @@ class JSI_EXPORT RNSScreenStackHeaderSubviewShadowNode final using ConcreteViewShadowNode::ConcreteViewShadowNode; using StateData = ConcreteViewShadowNode::ConcreteStateData; - void layout(LayoutContext layoutContext) override; - #pragma mark - ShadowNode overrides + void layout(LayoutContext layoutContext) override; #pragma mark - Custom interface -#ifdef ANDROID - void applyFrameCorrections(); -#endif + void applyFrameCorrections(); }; } // namespace facebook::react diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.h index 3e6de453b7..f37ee5c452 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.h @@ -20,6 +20,9 @@ class JSI_EXPORT RNSScreenStackHeaderSubviewState final { using Shared = std::shared_ptr; RNSScreenStackHeaderSubviewState() = default; + + RNSScreenStackHeaderSubviewState(Size frameSize_, Point contentOffset_) + : frameSize(frameSize_), contentOffset(contentOffset_){}; #ifdef ANDROID RNSScreenStackHeaderSubviewState( @@ -28,9 +31,9 @@ class JSI_EXPORT RNSScreenStackHeaderSubviewState final { : frameSize(Size{ (Float)data["frameWidth"].getDouble(), (Float)data["frameHeight"].getDouble()}), - contentOffset(Point{ - (Float)data["contentOffsetX"].getDouble(), - (Float)data["contentOffsetY"].getDouble()}) {} + contentOffset(Point{ + (Float)data["contentOffsetX"].getDouble(), + (Float)data["contentOffsetY"].getDouble()}) {} #endif #ifdef ANDROID diff --git a/ios/RNSScreenStack.mm b/ios/RNSScreenStack.mm index b8e4c4496b..f3e9c39164 100644 --- a/ios/RNSScreenStack.mm +++ b/ios/RNSScreenStack.mm @@ -111,22 +111,7 @@ - (void)maybeUpdateHeaderInsetsInShadowTreeForScreen:(RNSScreen *)screenControll return; } - NSDirectionalEdgeInsets navBarMargins = [self.navigationBar directionalLayoutMargins]; - NSDirectionalEdgeInsets navBarContentMargins = - [self.navigationBar.rnscreens_findContentView directionalLayoutMargins]; - - BOOL isDisplayingBackButton = [headerConfig shouldBackButtonBeVisibleInNavigationBar:self.navigationBar]; - - // 44.0 is just "closed eyes default". It is so on device I've tested with, nothing more. - UIView *barButtonView = isDisplayingBackButton ? self.navigationBar.rnscreens_findBackButtonWrapperView : nil; - CGFloat platformBackButtonWidth = barButtonView != nil ? barButtonView.frame.size.width : 44.0f; - - [headerConfig updateHeaderInsetsInShadowTreeTo:NSDirectionalEdgeInsets{ - .leading = navBarMargins.leading + navBarContentMargins.leading + - (isDisplayingBackButton ? platformBackButtonWidth : 0), - .trailing = navBarMargins.trailing + navBarContentMargins.trailing, - .top = self.navigationBar.frame.origin.y - }]; + [headerConfig updateHeaderConfigState:self.navigationBar.frame.size :self.navigationBar.frame.origin]; } #endif diff --git a/ios/RNSScreenStackHeaderConfig.h b/ios/RNSScreenStackHeaderConfig.h index b9d33831d3..b6d369c2a2 100644 --- a/ios/RNSScreenStackHeaderConfig.h +++ b/ios/RNSScreenStackHeaderConfig.h @@ -64,9 +64,8 @@ /** * Allows to send information with insets to the corresponding node in shadow tree. - * Currently only horizontal insets are send through. Vertical ones are filtered out. */ -- (void)updateHeaderInsetsInShadowTreeTo:(NSDirectionalEdgeInsets)insets; +- (void)updateHeaderConfigState:(CGSize)size :(CGPoint)origin; /** * Returns true iff subview of given `type` is present. diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index cb1cafa80f..6e096be9e7 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -191,19 +191,22 @@ - (void)layoutNavigationControllerView [navctr.view setNeedsLayout]; } -- (void)updateHeaderInsetsInShadowTreeTo:(NSDirectionalEdgeInsets)insets -{ - if (_lastHeaderInsets.leading != insets.leading || _lastHeaderInsets.trailing != insets.trailing || _lastHeaderInsets.top != insets.top) { + #ifdef RCT_NEW_ARCH_ENABLED - auto newState = react::RNSScreenStackHeaderConfigState{insets.leading, insets.trailing, insets.top}; +- (void)updateHeaderConfigState:(CGSize)size :(CGPoint)origin +{ + auto newState = react::RNSScreenStackHeaderConfigState(RCTSizeFromCGSize(size), RCTPointFromCGPoint(origin)); _state->updateState(std::move(newState)); - _lastHeaderInsets = std::move(insets); +} #else - [_bridge.uiManager setLocalData:[[RNSHeaderConfigInsetsPayload alloc] initWithInsets:insets] forView:self]; - _lastHeaderInsets = std::move(insets); -#endif // RCT_NEW_ARCH_ENABLED - } +- (void)updateHeaderConfigState:(NSDirectionalEdgeInsets)insets +{ + if (_lastHeaderInsets.leading != insets.leading || _lastHeaderInsets.trailing != insets.trailing || _lastHeaderInsets.top != insets.top) { + [_bridge.uiManager setLocalData:[[RNSHeaderConfigInsetsPayload alloc] initWithInsets:insets] forView:self]; + _lastHeaderInsets = std::move(insets); + } } +#endif // RCT_NEW_ARCH_ENABLED - (BOOL)hasSubviewOfType:(RNSScreenStackHeaderSubviewType)type { diff --git a/ios/RNSScreenStackHeaderSubview.mm b/ios/RNSScreenStackHeaderSubview.mm index d5756fb54e..8cb7eeae8a 100644 --- a/ios/RNSScreenStackHeaderSubview.mm +++ b/ios/RNSScreenStackHeaderSubview.mm @@ -21,7 +21,11 @@ @interface RCTBridge (Private) + (RCTBridge *)currentBridge; @end -@implementation RNSScreenStackHeaderSubview +@implementation RNSScreenStackHeaderSubview { +#ifdef RCT_NEW_ARCH_ENABLED + react::RNSScreenStackHeaderSubviewShadowNode::ConcreteState::Shared _state; +#endif +} #pragma mark - Common @@ -111,6 +115,31 @@ + (BOOL)shouldBeRecycled return NO; } +- (void)layoutSubviews +{ + [super layoutSubviews]; + RNSScreenStackHeaderConfig *headerConfig = [self getHeaderConfig]; + + if (headerConfig) { + CGRect frameInHeaderConfig = [self convertRect:self.frame toView:headerConfig]; + [self updateHeaderSubviewFrame:frameInHeaderConfig.size :frameInHeaderConfig.origin]; + } +} + +- (void)updateState:(const facebook::react::State::Shared &)state + oldState:(const facebook::react::State::Shared &)oldState +{ + _state = std::static_pointer_cast(state); +} + +- (void)updateHeaderSubviewFrame:(CGSize)size :(CGPoint)origin +{ + if (_state != nullptr) { + auto newState = react::RNSScreenStackHeaderSubviewState(RCTSizeFromCGSize(size), RCTPointFromCGPoint(origin)); + _state->updateState(std::move(newState)); + } +} + #else #pragma mark - Paper specific From b3ebaf56aa3009a7c8247b33b1993d4bf1b821ef Mon Sep 17 00:00:00 2001 From: Dawid Date: Tue, 19 Nov 2024 09:33:23 +0100 Subject: [PATCH 11/26] flattening --- ios/RNSScreenStackHeaderConfig.mm | 4 +--- src/components/ScreenStackHeaderConfig.tsx | 12 ++++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index 6e096be9e7..fb98bcd6ce 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -139,9 +139,7 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event // we wrap the headerLeft/Right component in a UIBarButtonItem // so we need to use the only subview of it to retrieve the correct view - UIView *headerComponent = subview.subviews.count > 1 ? - headerComponent = subview.subviews[subview.subviews.count - 1] : - subview.subviews.firstObject; + UIView *headerComponent = subview.subviews.firstObject; // we convert the point to RNSScreenStackView since it always contains the header inside it CGPoint convertedPoint = [_screenView.reactSuperview convertPoint:point toView:headerComponent]; diff --git a/src/components/ScreenStackHeaderConfig.tsx b/src/components/ScreenStackHeaderConfig.tsx index 8ce5c0bdcf..4a11eac9c2 100644 --- a/src/components/ScreenStackHeaderConfig.tsx +++ b/src/components/ScreenStackHeaderConfig.tsx @@ -55,7 +55,11 @@ export const ScreenStackHeaderRightView = ( {...rest} type="right" style={[styles.headerSubview, style]} - /> + > + + {props.children} + + ); }; @@ -69,7 +73,11 @@ export const ScreenStackHeaderLeftView = ( {...rest} type="left" style={[styles.headerSubview, style]} - /> + > + + {props.children} + + ); }; From b9e01249f2a98fde04c5b2008695ff8761bc1828 Mon Sep 17 00:00:00 2001 From: Dawid Date: Tue, 19 Nov 2024 10:08:50 +0100 Subject: [PATCH 12/26] fix Android --- .../FabricEnabledHeaderConfigViewGroup.kt | 34 +++++++++---------- .../com/swmansion/rnscreens/CustomToolbar.kt | 2 +- .../RNSScreenStackHeaderConfigState.cpp | 5 +-- .../RNSScreenStackHeaderSubviewState.cpp | 4 ++- ios/RNSScreenStackHeaderConfig.mm | 4 ++- src/components/ScreenStackHeaderConfig.tsx | 12 ++----- 6 files changed, 29 insertions(+), 32 deletions(-) diff --git a/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt b/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt index df8107fb2f..34d9a0bb0f 100644 --- a/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt +++ b/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt @@ -14,57 +14,57 @@ abstract class FabricEnabledHeaderConfigViewGroup( ) : ViewGroup(context) { private var mStateWrapper: StateWrapper? = null - private var lastPaddingStart = 0f - private var lastPaddingEnd = 0f private var lastWidth = 0f private var lastHeight = 0f + private var lastOffsetX = 0f + private var lastOffsetY = 0f fun setStateWrapper(wrapper: StateWrapper?) { mStateWrapper = wrapper } fun updateHeaderConfigState( - paddingStart: Int, - paddingEnd: Int, width: Int, height: Int, + offsetX: Int, + offsetY: Int ) { - updateState(paddingStart, paddingEnd, width, height) + updateState(width, height, offsetX, offsetY) } @UiThread fun updateState( - paddingStart: Int, - paddingEnd: Int, width: Int, height: Int, + offsetX: Int, + offsetY: Int ) { - val paddingStartDip: Float = PixelUtil.toDIPFromPixel(paddingStart.toFloat()) - val paddingEndDip: Float = PixelUtil.toDIPFromPixel(paddingEnd.toFloat()) val realWidth: Float = PixelUtil.toDIPFromPixel(width.toFloat()) val realHeight: Float = PixelUtil.toDIPFromPixel(height.toFloat()) + val offsetXDip: Float = PixelUtil.toDIPFromPixel(offsetX.toFloat()) + val offsetYDip: Float = PixelUtil.toDIPFromPixel(offsetY.toFloat()) // Check incoming state values. If they're already the correct value, return early to prevent // infinite UpdateState/SetState loop. - if (abs(lastPaddingStart - paddingStartDip) < DELTA && - abs(lastPaddingEnd - paddingEndDip) < DELTA && - abs(lastWidth - realWidth) < DELTA && - abs(lastHeight - realHeight) < DELTA + if (abs(lastWidth - realWidth) < DELTA && + abs(lastHeight - realHeight) < DELTA && + abs(lastOffsetX - offsetXDip) < DELTA && + abs(lastOffsetY - offsetY) < DELTA ) { return } - lastPaddingStart = paddingStartDip - lastPaddingEnd = paddingEndDip lastWidth = realWidth lastHeight = realHeight + lastOffsetX = offsetXDip + lastOffsetY = offsetYDip val map: WritableMap = WritableNativeMap().apply { - putDouble("paddingStart", paddingStartDip.toDouble()) - putDouble("paddingEnd", paddingEndDip.toDouble()) putDouble("frameWidth", realWidth.toDouble()) putDouble("frameHeight", realHeight.toDouble()) + putDouble("contentOffsetX", offsetXDip.toDouble()) + putDouble("contentOffsetY", offsetYDip.toDouble()) } mStateWrapper?.updateState(map) } diff --git a/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt b/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt index 79357bd005..49ced96009 100644 --- a/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt +++ b/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt @@ -72,6 +72,6 @@ open class CustomToolbar( // our children are already laid out val contentInsetStart = if (navigationIcon != null) contentInsetStartWithNavigation else contentInsetStart - config.updateHeaderConfigState(contentInsetStart, contentInsetEnd, width, height) + config.updateHeaderConfigState(width, height, l, t) } } diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.cpp index de31f14773..a7a72fed64 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.cpp +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.cpp @@ -6,8 +6,9 @@ namespace react { #ifdef ANDROID folly::dynamic RNSScreenStackHeaderConfigState::getDynamic() const { - return folly::dynamic::object("paddingStart", paddingStart_)( - "paddingEnd_", paddingEnd_); + return folly::dynamic::object("frameWidth", frameSize.width)( + "frameHeight", frameSize.height)("contentOffsetX", contentOffset.x)( + "contentOffsetY", contentOffset.y); } #endif } // namespace react diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.cpp index a5019eb812..56eedd8ea1 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.cpp +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.cpp @@ -7,7 +7,9 @@ using namespace rnscreens; #ifdef ANDROID folly::dynamic RNSScreenStackHeaderSubviewState::getDynamic() const { - return folly::dynamic::object(); + return folly::dynamic::object("frameWidth", frameSize.width)( + "frameHeight", frameSize.height)("contentOffsetX", contentOffset.x)( + "contentOffsetY", contentOffset.y); } #endif diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index fb98bcd6ce..6e096be9e7 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -139,7 +139,9 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event // we wrap the headerLeft/Right component in a UIBarButtonItem // so we need to use the only subview of it to retrieve the correct view - UIView *headerComponent = subview.subviews.firstObject; + UIView *headerComponent = subview.subviews.count > 1 ? + headerComponent = subview.subviews[subview.subviews.count - 1] : + subview.subviews.firstObject; // we convert the point to RNSScreenStackView since it always contains the header inside it CGPoint convertedPoint = [_screenView.reactSuperview convertPoint:point toView:headerComponent]; diff --git a/src/components/ScreenStackHeaderConfig.tsx b/src/components/ScreenStackHeaderConfig.tsx index 4a11eac9c2..8ce5c0bdcf 100644 --- a/src/components/ScreenStackHeaderConfig.tsx +++ b/src/components/ScreenStackHeaderConfig.tsx @@ -55,11 +55,7 @@ export const ScreenStackHeaderRightView = ( {...rest} type="right" style={[styles.headerSubview, style]} - > - - {props.children} - - + /> ); }; @@ -73,11 +69,7 @@ export const ScreenStackHeaderLeftView = ( {...rest} type="left" style={[styles.headerSubview, style]} - > - - {props.children} - - + /> ); }; From aad021ae83a52fc963102003503785e955427575 Mon Sep 17 00:00:00 2001 From: Dawid Date: Tue, 19 Nov 2024 16:36:42 +0100 Subject: [PATCH 13/26] fix layout iOS subviews --- .../rnscreens/RNSScreenShadowNode.cpp | 20 +++++++++---------- ios/RNSScreenStackHeaderSubview.mm | 3 ++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp index b3ccebdddb..81c8d30e6b 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp @@ -119,16 +119,16 @@ void RNSScreenShadowNode::appendChild(const ShadowNode::Shared &child) { void RNSScreenShadowNode::layout(facebook::react::LayoutContext layoutContext) { YogaLayoutableShadowNode::layout(layoutContext); - - auto headerConfigChildOpt = findHeaderConfigChild(*this); - if (headerConfigChildOpt) { - auto headerConfigChildConst = std::dynamic_pointer_cast(headerConfigChildOpt->get()); - auto headerConfigChild = std::const_pointer_cast(headerConfigChildConst); - auto stateData = getStateData(); - auto contentOffset = stateData.contentOffset; - headerConfigChild->layoutMetrics_.frame.origin.y = -contentOffset.y; - } - + + auto headerConfigChildOpt = findHeaderConfigChild(*this); + if (headerConfigChildOpt) { + auto headerConfigChildConst = std::dynamic_pointer_cast(headerConfigChildOpt->get()); + auto headerConfigChild = std::const_pointer_cast(headerConfigChildConst); + auto stateData = getStateData(); + auto contentOffset = stateData.contentOffset; + headerConfigChild->layoutMetrics_.frame.origin.y = -contentOffset.y; + } + #ifdef ANDROID applyFrameCorrections(); #endif // ANDROID diff --git a/ios/RNSScreenStackHeaderSubview.mm b/ios/RNSScreenStackHeaderSubview.mm index 8cb7eeae8a..dad44f5802 100644 --- a/ios/RNSScreenStackHeaderSubview.mm +++ b/ios/RNSScreenStackHeaderSubview.mm @@ -121,7 +121,8 @@ - (void)layoutSubviews RNSScreenStackHeaderConfig *headerConfig = [self getHeaderConfig]; if (headerConfig) { - CGRect frameInHeaderConfig = [self convertRect:self.frame toView:headerConfig]; + UINavigationController *navctr = headerConfig.screenView.reactViewController.navigationController; + CGRect frameInHeaderConfig = [self convertRect:self.frame toView:navctr.view]; [self updateHeaderSubviewFrame:frameInHeaderConfig.size :frameInHeaderConfig.origin]; } } From 43ddcb29904ccd4de306d1211564988a61052fe5 Mon Sep 17 00:00:00 2001 From: Dawid Date: Tue, 26 Nov 2024 10:38:18 +0100 Subject: [PATCH 14/26] header config and subviews position --- .../components/rnscreens/RNSScreenShadowNode.cpp | 9 --------- .../RNSScreenStackHeaderConfigComponentDescriptor.h | 1 - .../rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp | 3 +-- ios/RNSScreenStackHeaderSubview.mm | 2 +- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp index 81c8d30e6b..6d84153335 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp @@ -119,15 +119,6 @@ void RNSScreenShadowNode::appendChild(const ShadowNode::Shared &child) { void RNSScreenShadowNode::layout(facebook::react::LayoutContext layoutContext) { YogaLayoutableShadowNode::layout(layoutContext); - - auto headerConfigChildOpt = findHeaderConfigChild(*this); - if (headerConfigChildOpt) { - auto headerConfigChildConst = std::dynamic_pointer_cast(headerConfigChildOpt->get()); - auto headerConfigChild = std::const_pointer_cast(headerConfigChildConst); - auto stateData = getStateData(); - auto contentOffset = stateData.contentOffset; - headerConfigChild->layoutMetrics_.frame.origin.y = -contentOffset.y; - } #ifdef ANDROID applyFrameCorrections(); diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigComponentDescriptor.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigComponentDescriptor.h index f5c5977ed3..09927bb28e 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigComponentDescriptor.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigComponentDescriptor.h @@ -34,7 +34,6 @@ class RNSScreenStackHeaderConfigComponentDescriptor final shadowNode.getState()); auto stateData = state->getData(); - if (stateData.frameSize.width != 0 && stateData.frameSize.height != 0) { layoutableShadowNode.setSize(Size{stateData.frameSize.width, stateData.frameSize.height}); } diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp index 1e176f9603..03dab24af6 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp @@ -14,8 +14,7 @@ void RNSScreenStackHeaderConfigShadowNode::applyFrameCorrections() { ensureUnsealed(); const auto &stateData = getStateData(); - layoutMetrics_.frame.origin.x = stateData.contentOffset.x; - layoutMetrics_.frame.origin.y = stateData.contentOffset.y; + layoutMetrics_.frame.origin.y = -stateData.frameSize.height; } } diff --git a/ios/RNSScreenStackHeaderSubview.mm b/ios/RNSScreenStackHeaderSubview.mm index dad44f5802..052e0afb29 100644 --- a/ios/RNSScreenStackHeaderSubview.mm +++ b/ios/RNSScreenStackHeaderSubview.mm @@ -122,7 +122,7 @@ - (void)layoutSubviews if (headerConfig) { UINavigationController *navctr = headerConfig.screenView.reactViewController.navigationController; - CGRect frameInHeaderConfig = [self convertRect:self.frame toView:navctr.view]; + CGRect frameInHeaderConfig = [self convertRect:self.frame toView:navctr.navigationBar]; [self updateHeaderSubviewFrame:frameInHeaderConfig.size :frameInHeaderConfig.origin]; } } From eca658014164db6f7b2525c7013a47fbea84da6c Mon Sep 17 00:00:00 2001 From: Dawid Date: Tue, 26 Nov 2024 12:35:32 +0100 Subject: [PATCH 15/26] fix not completed layout --- ios/RNSScreenStack.mm | 5 +++++ ios/RNSScreenStackHeaderSubview.h | 1 + ios/RNSScreenStackHeaderSubview.mm | 16 ++-------------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/ios/RNSScreenStack.mm b/ios/RNSScreenStack.mm index f3e9c39164..e6d54e8215 100644 --- a/ios/RNSScreenStack.mm +++ b/ios/RNSScreenStack.mm @@ -112,6 +112,11 @@ - (void)maybeUpdateHeaderInsetsInShadowTreeForScreen:(RNSScreen *)screenControll } [headerConfig updateHeaderConfigState:self.navigationBar.frame.size :self.navigationBar.frame.origin]; + + for (RNSScreenStackHeaderSubview *subview in headerConfig.reactSubviews) { + CGRect frameToNavigationBar = [subview convertRect:subview.frame toView:self.navigationBar]; + [subview updateHeaderSubviewFrame:frameToNavigationBar]; + } } #endif diff --git a/ios/RNSScreenStackHeaderSubview.h b/ios/RNSScreenStackHeaderSubview.h index 6930491d7e..b042ae0d25 100644 --- a/ios/RNSScreenStackHeaderSubview.h +++ b/ios/RNSScreenStackHeaderSubview.h @@ -23,6 +23,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, weak) RCTBridge *bridge; #ifdef RCT_NEW_ARCH_ENABLED +- (void)updateHeaderSubviewFrame:(CGRect)frame; #else - (instancetype)initWithBridge:(RCTBridge *)bridge; #endif // RCT_NEW_ARCH_ENABLED diff --git a/ios/RNSScreenStackHeaderSubview.mm b/ios/RNSScreenStackHeaderSubview.mm index 052e0afb29..2171b4f470 100644 --- a/ios/RNSScreenStackHeaderSubview.mm +++ b/ios/RNSScreenStackHeaderSubview.mm @@ -115,28 +115,16 @@ + (BOOL)shouldBeRecycled return NO; } -- (void)layoutSubviews -{ - [super layoutSubviews]; - RNSScreenStackHeaderConfig *headerConfig = [self getHeaderConfig]; - - if (headerConfig) { - UINavigationController *navctr = headerConfig.screenView.reactViewController.navigationController; - CGRect frameInHeaderConfig = [self convertRect:self.frame toView:navctr.navigationBar]; - [self updateHeaderSubviewFrame:frameInHeaderConfig.size :frameInHeaderConfig.origin]; - } -} - - (void)updateState:(const facebook::react::State::Shared &)state oldState:(const facebook::react::State::Shared &)oldState { _state = std::static_pointer_cast(state); } -- (void)updateHeaderSubviewFrame:(CGSize)size :(CGPoint)origin +- (void)updateHeaderSubviewFrame:(CGRect)frame { if (_state != nullptr) { - auto newState = react::RNSScreenStackHeaderSubviewState(RCTSizeFromCGSize(size), RCTPointFromCGPoint(origin)); + auto newState = react::RNSScreenStackHeaderSubviewState(RCTSizeFromCGSize(frame.size), RCTPointFromCGPoint(frame.origin)); _state->updateState(std::move(newState)); } } From 0823b03edf579b2ef03ecc025bb6d33128c3fad1 Mon Sep 17 00:00:00 2001 From: Dawid Date: Tue, 26 Nov 2024 16:31:26 +0100 Subject: [PATCH 16/26] fix subview hit test bug --- ios/RNSScreenStackHeaderConfig.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index 6e096be9e7..3b9ec02ee8 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -144,7 +144,7 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event subview.subviews.firstObject; // we convert the point to RNSScreenStackView since it always contains the header inside it - CGPoint convertedPoint = [_screenView.reactSuperview convertPoint:point toView:headerComponent]; + CGPoint convertedPoint = [self convertPoint:point toView:headerComponent]; UIView *hitTestResult = [headerComponent hitTest:convertedPoint withEvent:event]; if (hitTestResult != nil) { From 61f2f9d36df85e6dcc11d2c688a1415a6ee68ee0 Mon Sep 17 00:00:00 2001 From: Dawid Date: Tue, 26 Nov 2024 16:44:54 +0100 Subject: [PATCH 17/26] hit testing flattened views on iOS --- ios/RNSScreenStackHeaderConfig.mm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index 3b9ec02ee8..f76c7b884c 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -138,18 +138,18 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event if (subview.type == RNSScreenStackHeaderSubviewTypeLeft || subview.type == RNSScreenStackHeaderSubviewTypeRight) { // we wrap the headerLeft/Right component in a UIBarButtonItem - // so we need to use the only subview of it to retrieve the correct view - UIView *headerComponent = subview.subviews.count > 1 ? - headerComponent = subview.subviews[subview.subviews.count - 1] : - subview.subviews.firstObject; - - // we convert the point to RNSScreenStackView since it always contains the header inside it - CGPoint convertedPoint = [self convertPoint:point toView:headerComponent]; - - UIView *hitTestResult = [headerComponent hitTest:convertedPoint withEvent:event]; - if (hitTestResult != nil) { - return hitTestResult; + // so we need to hit test subviews from left to right, because of the view flattening + UIView *headerComponent = nil; + for (UIView *headerComponentSubview in subview.subviews) { + CGPoint convertedPoint = [self convertPoint:point toView:headerComponentSubview]; + UIView *hitTestResult = [headerComponentSubview hitTest:convertedPoint withEvent:event]; + + if (hitTestResult != nil) { + headerComponent = hitTestResult; + } } + + return headerComponent; } } return nil; From 3b5ee9d82e38286caecc11c0d58f62e13de2801e Mon Sep 17 00:00:00 2001 From: Dawid Date: Tue, 26 Nov 2024 16:58:11 +0100 Subject: [PATCH 18/26] sending subviews frames on fabric --- ios/RNSScreenStack.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ios/RNSScreenStack.mm b/ios/RNSScreenStack.mm index e6d54e8215..11589b2255 100644 --- a/ios/RNSScreenStack.mm +++ b/ios/RNSScreenStack.mm @@ -113,10 +113,12 @@ - (void)maybeUpdateHeaderInsetsInShadowTreeForScreen:(RNSScreen *)screenControll [headerConfig updateHeaderConfigState:self.navigationBar.frame.size :self.navigationBar.frame.origin]; +#ifdef RCT_NEW_ARCH_ENABLED for (RNSScreenStackHeaderSubview *subview in headerConfig.reactSubviews) { CGRect frameToNavigationBar = [subview convertRect:subview.frame toView:self.navigationBar]; [subview updateHeaderSubviewFrame:frameToNavigationBar]; } +#endif } #endif From d6e1597477ae1142e4f2f0ca63f10a0ccab07750 Mon Sep 17 00:00:00 2001 From: Dawid Date: Thu, 28 Nov 2024 10:49:22 +0100 Subject: [PATCH 19/26] fix Android build paper --- .../FabricEnabledHeaderConfigViewGroup.kt | 9 +++++++- .../FabricEnabledHeaderSubviewGroup.kt | 2 +- .../com/swmansion/rnscreens/CustomToolbar.kt | 14 ++++++++----- .../FabricEnabledHeaderConfigViewGroup.kt | 11 +++++++++- .../FabricEnabledHeaderSubviewGroup.kt | 21 +++++++++++++++++++ 5 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt diff --git a/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt b/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt index 34d9a0bb0f..ba32559fc3 100644 --- a/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt +++ b/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt @@ -22,6 +22,13 @@ abstract class FabricEnabledHeaderConfigViewGroup( fun setStateWrapper(wrapper: StateWrapper?) { mStateWrapper = wrapper } + + fun updatePaddings( + paddingStart: Int, + paddingEnd: Int + ) { + // do nothing + } fun updateHeaderConfigState( width: Int, @@ -49,7 +56,7 @@ abstract class FabricEnabledHeaderConfigViewGroup( if (abs(lastWidth - realWidth) < DELTA && abs(lastHeight - realHeight) < DELTA && abs(lastOffsetX - offsetXDip) < DELTA && - abs(lastOffsetY - offsetY) < DELTA + abs(lastOffsetY - offsetYDip) < DELTA ) { return } diff --git a/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt b/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt index 926a36ba47..cdf6095a96 100644 --- a/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt +++ b/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt @@ -15,7 +15,7 @@ abstract class FabricEnabledHeaderSubviewGroup(context: Context?): ViewGroup(con mStateWrapper = wrapper } - fun updateSubviewFrameState( + protected fun updateSubviewFrameState( width: Int, height: Int, offsetX: Int, diff --git a/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt b/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt index 49ced96009..55c8d3fe73 100644 --- a/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt +++ b/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt @@ -67,11 +67,15 @@ open class CustomToolbar( b: Int, ) { super.onLayout(changed, l, t, r, b) - val width = r - l; - val height = b - t; - // our children are already laid out - val contentInsetStart = if (navigationIcon != null) contentInsetStartWithNavigation else contentInsetStart - config.updateHeaderConfigState(width, height, l, t) + if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { + val width = r - l; + val height = b - t; + config.updateHeaderConfigState(width, height, l, t) + } else { + // our children are already laid out + val contentInsetStart = if (navigationIcon != null) contentInsetStartWithNavigation else contentInsetStart + config.updatePaddings(contentInsetStart, contentInsetEnd) + } } } diff --git a/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt b/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt index f1abaf546a..e0e60f287f 100644 --- a/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt +++ b/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt @@ -16,7 +16,16 @@ abstract class FabricEnabledHeaderConfigViewGroup( fun setStateWrapper(wrapper: StateWrapper?) = Unit - fun updatePaddingsFabric( + fun updateHeaderConfigState( + width: Int, + height: Int, + offsetX: Int, + offsetY: Int + ) { + // do nothing + } + + fun updatePaddings( paddingStart: Int, paddingEnd: Int, ) { diff --git a/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt b/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt new file mode 100644 index 0000000000..529a769e2e --- /dev/null +++ b/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt @@ -0,0 +1,21 @@ +package com.swmansion.rnscreens + +import android.content.Context +import android.view.ViewGroup +import com.facebook.react.uimanager.StateWrapper + +abstract class FabricEnabledHeaderSubviewGroup(context: Context?): ViewGroup(context) { + + fun setStateWrapper(wrapper: StateWrapper?) = Unit + + protected fun updateSubviewFrameState( + width: Int, + height: Int, + offsetX: Int, + offsetY: Int + ) { + // do nothing + } + + +} \ No newline at end of file From 723e8a9edc5769ee618588272fa38e9b65c9288b Mon Sep 17 00:00:00 2001 From: Dawid Date: Thu, 28 Nov 2024 11:03:50 +0100 Subject: [PATCH 20/26] FabricEnabledHeaderSubviewGroup empty line --- .../com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt b/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt index 529a769e2e..e8fda35aab 100644 --- a/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt +++ b/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderSubviewGroup.kt @@ -18,4 +18,4 @@ abstract class FabricEnabledHeaderSubviewGroup(context: Context?): ViewGroup(con } -} \ No newline at end of file +} From b71e62eeb097145914cd13c78843fb1fc63742f1 Mon Sep 17 00:00:00 2001 From: Dawid Date: Thu, 28 Nov 2024 11:08:11 +0100 Subject: [PATCH 21/26] remove RNSScreenStackHeaderConfigShadowNode include --- .../react/renderer/components/rnscreens/RNSScreenShadowNode.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp b/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp index 33bb36824f..855e04e66f 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp @@ -1,5 +1,4 @@ #include "RNSScreenShadowNode.h" -#include "RNSScreenStackHeaderConfigShadowNode.h" namespace facebook { namespace react { From 8541afcff016b6dbac5df7cdab618edff10c51f3 Mon Sep 17 00:00:00 2001 From: Dawid Date: Thu, 28 Nov 2024 11:35:04 +0100 Subject: [PATCH 22/26] remove unused origin from header config state --- .../FabricEnabledHeaderConfigViewGroup.kt | 18 ++-------------- .../com/swmansion/rnscreens/CustomToolbar.kt | 2 +- .../RNSScreenStackHeaderConfigState.h | 9 +++----- ios/RNSScreenStack.mm | 21 ++++++++++++++++--- ios/RNSScreenStackHeaderConfig.h | 17 ++++++++++----- ios/RNSScreenStackHeaderConfig.mm | 4 ++-- 6 files changed, 38 insertions(+), 33 deletions(-) diff --git a/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt b/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt index ba32559fc3..17b307bc43 100644 --- a/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt +++ b/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt @@ -16,8 +16,6 @@ abstract class FabricEnabledHeaderConfigViewGroup( private var lastWidth = 0f private var lastHeight = 0f - private var lastOffsetX = 0f - private var lastOffsetY = 0f fun setStateWrapper(wrapper: StateWrapper?) { mStateWrapper = wrapper @@ -33,45 +31,33 @@ abstract class FabricEnabledHeaderConfigViewGroup( fun updateHeaderConfigState( width: Int, height: Int, - offsetX: Int, - offsetY: Int ) { - updateState(width, height, offsetX, offsetY) + updateState(width, height) } @UiThread fun updateState( width: Int, height: Int, - offsetX: Int, - offsetY: Int ) { val realWidth: Float = PixelUtil.toDIPFromPixel(width.toFloat()) val realHeight: Float = PixelUtil.toDIPFromPixel(height.toFloat()) - val offsetXDip: Float = PixelUtil.toDIPFromPixel(offsetX.toFloat()) - val offsetYDip: Float = PixelUtil.toDIPFromPixel(offsetY.toFloat()) // Check incoming state values. If they're already the correct value, return early to prevent // infinite UpdateState/SetState loop. if (abs(lastWidth - realWidth) < DELTA && - abs(lastHeight - realHeight) < DELTA && - abs(lastOffsetX - offsetXDip) < DELTA && - abs(lastOffsetY - offsetYDip) < DELTA + abs(lastHeight - realHeight) < DELTA ) { return } lastWidth = realWidth lastHeight = realHeight - lastOffsetX = offsetXDip - lastOffsetY = offsetYDip val map: WritableMap = WritableNativeMap().apply { putDouble("frameWidth", realWidth.toDouble()) putDouble("frameHeight", realHeight.toDouble()) - putDouble("contentOffsetX", offsetXDip.toDouble()) - putDouble("contentOffsetY", offsetYDip.toDouble()) } mStateWrapper?.updateState(map) } diff --git a/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt b/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt index 55c8d3fe73..f74b2ac919 100644 --- a/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt +++ b/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt @@ -71,7 +71,7 @@ open class CustomToolbar( if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { val width = r - l; val height = b - t; - config.updateHeaderConfigState(width, height, l, t) + config.updateHeaderConfigState(width, height) } else { // our children are already laid out val contentInsetStart = if (navigationIcon != null) contentInsetStartWithNavigation else contentInsetStart diff --git a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h index 93eca9811a..ff7acdff94 100644 --- a/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h +++ b/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h @@ -17,8 +17,8 @@ class JSI_EXPORT RNSScreenStackHeaderConfigState final { RNSScreenStackHeaderConfigState() = default; - RNSScreenStackHeaderConfigState(Size frameSize_, Point contentOffset_) - : frameSize(frameSize_), contentOffset(contentOffset_) {} + RNSScreenStackHeaderConfigState(Size frameSize_) + : frameSize(frameSize_) {} #ifdef ANDROID RNSScreenStackHeaderConfigState( @@ -26,10 +26,7 @@ class JSI_EXPORT RNSScreenStackHeaderConfigState final { folly::dynamic data) : frameSize(Size{ (Float)data["frameWidth"].getDouble(), - (Float)data["frameHeight"].getDouble()}), - contentOffset(Point{ - (Float)data["contentOffsetX"].getDouble(), - (Float)data["contentOffsetY"].getDouble()}){} + (Float)data["frameHeight"].getDouble()}){} #endif #ifdef ANDROID diff --git a/ios/RNSScreenStack.mm b/ios/RNSScreenStack.mm index fbb0e46555..78dab89f67 100644 --- a/ios/RNSScreenStack.mm +++ b/ios/RNSScreenStack.mm @@ -111,15 +111,30 @@ - (void)maybeUpdateHeaderInsetsInShadowTreeForScreen:(RNSScreen *)screenControll if (headerConfig == nil || !headerConfig.shouldHeaderBeVisible) { return; } - - [headerConfig updateHeaderConfigState:self.navigationBar.frame.size :self.navigationBar.frame.origin]; #ifdef RCT_NEW_ARCH_ENABLED + [headerConfig updateHeaderConfigState:self.navigationBar.frame.size]; for (RNSScreenStackHeaderSubview *subview in headerConfig.reactSubviews) { CGRect frameToNavigationBar = [subview convertRect:subview.frame toView:self.navigationBar]; [subview updateHeaderSubviewFrame:frameToNavigationBar]; } -#endif +#else + NSDirectionalEdgeInsets navBarMargins = [self.navigationBar directionalLayoutMargins]; + NSDirectionalEdgeInsets navBarContentMargins = + [self.navigationBar.rnscreens_findContentView directionalLayoutMargins]; + + BOOL isDisplayingBackButton = [headerConfig shouldBackButtonBeVisibleInNavigationBar:self.navigationBar]; + + // 44.0 is just "closed eyes default". It is so on device I've tested with, nothing more. + UIView *barButtonView = isDisplayingBackButton ? self.navigationBar.rnscreens_findBackButtonWrapperView : nil; + CGFloat platformBackButtonWidth = barButtonView != nil ? barButtonView.frame.size.width : 44.0f; + + [headerConfig updateHeaderConfigState:NSDirectionalEdgeInsets{ + .leading = navBarMargins.leading + navBarContentMargins.leading + + (isDisplayingBackButton ? platformBackButtonWidth : 0), + .trailing = navBarMargins.trailing + navBarContentMargins.trailing, + }]; +#endif // RCT_NEW_ARCH_ENABLED } #endif diff --git a/ios/RNSScreenStackHeaderConfig.h b/ios/RNSScreenStackHeaderConfig.h index 2084edf24e..2fd78eb9ed 100644 --- a/ios/RNSScreenStackHeaderConfig.h +++ b/ios/RNSScreenStackHeaderConfig.h @@ -66,11 +66,6 @@ NS_ASSUME_NONNULL_END animated:(BOOL)animated withConfig:(nonnull RNSScreenStackHeaderConfig *)config; -/** - * Allows to send information with insets to the corresponding node in shadow tree. - */ -- (void)updateHeaderConfigState:(CGSize)size :(CGPoint)origin; - /** * Returns true iff subview of given `type` is present. * @@ -103,6 +98,18 @@ NS_ASSUME_NONNULL_END */ - (BOOL)shouldBackButtonBeVisibleInNavigationBar:(nullable UINavigationBar *)navBar; +#ifdef RCT_NEW_ARCH_ENABLED +/** + * Allows to send information with size to the corresponding node in shadow tree. + */ +- (void)updateHeaderConfigState:(CGSize)size; +#else +/** + * Allows to send information with insets to the corresponding node in shadow tree. + */ +- (void)updateHeaderConfigState:(NSDirectionalEdgeInsets)insets; +#endif + @end @interface RNSScreenStackHeaderConfigManager : RCTViewManager diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index 245f9ea57c..e759a45918 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -202,9 +202,9 @@ - (void)layoutNavigationControllerView #ifdef RCT_NEW_ARCH_ENABLED -- (void)updateHeaderConfigState:(CGSize)size :(CGPoint)origin +- (void)updateHeaderConfigState:(CGSize)size { - auto newState = react::RNSScreenStackHeaderConfigState(RCTSizeFromCGSize(size), RCTPointFromCGPoint(origin)); + auto newState = react::RNSScreenStackHeaderConfigState(RCTSizeFromCGSize(size)); _state->updateState(std::move(newState)); } #else From 396abd4dac21b3429b826a6171d53646b3cbe23a Mon Sep 17 00:00:00 2001 From: Dawid Date: Thu, 28 Nov 2024 11:42:01 +0100 Subject: [PATCH 23/26] caching header config size, iOS --- ios/RNSScreenStackHeaderConfig.mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index e759a45918..e652ae2215 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -63,6 +63,7 @@ @implementation RNSScreenStackHeaderConfig { NSDirectionalEdgeInsets _lastHeaderInsets; #ifdef RCT_NEW_ARCH_ENABLED BOOL _initialPropsSet; + CGSize _lastSize; react::RNSScreenStackHeaderConfigShadowNode::ConcreteState::Shared _state; #ifndef NDEBUG RCTImageLoader *imageLoader; @@ -204,8 +205,11 @@ - (void)layoutNavigationControllerView #ifdef RCT_NEW_ARCH_ENABLED - (void)updateHeaderConfigState:(CGSize)size { - auto newState = react::RNSScreenStackHeaderConfigState(RCTSizeFromCGSize(size)); - _state->updateState(std::move(newState)); + if (_lastSize.width != size.width || _lastSize.height != size.height) { + auto newState = react::RNSScreenStackHeaderConfigState(RCTSizeFromCGSize(size)); + _state->updateState(std::move(newState)); + _lastSize = size; + } } #else - (void)updateHeaderConfigState:(NSDirectionalEdgeInsets)insets From 9799d47a81ece46b2184af34b10bcc9678dae065 Mon Sep 17 00:00:00 2001 From: Dawid Date: Thu, 28 Nov 2024 11:49:41 +0100 Subject: [PATCH 24/26] _lastSize recycle --- ios/RNSScreenStackHeaderConfig.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index e652ae2215..16dccfb50d 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -60,7 +60,6 @@ + (BOOL)RNSisBlank:(NSString *)string @implementation RNSScreenStackHeaderConfig { NSMutableArray *_reactSubviews; - NSDirectionalEdgeInsets _lastHeaderInsets; #ifdef RCT_NEW_ARCH_ENABLED BOOL _initialPropsSet; CGSize _lastSize; @@ -69,6 +68,7 @@ @implementation RNSScreenStackHeaderConfig { RCTImageLoader *imageLoader; #endif // !NDEBUG #else + NSDirectionalEdgeInsets _lastHeaderInsets; __weak RCTBridge *_bridge; #endif } @@ -952,7 +952,12 @@ - (void)prepareForRecycle { [super prepareForRecycle]; _initialPropsSet = NO; + +#ifdef RCT_NEW_ARCH_ENABLED + _lastSize = CGSize(); +#else _lastHeaderInsets = NSDirectionalEdgeInsets{}; +#endif } - (NSNumber *)getFontSizePropValue:(int)value From f7bfbd7674378082f60087865cbf753a4da47183 Mon Sep 17 00:00:00 2001 From: Dawid Date: Thu, 28 Nov 2024 11:52:27 +0100 Subject: [PATCH 25/26] remove sending top inset, paper --- ios/RNSScreenStackHeaderConfig.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index 16dccfb50d..f54d0b33d1 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -214,7 +214,7 @@ - (void)updateHeaderConfigState:(CGSize)size #else - (void)updateHeaderConfigState:(NSDirectionalEdgeInsets)insets { - if (_lastHeaderInsets.leading != insets.leading || _lastHeaderInsets.trailing != insets.trailing || _lastHeaderInsets.top != insets.top) { + if (_lastHeaderInsets.leading != insets.leading || _lastHeaderInsets.trailing != insets.trailing) { [_bridge.uiManager setLocalData:[[RNSHeaderConfigInsetsPayload alloc] initWithInsets:insets] forView:self]; _lastHeaderInsets = std::move(insets); } From c71ce45173f269012a44481202939a0c5606c43d Mon Sep 17 00:00:00 2001 From: Dawid Date: Thu, 28 Nov 2024 12:14:09 +0100 Subject: [PATCH 26/26] fix Android build --- .../swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt b/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt index e0e60f287f..0e1f8c7cfa 100644 --- a/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt +++ b/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt @@ -19,8 +19,6 @@ abstract class FabricEnabledHeaderConfigViewGroup( fun updateHeaderConfigState( width: Int, height: Int, - offsetX: Int, - offsetY: Int ) { // do nothing }