Skip to content

Instantly share code, notes, and snippets.

@zurche
Created July 27, 2023 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zurche/b8000eb13dfff704bbde0ac877ecf744 to your computer and use it in GitHub Desktop.
Save zurche/b8000eb13dfff704bbde0ac877ecf744 to your computer and use it in GitHub Desktop.
@Composable
fun MonthlyCapPreview(monthlyPreview: List<Pair<String, Float>>) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
val maxMonthValue = monthlyPreview.maxBy { it.second }.second
Row(
modifier = Modifier.fillMaxHeight(.8f),
verticalAlignment = Alignment.Bottom
) {
for (pairPreview in monthlyPreview) {
val columnHeightWeight = pairPreview.second / maxMonthValue
Card(
modifier = Modifier
.weight(1f)
.fillMaxHeight(columnHeightWeight)
.padding(5.dp)
) { }
}
}
Row(
verticalAlignment = Alignment.CenterVertically
) {
for (pairPreview in monthlyPreview) {
Text(
modifier = Modifier.weight(1f),
text = pairPreview.first,
textAlign = TextAlign.Center
)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment