rattleshirt
06/14/2024, 7:29 AMModalBottomSheet
but whenever the sheet contents change (through animations) the sheet disappears and animates in from the bottom again. Am I not allowed to have the sheet contents change?rattleshirt
06/14/2024, 7:30 AMval modalSheetState = rememberModalBottomSheetState(
skipPartiallyExpanded = true,
confirmValueChange = { false },
)
if (isVisible) {
ModalBottomSheet(
onDismissRequest = {},
modifier = modifier,
sheetState = modalSheetState,
Stylianos Gakis
06/14/2024, 7:39 AMisVisible
state on and off again quickly resulting in what you see.rattleshirt
06/14/2024, 7:51 AMisVisible
comes from the view model and does not change. Complete snippet:
fun NFCBottomSheet(
modifier: Modifier = Modifier,
events: LicenseDetailsEvents,
isVisible: Boolean,
title: String,
description: String,
totalSteps: Int,
currentStep: Int,
) {
val modalSheetState = rememberModalBottomSheetState(
skipPartiallyExpanded = true,
confirmValueChange = { false },
)
if (isVisible) {
ModalBottomSheet(
onDismissRequest = {},
modifier = modifier,
sheetState = modalSheetState,
shape = RoundedCornerShape(
topStart = largeCornerRadius.dp,
topEnd = largeCornerRadius.dp,
),
properties = ModalBottomSheetProperties(shouldDismissOnBackPress = false)
) {
NFCBottomSheetContent(
events = events,
title = title,
description = description,
totalSteps = totalSteps,
currentStep = currentStep,
)
}
}
}
rattleshirt
06/14/2024, 7:51 AMNFCBottomSheetContent
contains at some point:
fun NFCProgress(
modifier: Modifier = Modifier,
totalSteps: Int,
currentStep: Int,
) {
Column(
modifier = modifier.padding(vertical = nfcProgressSpacer.dp),
verticalArrangement = Arrangement.spacedBy(nfcProgressLoadingSpacer.dp),
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = defaultPagePadding.dp),
horizontalArrangement = Arrangement.spacedBy(nfcProgressStepGap.dp),
) {
(1..totalSteps).forEach {
NFCProgressStep(
modifier = Modifier.weight(1f),
totalSteps = totalSteps,
currentStep = currentStep,
position = it,
)
}
}
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.Center,
) {
CircularProgressIndicator(
modifier = Modifier
.size(buttonLoadingIndicatorSize.dp),
)
}
}
}
@Composable
fun NFCProgressStep(
modifier: Modifier = Modifier,
totalSteps: Int,
currentStep: Int,
position: Int,
) {
var progress by remember { mutableFloatStateOf(0f) }
val animatedProgress by animateFloatAsState(
targetValue = progress,
animationSpec = tween(),
label = "progress",
)
LaunchedEffect(progress, currentStep, position) {
progress = if (currentStep >= position) 1f else 0f
}
LinearProgressIndicator(
progress = { animatedProgress },
modifier = modifier
.height(nfcProgressStepHeight.dp)
.stepShape(totalSteps, position),
trackColor = Color.LightGray,
color = MaterialTheme.colorScheme.primary,
strokeCap = StrokeCap.Square,
drawStopIndicator = {},
)
}
rattleshirt
06/14/2024, 7:54 AMStylianos Gakis
06/14/2024, 8:03 AMSideEffect { Log.d("DEBUG", "isVisible:$isVisible") }
if (isVisible) {
Right above the isVisible check you do there, what does that print?Tolriq
06/14/2024, 8:04 AMrattleshirt
06/14/2024, 8:04 AMrattleshirt
06/14/2024, 8:08 AMisVisible
doesn’t change:
10:06:56.654 D DEBUG isVisible:false
10:07:00.633 D DEBUG isVisible:true
10:07:10.695 D DEBUG isVisible:true
10:07:30.772 D DEBUG isVisible:true
What I do see is that currentValue
stays Hidden
🤔Tolriq
06/14/2024, 8:11 AMconfirmValueChange = remember { { false } }
rattleshirt
06/14/2024, 8:12 AMStylianos Gakis
06/14/2024, 8:12 AMrattleshirt
06/14/2024, 8:13 AMStylianos Gakis
06/14/2024, 8:13 AMTolriq
06/14/2024, 8:14 AMM3 bottom sheets are notorious for having bugsYes they recently moved to popup and this broke edge to edge too 🙂 And no more answering on the issue.
Tolriq
06/14/2024, 8:14 AMTolriq
06/14/2024, 8:15 AM