mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 22:17:03 +05:30
fix: add extra offset to comment counts when required
This commit is contained in:
parent
30d035baa2
commit
b6169ca5ca
1 changed files with 10 additions and 1 deletions
|
@ -190,12 +190,21 @@ private fun SaveButton(isSaved: () -> Boolean, onClick: () -> Unit, modifier: Mo
|
|||
|
||||
@Composable
|
||||
private fun CommentsButton(commentCount: Int, modifier: Modifier = Modifier) {
|
||||
val offset = run {
|
||||
var count = commentCount
|
||||
var digits = 1
|
||||
while (count > 10) {
|
||||
count /= 10
|
||||
digits += 1
|
||||
}
|
||||
if (digits < 3) 0 else digits * -2
|
||||
}
|
||||
BadgedBox(
|
||||
modifier = modifier.minimumInteractiveComponentSize(),
|
||||
badge = {
|
||||
Badge(
|
||||
containerColor = MaterialTheme.colorScheme.tertiaryContainer,
|
||||
modifier = Modifier.absoluteOffset(y = (-8).dp),
|
||||
modifier = Modifier.absoluteOffset(x = offset.dp, y = (-8).dp),
|
||||
) {
|
||||
Text(
|
||||
text = commentCount.toString(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue