Created
September 4, 2025 06:07
-
-
Save akshat12/d9b3a80622adc86902f93ab82d52bcd5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ConditionalColumnLayoutWithThreshold() { | |
| BoxWithConstraints(modifier = Modifier.fillMaxSize()) { | |
| // This '200.dp' is brittle and doesn't adapt to content changes! | |
| if (maxHeight > 200.dp) { | |
| Column { | |
| Text("Top Element", Modifier.background(Color.Yellow).height(100.dp)) | |
| Text("Middle Element", Modifier.background(Color.Green).height(50.dp)) | |
| Text("Bottom Element", Modifier.background(Color.Blue).height(50.dp)) | |
| } | |
| } else { | |
| Column { | |
| Text("Middle Element", Modifier.background(Color.Green).height(50.dp)) | |
| Text("Bottom Element", Modifier.background(Color.Blue).height(50.dp)) | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment