I have a simple CountDown indicator which is made like so:
@Composable
fun BreakPopup(
duration: ZbTimeData,
onTimeFinished: () -> Unit,
) {
var progress by remember {
mutableStateOf(1F)
}
val animatedProgress by animateFloatAsState(
targetValue = progress,
animationSpec = tween(
durationMillis = duration.millis.toInt(),
easing = LinearEasing
),
finishedListener = {
onTimeFinished()
}
)
LaunchedEffect(Unit) {
progress = 0F
}
// Etc...
RoundedCornersCircularProgressIndicator(
progress = animatedProgress,
color = textColor,
strokeWidth = 8.dp,
modifier = Modifier
.fillMaxSize()
.padding(8.dp)
)
And I show it in a simple window
Window(
visible = isPopupWindowVisible
) {
BreakPopup(message = settings.value.breakMessage,
duration = settings.value.breakDuration,
onTimeFinished = {
isPopupWindowVisible = false
},
)
}
I’m encountering a weird issue where
the composable doesn’t seem to get disposed when the window is not visible anymore, because the first time it works correctly, while from the second time and on the progress is already at
0F
, and it seems like it’s holding the same composable with the old values instead of recreating it when the window is not visible anymore