SergioR
08/02/2024, 5:47 PMSergioR
08/02/2024, 7:12 PM@Composable
fun AppScaffold() {
val navController = rememberNavController()
val shouldShowBottomBar = remember { mutableStateOf(true) }. // these val are set by my globalStateManager
val drawerContent = remember { mutableStateOf<(@Composable () -> Unit)?>(null) }
val snackbarContent = remember { mutableStateOf<(@Composable () -> Unit)?>(null) }
val floatingActionButtonState = remember { mutableStateOf(FloatingActionButtonState()) }
val scope = rememberCoroutineScope()
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Rtl) {
ModalNavigationDrawer(
drawerState = rememberDrawerState(DrawerValue.Closed),
drawerContent = {
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {
drawerContent.value?.invoke()
}
},
gesturesEnabled = drawerContent.value != null
) {
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {
Scaffold(
topBar = {
if (show topbar.value.show) {
TopAppBar(
title = { Text("Title") },
modifier = Modifier
.fillMaxWidth()
.heightIn(max = 56.dp)
)
},
floatingActionButton = {
if (floatingActionButtonState.value.show) {
FloatingActionButton(onClick = { /* Do something */ }) {
Icon(Icons.Default.Add, contentDescription = "FAB")
}
}
},
bottomBar = {
if (shouldShowBottomBar.value) {
BottomAppBar {
// Bottom navigation items
}
}
},
snackbarHost = {
SnackbarHost(hostState = remember { SnackbarHostState() }) { data ->
snackbarContent.value?.invoke(data)
}
},
) { paddingValues ->
MainNavigationController(
navController = navController,
paddingValues = paddingValues
)
}
}
}
}
}
someone else has experienced that?