Skip to content

Instantly share code, notes, and snippets.

@zurche
Created July 27, 2023 13:17
Show Gist options
  • Save zurche/4893463dd1d5de7acf6272092744b728 to your computer and use it in GitHub Desktop.
Save zurche/4893463dd1d5de7acf6272092744b728 to your computer and use it in GitHub Desktop.
@Composable
fun MonthlyCapPreview(monthlyPreview: List<Pair<String, Float>>) {
val maxMonthValue = monthlyPreview.maxBy { it.second }.second
Row(
modifier = Modifier.fillMaxSize(),
verticalAlignment = Alignment.Bottom
) {
for (pairPreview in monthlyPreview) {
val columnHeightWeight = pairPreview.second / maxMonthValue
BarView(
modifier = Modifier
.weight(1f)
.fillMaxHeight(columnHeightWeight),
name = pairPreview.first
)
}
}
}
@Composable
@Preview
private fun BarView(modifier: Modifier = Modifier, name: String = "Jan") {
Card(
modifier = modifier.padding(5.dp)
) {
Text(text = name)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment