Created
August 1, 2021 17:34
-
-
Save ankitdubey021/49c1904e1477baa7c1513a870b8365e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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