hawklike
05/02/2023, 8:36 AMhawklike
05/02/2023, 8:37 AM@Composable
fun Questionnaire(answers: List<Answer>) {
LazyColumn {
nodes(answers)
}
}
fun LazyListScope.nodes(answers: List<Answer>) {
nodes.forEach { answer ->
node(answer)
}
}
fun LazyListScope.node(answer: Answer) {
item {
Text(answer.content)
}
if(answer.selected) {
nodes(answer.subAnswers)
}
}
As you can see, sub-answers are visible only if the parent answer is selected. It works well, however, is it possible to animate the visibility of such a group of sub-answers?
Something like this:
fun LazyListScope.node(answer: Answer) {
item {
Text(answer.content)
}
// Needs context of a @Composable function, will not compile
AnimatedVisibility(visible = answer.selected) {
nodes(answer.subAnswers)
}
}
I will appreciate any help 🙏shikasd
05/02/2023, 5:29 PM