expand person bio card when tapping anywhere

This commit is contained in:
Owen LeJeune
2023-07-08 21:11:18 -04:00
parent bcb856bdf5
commit 1ff35387c8
2 changed files with 13 additions and 3 deletions

View File

@@ -79,12 +79,20 @@ fun ExpandableContentCard(
collapsedText: String = stringResource(id = R.string.expandable_see_more), collapsedText: String = stringResource(id = R.string.expandable_see_more),
expandedText: String = stringResource(id = R.string.expandable_see_less), expandedText: String = stringResource(id = R.string.expandable_see_less),
toggleTextColor: Color = MaterialTheme.colorScheme.onSurfaceVariant, toggleTextColor: Color = MaterialTheme.colorScheme.onSurfaceVariant,
content: @Composable (Boolean) -> Unit = {} expandOnTouchAnywhere: Boolean = false,
content: @Composable (Boolean) -> Unit
) { ) {
var expandedState by remember { mutableStateOf(false) } var expandedState by remember { mutableStateOf(false) }
Card( Card(
modifier = modifier, modifier = modifier.then(
Modifier.clickable(
enabled = expandOnTouchAnywhere,
onClick = {
expandedState = true
}
)
),
shape = RoundedCornerShape(10.dp), shape = RoundedCornerShape(10.dp),
elevation = CardDefaults.cardElevation(defaultElevation = 8.dp), elevation = CardDefaults.cardElevation(defaultElevation = 8.dp),
colors = CardDefaults.cardColors(containerColor = backgroundColor) colors = CardDefaults.cardColors(containerColor = backgroundColor)

View File

@@ -138,7 +138,9 @@ fun PersonDetailScreen(
@Composable @Composable
private fun BiographyCard(person: DetailPerson?) { private fun BiographyCard(person: DetailPerson?) {
if (person != null && person.biography.isNotEmpty()) { if (person != null && person.biography.isNotEmpty()) {
ExpandableContentCard { isExpanded -> ExpandableContentCard(
expandOnTouchAnywhere = true
) { isExpanded ->
Text( Text(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()