Skip to content

Commit

Permalink
Make it compile
Browse files Browse the repository at this point in the history
  • Loading branch information
kkafar committed Sep 13, 2023
1 parent 3e4373d commit 277fbd9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ open class ScreenContainer(context: Context?) : ViewGroup(context) {

fun getScreenAt(index: Int): Screen = mScreenFragments[index].screen

fun getScreenFragmentWrapperAt(index: Int): ScreenFragmentWrapper = mScreenFragments[index]

open val topScreen: Screen?
get() = mScreenFragments.firstOrNull { getActivityState(it) === ActivityState.ON_TOP }?.screen

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.ViewGroupManager

@ReactModule(name = ScreenContainerViewManager.REACT_CLASS)
class ScreenContainerViewManager : ViewGroupManager<ScreenContainer<*>>() {
class ScreenContainerViewManager : ViewGroupManager<ScreenContainer>() {
override fun getName(): String = REACT_CLASS

override fun createViewInstance(reactContext: ThemedReactContext): ScreenContainer<ScreenFragment> = ScreenContainer(reactContext)
override fun createViewInstance(reactContext: ThemedReactContext): ScreenContainer = ScreenContainer(reactContext)

override fun addView(parent: ScreenContainer<*>, child: View, index: Int) {
override fun addView(parent: ScreenContainer, child: View, index: Int) {
require(child is Screen) { "Attempt attach child that is not of type RNScreens" }
parent.addScreen(child, index)
}

override fun removeViewAt(parent: ScreenContainer<*>, index: Int) {
override fun removeViewAt(parent: ScreenContainer, index: Int) {
parent.removeScreenAt(index)
}

override fun removeAllViews(parent: ScreenContainer<*>) {
override fun removeAllViews(parent: ScreenContainer) {
parent.removeAllScreens()
}

override fun getChildCount(parent: ScreenContainer<*>): Int = parent.screenCount
override fun getChildCount(parent: ScreenContainer): Int = parent.screenCount

override fun getChildAt(parent: ScreenContainer<*>, index: Int): View = parent.getScreenAt(index)
override fun getChildAt(parent: ScreenContainer, index: Int): View = parent.getScreenAt(index)

override fun createShadowNodeInstance(context: ReactApplicationContext): LayoutShadowNode = ScreensShadowNode(context)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ open class ScreenFragment : Fragment, ScreenFragmentWrapper {

override fun dispatchLifecycleEventInChildContainers(event: ScreenLifecycleEvent) {
mChildScreenContainers.filter { it.screenCount > 0 }.forEach {
it.topScreen?.fragment?.let { fragment -> dispatchLifecycleEvent(event, fragment) }
it.topScreen?.fragmentWrapper?.let { fragment -> dispatchLifecycleEvent(event, fragment) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) {
val reactContext = if (context is ReactContext) {
context as ReactContext
} else {
it.fragment?.tryGetContext()
it.fragmentWrapper?.tryGetContext()
}
ScreenWindowTraits.trySetWindowTraits(it, activity, reactContext)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ object ScreenWindowTraits {
screen: Screen?,
trait: WindowTraits
): Screen? {
screen?.fragment?.let {
screen?.fragmentWrapper?.let {
for (sc in it.childScreenContainers) {
// we check only the top screen for the trait
val topScreen = sc.topScreen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class ScreensShadowNode(private var mContext: ReactContext) : LayoutSha
super.onBeforeLayout(nativeViewHierarchyOptimizer)
(mContext.getNativeModule(UIManagerModule::class.java))?.addUIBlock { nativeViewHierarchyManager: NativeViewHierarchyManager ->
val view = nativeViewHierarchyManager.resolveView(reactTag)
if (view is ScreenContainer<*>) {
if (view is ScreenContainer) {
view.performUpdates()
}
}
Expand Down

0 comments on commit 277fbd9

Please sign in to comment.