mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-15 02:57:04 +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
|
@Composable
|
||||||
private fun CommentsButton(commentCount: Int, modifier: Modifier = Modifier) {
|
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(
|
BadgedBox(
|
||||||
modifier = modifier.minimumInteractiveComponentSize(),
|
modifier = modifier.minimumInteractiveComponentSize(),
|
||||||
badge = {
|
badge = {
|
||||||
Badge(
|
Badge(
|
||||||
containerColor = MaterialTheme.colorScheme.tertiaryContainer,
|
containerColor = MaterialTheme.colorScheme.tertiaryContainer,
|
||||||
modifier = Modifier.absoluteOffset(y = (-8).dp),
|
modifier = Modifier.absoluteOffset(x = offset.dp, y = (-8).dp),
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = commentCount.toString(),
|
text = commentCount.toString(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue