Created
October 20, 2023 00:22
-
-
Save Pouyaa91/dd75b6ba7ba7dd90902ce16c0280a4d2 to your computer and use it in GitHub Desktop.
ExpandableSection
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
@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