Skip to content

Instantly share code, notes, and snippets.

@Pouyaa91
Created October 20, 2023 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pouyaa91/dd75b6ba7ba7dd90902ce16c0280a4d2 to your computer and use it in GitHub Desktop.
Save Pouyaa91/dd75b6ba7ba7dd90902ce16c0280a4d2 to your computer and use it in GitHub Desktop.
ExpandableSection
@Composable
fun ExpandableSection(
modifier: Modifier = Modifier,
title: String,
content: @Composable () -> Unit
) {
var isExpanded by rememberSaveable { mutableStateOf(false) }
Column(
modifier = modifier
.clickable { isExpanded = !isExpanded }
.background(color = MaterialTheme.colorScheme.primaryContainer)
.fillMaxWidth()
) {
ExpandableSectionTitle(isExpanded = isExpanded, title = title)
AnimatedVisibility(
modifier = Modifier
.background(MaterialTheme.colorScheme.secondaryContainer)
.fillMaxWidth(),
visible = isExpanded
) {
content()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment