Qamar Khan
03/28/2023, 9:33 AMQamar Khan
03/28/2023, 9:33 AMQamar Khan
03/28/2023, 9:34 AMTim Malseed
03/28/2023, 9:35 AMQamar Khan
03/28/2023, 9:35 AM@SuppressLint("StateFlowValueCalledInComposition")
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun ServiceScreen(userViewModel: ServicesViewModel) {
// val state by userViewModel.uiState.collectAsState()
val modalSheetState = rememberModalBottomSheetState(
initialValue = ModalBottomSheetValue.Hidden,
confirmStateChange = { it != ModalBottomSheetValue.HalfExpanded }
)
val roundedCornerRadius = 20.dp
val sheetShape =
RoundedCornerShape(topStart = roundedCornerRadius, topEnd = roundedCornerRadius)
val coroutineScope = rememberCoroutineScope()
val closeSheet: () -> Unit = {
coroutineScope.launch {
modalSheetState.hide()
}
}
val openSheet: () -> Unit = {
coroutineScope.launch {
if (modalSheetState.isVisible) {
modalSheetState.hide()
} else {
modalSheetState.animateTo(ModalBottomSheetValue.Expanded)
}
}
}
GenericBottomSheet(
sheetState = modalSheetState,
sheetShape = sheetShape,
sheetContent = {
ShowLoginOrRegisterBottomSheet(
closeSheet = closeSheet,
viewModel = userViewModel
)
},
mainContent = {
ScreenContent(
openSheet = openSheet,
userViewModel = userViewModel
)
}
)
}
@Tim MalseedTim Malseed
03/28/2023, 9:37 AMQamar Khan
03/28/2023, 9:39 AMcontent = { padding -> // We have to pass the scaffold inner padding to our content. That's why we use Box.
Box(modifier = Modifier.padding(padding)) {
Navigation(navController)
}
}
as you see navigation handle the screen content in main activity,
this is the below code is used to render any composable screen
@Composable
fun Navigation(navController: NavHostController){
NavHost(
navController = navController,
startDestination = MainDirection.splash.destination
) {
composable(MainDirection.splash.destination) {
SplashScreen(hiltViewModel(), navController = navController)
}
composable(MainDirection.personalise.destination) {
PersonaliseScreen(hiltViewModel(), navController = navController)
}
Tim Malseed
03/28/2023, 9:41 AMNavigation()
lives inside MainScreen()
. And then, where does ServiceScreen()
live?Qamar Khan
03/28/2023, 9:41 AMTim Malseed
03/28/2023, 9:42 AMQamar Khan
03/28/2023, 9:42 AMcomposable(DashboardDirection.services.destination){
ServiceScreen(hiltViewModel())
}
Tim Malseed
03/28/2023, 9:44 AMshowBottomBar = false
when your nav destination is DashboardDirection.services.destination
Tim Malseed
03/28/2023, 9:45 AMOnDestinationChangedListener
to your NavHostController
and hide the bottom sheet when the destination is ‘services’Qamar Khan
03/28/2023, 9:47 AMTim Malseed
03/28/2023, 9:48 AMI would like the bottom sheet to appear above the navigation bar or hide when the sheet is openSo you don’t want it to hide when the sheet is open?
Oleksandr Balan
03/28/2023, 1:05 PMModalBottomSheetLayout
ands shows it in the custom fullscreen popup to ensure that bottom sheet is displayed above other UI.dewildte
03/28/2023, 4:44 PMdewildte
03/28/2023, 4:47 PMQamar Khan
03/28/2023, 6:29 PMQamar Khan
03/28/2023, 6:30 PM