xxfast
10/01/2023, 8:59 PMIslandScreen
which is just a wrapper around a simple view. However, in order to show this screen alongside with all the other screens, I need to declare an IslandComponent
.
@Composable
fun MainUi(component: MainComponent) {
Children(..) {
var numbers by remember { mutableStateOf(listOf(1, 2, 3)) }
when(val instance: ComponentContext = it.instance){
is IslandComponent -> IslandUi(instance)
is ShipComponent -> ShipUi(instance)
is DockComponent -> DockUi(instance)
}
}
}
This is because the childFactory
of MainComponent
here, requires you to provide a component
val childStack: Value<ChildStack<Config, ComponentContext>> = childStack(
source = navigation,
..
childFactory = { configuration, componentContext ->
when(configuration){
Island -> IslandComponent(componentContext) { .. }
Ship -> ShipComponent(
componentContext = componentContext,
..
)
Dock -> DockComponent(componentContext = componentContext) { .. }
}
}
)
Arkadii Ivanov
10/01/2023, 9:05 PMxxfast
10/01/2023, 9:06 PMchildFactory
would still require to create an instance for Island
configuration, even though it is not used by the ui - right?Arkadii Ivanov
10/01/2023, 9:09 PMxxfast
10/01/2023, 9:12 PMIslandComponent
all-together because this particular screen doesn't have any logic - as it just basically shows a image.
However, this won't be possible as childFactory
will need an instance to be created and stored in the childStack
- is that correct?Arkadii Ivanov
10/01/2023, 9:15 PMxxfast
10/01/2023, 9:18 PMComponentContext
but as you mentioned, it can return Any
so a Unit makes more sense hereArkadii Ivanov
10/01/2023, 9:20 PMxxfast
10/01/2023, 9:20 PMArkadii Ivanov
10/01/2023, 9:23 PMxxfast
10/01/2023, 9:48 PMArkadii Ivanov
10/01/2023, 9:50 PM