Andrey Larionov
02/25/2025, 1:46 PMBottomNavigation
tab (ExploreRootScreen
, WalletRootScreen
and ProfileRootScreen
) has it's own ChildStack
@Composable
internal fun HomeRootScreen(component: HomeRootComponent) = Box(
modifier = Modifier.fillMaxSize()
) {
StackContent(component)
BottomNavigation(component)
}
@Composable
private fun StackContent(component: HomeRootComponent) {
val homeStack by component.stackRouter.subscribeAsState()
Children(
// ...
content = { childStack -> childStack.instance.getContentByChild() }
)
}
@Composable
private fun HomeRootChild.getContentByChild() = when (this) {
// ...
is ProfileRootChild -> ProfileRootScreen(this) // with ProfileRootComponent
}
BottomNavigation
is drawn over StackContent
using Alignment.Bottom
If we need to display a Dialog (ChildSlot
) somewhere deep inside of tab's ChildStack
, it should be drawn above BottomNavigation
I created a diagram where LogoutDialog
and SwitchLanguageDialog
(marked with yellow color) should appear. Each child in the diagram (marked with blue, yellow and pink colors) has it's own ChildComponent
(e.g, LanguageComponent
and SwitchLanguageComponent
)
And as I understand Decompose, for SwitchLanguageDialog
I should create ChildSlot
inside LanguageComponent
and this Dialog should be displayed on LanguageScreen
That's ok, but it will be drawn under the BottomNavigation
I assume I could create ChildSlot
at HomeRootComponent
level, but
• I'm not sure how to handle different children from different nested screens (e.g, using activeSlotChild: Flow<BaseSlotChild>
seems odd due to a large when
check)
• I don't know if this approach would break children back navigation (e.g, when Dialog is displayed, using system back swipe might trigger ChildStack
's backHandler)
How should I handle this properly?
Thanks in advanceArkadii Ivanov
02/25/2025, 6:36 PMAndrey Larionov
02/26/2025, 10:50 AMPopup
Popup(
onDismissRequest = onDismissRequest,
properties = PopupProperties(
focusable = true,
clippingEnabled = false,
dismissOnBackPress = true,
dismissOnClickOutside = false
)
) {
// Full screen dialog content
}
and now it works as expected
Thank you so much!