Skip to content

Commit

Permalink
Shorten Animated Countdown timer
Browse files Browse the repository at this point in the history
  • Loading branch information
JackEblan committed Sep 20, 2024
1 parent 437a107 commit d534fa8
Showing 1 changed file with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,15 @@ private fun QuestionScreenTopBar(

Spacer(modifier = Modifier.width(5.dp))

Text(text = "$questionsWithSelectedChoicesSize", fontWeight = FontWeight.Bold)
AnimatedContent(
targetState = questionsWithSelectedChoicesSize,
transitionSpec = {
slideInVertically { it } togetherWith slideOutVertically { -it }
},
label = "",
) { state ->
Text(text = "$state", fontWeight = FontWeight.Bold)
}

if (countDownTime != null && countDownTime.isFinished.not()) {
Spacer(modifier = Modifier.width(20.dp))
Expand All @@ -375,7 +383,7 @@ private fun QuestionScreenTopBar(

Spacer(modifier = Modifier.width(5.dp))

Text(text = countDownTime.minutes, fontWeight = FontWeight.Bold)
AnimatedCountDownTimerText(text = countDownTime.minutes, fontWeight = FontWeight.Bold)
}
}
}
Expand Down Expand Up @@ -522,6 +530,31 @@ private fun QuestionChoicesSelection(
}
}

@Composable
private fun AnimatedCountDownTimerText(
modifier: Modifier = Modifier,
text: String,
fontWeight: FontWeight? = null,
) {
Row {
text.indices.forEach { i ->
AnimatedContent(
targetState = text[i],
transitionSpec = {
slideInVertically { it } togetherWith slideOutVertically { -it }
},
label = "",
) { char ->
Text(
text = "$char",
modifier = modifier,
fontWeight = fontWeight,
)
}
}
}
}

@Composable
private fun EmptyState(
modifier: Modifier = Modifier,
Expand Down

0 comments on commit d534fa8

Please sign in to comment.