Skip to content

Commit 976ff8a

Browse files
committed
refactor(message-list): use Box instead of Surface for MessageConversationCounterBadge and improve height calculation
1 parent 897fed1 commit 976ff8a

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

feature/mail/message/list/api/src/main/kotlin/net/thunderbird/feature/mail/message/list/ui/component/molecule/MessageConversationCounterBadge.kt

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
package net.thunderbird.feature.mail.message.list.ui.component.molecule
22

3+
import androidx.compose.foundation.background
34
import androidx.compose.foundation.border
5+
import androidx.compose.foundation.layout.Box
46
import androidx.compose.foundation.layout.padding
57
import androidx.compose.runtime.Composable
8+
import androidx.compose.ui.Alignment
69
import androidx.compose.ui.Modifier
710
import androidx.compose.ui.graphics.Color
811
import androidx.compose.ui.text.SpanStyle
912
import androidx.compose.ui.text.buildAnnotatedString
1013
import androidx.compose.ui.text.font.FontWeight
1114
import androidx.compose.ui.text.withStyle
1215
import androidx.compose.ui.unit.dp
13-
import app.k9mail.core.ui.compose.designsystem.atom.Surface
1416
import app.k9mail.core.ui.compose.designsystem.atom.text.TextLabelSmall
1517
import app.k9mail.core.ui.compose.theme2.MainTheme
1618

19+
internal const val MESSAGE_CONVERSATION_COUNTER_BADGE_PADDING = 3
20+
1721
/**
1822
* A composable that displays a message conversation counter badge with a customizable appearance.
1923
*
@@ -36,15 +40,19 @@ internal fun MessageConversationCounterBadge(
3640
modifier: Modifier = Modifier,
3741
limit: Int = MessageConversationCounterBadgeDefaults.CONVERSATION_COUNTER_LIMIT,
3842
) {
39-
Surface(
40-
color = color.containerColor,
41-
contentColor = color.contentColor,
42-
shape = MainTheme.shapes.large,
43-
modifier = modifier.border(
44-
width = 1.dp,
45-
color = color.borderColor ?: color.containerColor,
46-
shape = MainTheme.shapes.large,
47-
),
43+
Box(
44+
modifier = modifier
45+
.background(
46+
color = color.containerColor,
47+
shape = MainTheme.shapes.large,
48+
)
49+
.border(
50+
width = 1.dp,
51+
color = color.borderColor ?: color.containerColor,
52+
shape = MainTheme.shapes.large,
53+
)
54+
.padding(horizontal = MainTheme.spacings.half, vertical = MESSAGE_CONVERSATION_COUNTER_BADGE_PADDING.dp),
55+
contentAlignment = Alignment.Center,
4856
) {
4957
TextLabelSmall(
5058
text = buildAnnotatedString {
@@ -55,7 +63,7 @@ internal fun MessageConversationCounterBadge(
5563
}
5664
}
5765
},
58-
modifier = Modifier.padding(horizontal = MainTheme.spacings.half, vertical = MainTheme.spacings.quarter),
66+
color = color.contentColor,
5967
)
6068
}
6169
}

0 commit comments

Comments
 (0)