Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Android): Set stateWrapper in ScreenViewManager in Fabric #1944

Merged
merged 5 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -35,6 +37,18 @@ class ScreenViewManager : ViewGroupManager<Screen>(), RNSScreenManagerInterface<
setActivityState(view, activityState.toInt())
}

override fun updateState(
view: Screen,
props: ReactStylesDiffMap?,
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.
joemun marked this conversation as resolved.
Show resolved Hide resolved
view.fabricViewStateManager!!.setStateWrapper(stateWrapper)
}
return super.updateState(view, props, stateWrapper)
}

@ReactProp(name = "activityState")
fun setActivityState(view: Screen, activityState: Int) {
if (activityState == -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading