Created
July 27, 2023 13:11
-
-
Save zurche/dfee403ce05e29687c95160a2265c103 to your computer and use it in GitHub Desktop.
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 MonthlyCapPreview(monthlyPreview: List<Pair<String, Float>>) { | |
val maxMonthValue = monthlyPreview.maxBy { it.second }.second //<-- We find the max Float value of our Pair List | |
Row( | |
modifier = Modifier.fillMaxSize(), | |
verticalAlignment = Alignment.Bottom //<--- This is important to align them as required by spec | |
) { | |
for (pairPreview in monthlyPreview) { | |
val columnHeightWeight = pairPreview.second / maxMonthValue //<-- We use it to get a value between 0 and 1 | |
Card( | |
modifier = Modifier | |
.weight(1f) | |
.fillMaxHeight(columnHeightWeight) //<-- Pass it through the modifier to determine Its height | |
.padding(5.dp) | |
) { | |
Text(text = pairPreview.first) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment