electrolobzik
02/13/2024, 12:33 PMArkadii Ivanov
02/13/2024, 1:01 PMelectrolobzik
02/13/2024, 1:12 PMArkadii Ivanov
02/13/2024, 2:54 PMelectrolobzik
02/27/2024, 6:32 PM@Composable fun render()
? Do you know any better solution?electrolobzik
02/27/2024, 6:34 PMelectrolobzik
02/27/2024, 7:00 PMArkadii Ivanov
02/27/2024, 7:04 PMelectrolobzik
02/27/2024, 7:16 PMelectrolobzik
02/27/2024, 7:55 PMelectrolobzik
02/27/2024, 7:55 PMArkadii Ivanov
02/27/2024, 7:56 PMProbably it is better to forward this event to the root and ask it to open the details screenExactly! I feel the same.
Arkadii Ivanov
02/27/2024, 8:02 PMelectrolobzik
02/27/2024, 8:05 PM@Composable
fun Root(
contentRootComponent: ContentRootComponent
) {
fun showContent(content: @Composable () -> Unit, showBottomNavigation: Boolean) {
if (showBottomNavigation) {
BottomNavigationScreen(
content = content
)
} else {
content()
}
}
Children(
modifier = modifier.padding(innerpadding),
stack = contentRootComponent.childStack,
animation = stackAnimation(fade() + scale()),
) {
when (val child = it.instance) {
is Child.A -> {
ChildAContent(::showContent)
}
...
}
}
}
@Composable
fun ChildAContent(
showContentHandler: @Composable (content: @Composable () -> Unit, showBottomNavigation: Boolean) -> Unit
) {
showContentHandler(
{ ChildAContent() },
false
)
}
@Composable
fun ChildAContent(){
}
electrolobzik
02/27/2024, 8:07 PMelectrolobzik
02/27/2024, 8:08 PMelectrolobzik
02/27/2024, 8:12 PMelectrolobzik
02/27/2024, 8:12 PMArkadii Ivanov
02/27/2024, 10:05 PMelectrolobzik
02/27/2024, 10:24 PMArkadii Ivanov
02/27/2024, 10:29 PMelectrolobzik
02/27/2024, 10:37 PMArkadii Ivanov
02/27/2024, 10:40 PMelectrolobzik
02/27/2024, 10:47 PMelectrolobzik
02/27/2024, 10:50 PMArkadii Ivanov
02/28/2024, 10:49 AMSo in general being Fullscreen doesn't mean that the screen belongs to the root in the logical/navigation treeI think it's kinda subjective and it depends. From my point of view, removing the dependency between screens in a stack (a flow of screens) is almost always better. E.g. if your child (tab) screen needs to open a details screen, then actually it doesn't care what the actual screen it should be - inversion of control. But again, the Portal pattern exists exactly because sometimes it might be useful. So use it with care. 🙂
electrolobzik
02/28/2024, 12:00 PMmay
not know about dependency and we remove that dependency it is always good. But in this case we can’t just remove it completely. If the feature component looses this knowledge, it just moves to some over point of the app. In this case the root, which now decides what to do on some event which should lead to opening of the details screen. So in one place we remove dependency and in another one we put that dependency. We don’t decrease coupling in general, but just remove coupling in one place and add it in another place. That means that we still will need to decide where this coupling is more justified and where less and choose from this decision.
Also besides IoC there is a factor of complexity. And if there are 2 places where the dependency/coupling can go we should also consider the resulting complexity as not the main factor but still important, especially if there are no strong reasons why that exact components should not be coupled (we should keep following something like SOLID here I suppose).Arkadii Ivanov
02/28/2024, 2:00 PMIn this case the root, which now decides what to do on some event which should lead to opening of the details screen.Yes, and this is the super-power. It is the integration point (the upper level) that decides how to handle the action. If it can't, then it bubbles the decision further up. And it's also the only way to avoid possible circular dependencies between features.
Also besides IoC there is a factor of complexity.True! I consider it as a trade-off.