From da09272e9e86136b006281fc972cc3d70d3317fd Mon Sep 17 00:00:00 2001 From: Joe Mun Date: Mon, 23 Oct 2023 11:41:47 -0700 Subject: [PATCH 1/5] Set stateWrapper in ScreenViewManager --- .../java/com/swmansion/rnscreens/ScreenViewManager.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt b/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt index 5d92778f65..5eb42424cf 100644 --- a/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +++ b/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt @@ -4,6 +4,8 @@ import com.facebook.react.bridge.JSApplicationIllegalArgumentException import com.facebook.react.bridge.ReadableMap import com.facebook.react.common.MapBuilder 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 @@ -35,6 +37,15 @@ class ScreenViewManager : ViewGroupManager(), RNSScreenManagerInterface< setActivityState(view, activityState.toInt()) } + override fun updateState( + view: Screen, + props: ReactStylesDiffMap?, + stateWrapper: StateWrapper? + ): Any? { + view.fabricViewStateManager.setStateWrapper(stateWrapper) + return null + } + @ReactProp(name = "activityState") fun setActivityState(view: Screen, activityState: Int) { if (activityState == -1) { From c904737524b819cabe8e2dafb6088e3bd9d1ece6 Mon Sep 17 00:00:00 2001 From: Joe Mun Date: Mon, 23 Oct 2023 16:24:31 -0700 Subject: [PATCH 2/5] fix paper --- .../main/java/com/swmansion/rnscreens/ScreenViewManager.kt | 7 +++++-- .../java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt b/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt index 5eb42424cf..61a25d556a 100644 --- a/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +++ b/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt @@ -42,8 +42,11 @@ class ScreenViewManager : ViewGroupManager(), RNSScreenManagerInterface< props: ReactStylesDiffMap?, stateWrapper: StateWrapper? ): Any? { - view.fabricViewStateManager.setStateWrapper(stateWrapper) - return null + if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { + view.fabricViewStateManager.setStateWrapper(stateWrapper) + return null + } + return super.updateState(view, props, stateWrapper) } @ReactProp(name = "activityState") diff --git a/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt b/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt index 106638858d..1d41a593a4 100644 --- a/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +++ b/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt @@ -2,8 +2,12 @@ package com.swmansion.rnscreens import android.view.ViewGroup import com.facebook.react.bridge.ReactContext +import com.facebook.react.uimanager.FabricViewStateManager abstract class FabricEnabledViewGroup constructor(context: ReactContext?) : ViewGroup(context) { + + val fabricViewStateManager get() = null as FabricViewStateManager + protected fun updateScreenSizeFabric(width: Int, height: Int) { // do nothing } From 620ee9b6955d6a1f1931024c8bfb53d5f431082f Mon Sep 17 00:00:00 2001 From: Joe Mun Date: Tue, 24 Oct 2023 11:22:19 -0700 Subject: [PATCH 3/5] make FabricEnabledViewGroup.fabricViewStateManager nullable in Paper --- .../main/java/com/swmansion/rnscreens/ScreenViewManager.kt | 6 +++--- .../java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt b/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt index 61a25d556a..fdf83fdc9c 100644 --- a/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +++ b/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt @@ -42,9 +42,9 @@ class ScreenViewManager : ViewGroupManager(), RNSScreenManagerInterface< props: ReactStylesDiffMap?, stateWrapper: StateWrapper? ): Any? { - if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { - view.fabricViewStateManager.setStateWrapper(stateWrapper) - return null + if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED && view.fabricViewStateManager != null) { + // fabricViewStateManager should never be null in Fabric. the null check is only for Paper's empty impl. + view.fabricViewStateManager!!.setStateWrapper(stateWrapper) } return super.updateState(view, props, stateWrapper) } diff --git a/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt b/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt index 1d41a593a4..6c1c238bd6 100644 --- a/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +++ b/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt @@ -6,7 +6,7 @@ import com.facebook.react.uimanager.FabricViewStateManager abstract class FabricEnabledViewGroup constructor(context: ReactContext?) : ViewGroup(context) { - val fabricViewStateManager get() = null as FabricViewStateManager + val fabricViewStateManager get() = null as FabricViewStateManager? protected fun updateScreenSizeFabric(width: Int, height: Int) { // do nothing From 92744a1187a75b35347efe0d559ef85983f25815 Mon Sep 17 00:00:00 2001 From: Joe Mun <12057449+joemun@users.noreply.github.com> Date: Wed, 25 Oct 2023 09:45:21 -0700 Subject: [PATCH 4/5] fix caps Co-authored-by: Tymoteusz Boba --- .../src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt b/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt index fdf83fdc9c..7977b990e0 100644 --- a/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +++ b/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt @@ -43,7 +43,7 @@ class ScreenViewManager : ViewGroupManager(), RNSScreenManagerInterface< stateWrapper: StateWrapper? ): Any? { if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED && view.fabricViewStateManager != null) { - // fabricViewStateManager should never be null in Fabric. the null check is only for Paper's empty impl. + // fabricViewStateManager should never be null in Fabric. The null check is only for Paper's empty impl. view.fabricViewStateManager!!.setStateWrapper(stateWrapper) } return super.updateState(view, props, stateWrapper) From a1b5e8964270cb1751498292fd1b0774c6d195a7 Mon Sep 17 00:00:00 2001 From: Joe Mun <12057449+joemun@users.noreply.github.com> Date: Thu, 26 Oct 2023 09:23:41 -0700 Subject: [PATCH 5/5] change null check Co-authored-by: Tymoteusz Boba --- .../main/java/com/swmansion/rnscreens/ScreenViewManager.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt b/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt index 7977b990e0..8c70876ef4 100644 --- a/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +++ b/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt @@ -42,9 +42,9 @@ class ScreenViewManager : ViewGroupManager(), RNSScreenManagerInterface< props: ReactStylesDiffMap?, stateWrapper: StateWrapper? ): Any? { - if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED && view.fabricViewStateManager != null) { + if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { // fabricViewStateManager should never be null in Fabric. The null check is only for Paper's empty impl. - view.fabricViewStateManager!!.setStateWrapper(stateWrapper) + view.fabricViewStateManager?.setStateWrapper(stateWrapper) } return super.updateState(view, props, stateWrapper) }