A full-width count tile lays out in a row (#59)
This commit is contained in:
1 parent
631a371e58
commit
844fd4fe9b
1 file changed
+30
-3
@@ -283,7 +283,7 @@ internal fun Tile(block: Block, state: ListsUiState.Content, actions: BlockActio
|
||||
}
|
||||
}
|
||||
is BlockOptions.CountTile -> state.counts[block.id]?.takeIf { filter != null }?.let { count ->
|
||||
CountCard(tileStyle(block, options, state), count, marked, modifier, open)
|
||||
CountCard(tileStyle(block, options, state), count, marked, block.width == BlockWidth.FULL, modifier, open)
|
||||
}
|
||||
else -> null
|
||||
} ?: Spacer(modifier.height(FloretDensity.tileHeight))
|
||||
@@ -539,7 +539,14 @@ internal fun tileColors(color: TileColor): Pair<Color, Color> {
|
||||
* silhouette. Full width it lays out in a row: icon and name, count at the end.
|
||||
*/
|
||||
@Composable
|
||||
private fun CountCard(style: TileStyle, count: Int, marked: Boolean, modifier: Modifier = Modifier, onClick: () -> Unit) {
|
||||
private fun CountCard(
|
||||
style: TileStyle,
|
||||
count: Int,
|
||||
marked: Boolean,
|
||||
full: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
val interaction = remember { MutableInteractionSource() }
|
||||
Surface(
|
||||
onClick = onClick,
|
||||
@@ -547,8 +554,28 @@ private fun CountCard(style: TileStyle, count: Int, marked: Boolean, modifier: M
|
||||
color = style.container,
|
||||
contentColor = style.onContainer,
|
||||
interactionSource = interaction,
|
||||
modifier = modifier.height(FloretDensity.tileHeight),
|
||||
modifier = modifier.height(if (full) FloretDensity.rowHeight else FloretDensity.tileHeight),
|
||||
) {
|
||||
if (full) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxSize().padding(horizontal = 20.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
||||
) {
|
||||
Icon(style.icon, contentDescription = null)
|
||||
Text(
|
||||
style.label,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.weight(1f, fill = false),
|
||||
)
|
||||
if (marked) IgnoredScopeMark(style.onContainer)
|
||||
Spacer(Modifier.weight(1f))
|
||||
Text(count.toString(), style = MaterialTheme.typography.headlineSmall)
|
||||
}
|
||||
return@Surface
|
||||
}
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize().padding(byDensity(16.dp, 12.dp)),
|
||||
verticalArrangement = Arrangement.SpaceBetween,
|
||||
|
||||
Reference in new issue
Block a user