Skip to content

Commit 5f50e1b

Browse files
feat(designsystem): add message badge atoms (#10643)
2 parents 7c93e5d + 12797be commit 5f50e1b

2 files changed

Lines changed: 77 additions & 0 deletions

File tree

  • feature/mail/message/list/api/src
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package net.thunderbird.feature.mail.message.list.ui.component.atom
2+
3+
import androidx.compose.foundation.layout.Arrangement
4+
import androidx.compose.foundation.layout.Column
5+
import androidx.compose.foundation.layout.padding
6+
import androidx.compose.runtime.Composable
7+
import androidx.compose.ui.Modifier
8+
import androidx.compose.ui.tooling.preview.PreviewLightDark
9+
import app.k9mail.core.ui.compose.designsystem.PreviewWithThemesLightDark
10+
import app.k9mail.core.ui.compose.theme2.MainTheme
11+
12+
@PreviewLightDark
13+
@Composable
14+
private fun MessageBadgePreview() {
15+
PreviewWithThemesLightDark {
16+
Column(
17+
verticalArrangement = Arrangement.spacedBy(MainTheme.spacings.double),
18+
modifier = Modifier.padding(MainTheme.spacings.quadruple),
19+
) {
20+
NewMessageBadge(modifier = Modifier.padding(MainTheme.spacings.double))
21+
UnreadMessageBadge(modifier = Modifier.padding(MainTheme.spacings.double))
22+
}
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package net.thunderbird.feature.mail.message.list.ui.component.atom
2+
3+
import androidx.compose.foundation.background
4+
import androidx.compose.foundation.border
5+
import androidx.compose.foundation.layout.Box
6+
import androidx.compose.foundation.layout.padding
7+
import androidx.compose.foundation.layout.size
8+
import androidx.compose.foundation.shape.CircleShape
9+
import androidx.compose.runtime.Composable
10+
import androidx.compose.ui.Modifier
11+
import androidx.compose.ui.draw.clip
12+
import androidx.compose.ui.unit.dp
13+
import app.k9mail.core.ui.compose.theme2.MainTheme
14+
15+
/**
16+
* A composable function that displays a badge indicator for new messages.
17+
*
18+
* The badge is rendered as a small circular shape filled with the primary theme color,
19+
* typically used to indicate the presence of new unread messages in a message list or conversation.
20+
*
21+
* @param modifier The modifier to be applied to the badge container.
22+
*/
23+
@Composable
24+
fun NewMessageBadge(modifier: Modifier = Modifier) {
25+
Box(
26+
modifier = modifier
27+
.size(size = 14.dp)
28+
.padding(all = 1.dp)
29+
.clip(CircleShape)
30+
.background(MainTheme.colors.primary),
31+
)
32+
}
33+
34+
/**
35+
* A composable function that displays a badge indicator for unread messages.
36+
*
37+
* The badge is rendered as a small circular shape with a surface background color and
38+
* a primary-colored border, typically used to indicate the presence of unread messages
39+
* that are not new in a message list or conversation.
40+
*
41+
* @param modifier The modifier to be applied to the badge container.
42+
*/
43+
@Composable
44+
fun UnreadMessageBadge(modifier: Modifier = Modifier) {
45+
Box(
46+
modifier = modifier
47+
.size(MainTheme.sizes.badge)
48+
.padding(MainTheme.spacings.quarter)
49+
.clip(CircleShape)
50+
.background(MainTheme.colors.surface)
51+
.border(width = 2.dp, color = MainTheme.colors.primary, shape = CircleShape),
52+
)
53+
}

0 commit comments

Comments
 (0)