Skip to content

Instantly share code, notes, and snippets.

@ankitdubey021
Created August 1, 2021 17:34
Show Gist options
  • Save ankitdubey021/49c1904e1477baa7c1513a870b8365e6 to your computer and use it in GitHub Desktop.
Save ankitdubey021/49c1904e1477baa7c1513a870b8365e6 to your computer and use it in GitHub Desktop.
@ExperimentalAnimationApi
@ExperimentalMaterialApi
@Composable
fun MyExpandedList() {
var expanded by remember { mutableStateOf(false) }
val rotateState = animateFloatAsState(
targetValue = if (expanded) 180F else 0F,
)
Column(
modifier = Modifier
.fillMaxWidth()
) {
Card(onClick = { expanded = !expanded }) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "This is header",
modifier = Modifier.fillMaxWidth(0.92F),
style = MaterialTheme.typography.subtitle1
)
Icon(
Icons.Default.ArrowDropDown, "",
modifier = Modifier.rotate(rotateState.value)
)
}
}
Divider()
AnimatedVisibility(
visible = expanded,
) {
Column(
modifier = Modifier
.fillMaxWidth()
.background(Color.LightGray)
.padding(16.dp)
) {
Text(text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment