-
-
Save sergey-ben/3622dd192d8e537c41b303cdd757b1fd to your computer and use it in GitHub Desktop.
PositioningIssue
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 CollapsibleContent() { | |
var innerBoxHeight by remember { | |
mutableStateOf(200.dp) | |
} | |
var outerBoxHeight by remember { | |
mutableStateOf(100.dp) | |
} | |
Column { | |
Row { | |
Button( | |
onClick = { | |
innerBoxHeight = 200.dp | |
outerBoxHeight = 200.dp | |
} | |
) { | |
Text(text = "Button 1") | |
} | |
Spacer(modifier = Modifier.width(8.dp)) | |
Button( | |
onClick = { | |
innerBoxHeight = 400.dp | |
outerBoxHeight = innerBoxHeight | |
} | |
) { | |
Text(text = "Button 2") | |
} | |
} | |
Row { | |
ComposableWithPositioningIssue( | |
outerBoxHeight = outerBoxHeight, | |
innerBoxHeight = innerBoxHeight, | |
) | |
} | |
} | |
} | |
@Composable | |
fun ComposableWithPositioningIssue( | |
innerBoxHeight: Dp, | |
outerBoxHeight: Dp | |
) { | |
Box( | |
modifier = Modifier | |
.height(outerBoxHeight) | |
.fillMaxWidth() | |
.clipToBounds() | |
.background(Color.DarkGray) | |
) { | |
Box( | |
modifier = Modifier | |
.requiredHeight(innerBoxHeight) | |
.fillMaxWidth() | |
.background(Color.Yellow) | |
) { | |
Text(text = "text") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment