Skip to content

Instantly share code, notes, and snippets.

@tfaki
Created March 30, 2023 20:49
Show Gist options
  • Save tfaki/3db40d9e510bf045ab065db1ae84b8aa to your computer and use it in GitHub Desktop.
Save tfaki/3db40d9e510bf045ab065db1ae84b8aa to your computer and use it in GitHub Desktop.
Modifier Then Block
@Composable
fun WithThenBlock() {
var isExpanded by remember {
mutableStateOf(true)
}
Box(
modifier = Modifier
.height(50.dp)
.then(
if (isExpanded) {
isExpanded = false
Modifier.fillMaxWidth()
} else {
Modifier.fillMaxWidth(0.5f)
}
)
.background(Color.Blue)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment