Skip to content

Commit 5306757

Browse files
committed
chore(ui): update Badge to use Pill
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent bde7c8c commit 5306757

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

ui/components/src/main/kotlin/com/getcode/ui/components/Badge.kt

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import androidx.compose.animation.fadeIn
88
import androidx.compose.animation.fadeOut
99
import androidx.compose.animation.scaleIn
1010
import androidx.compose.animation.scaleOut
11+
import androidx.compose.foundation.layout.PaddingValues
1112
import androidx.compose.foundation.layout.padding
1213
import androidx.compose.material.Text
1314
import androidx.compose.runtime.Composable
@@ -31,24 +32,30 @@ fun Badge(
3132
enterTransition: EnterTransition = scaleIn(tween(durationMillis = 300)) + fadeIn(),
3233
exitTransition: ExitTransition = fadeOut() + scaleOut(tween(durationMillis = 300))
3334
) {
34-
AnimatedVisibility(modifier = modifier, visible = count > 0, enter = enterTransition, exit = exitTransition) {
35-
val text = when {
35+
AnimatedVisibility(
36+
modifier = modifier,
37+
visible = count > 0,
38+
enter = enterTransition,
39+
exit = exitTransition
40+
) {
41+
val text = when {
3642
count == 0 -> ""
3743
showMoreUnread -> "$count+"
3844
else -> "$count"
3945
}
4046

41-
Text(
42-
text = text,
43-
color = contentColor,
44-
style = textStyle,
45-
modifier = Modifier
46-
.drawBehind {
47-
drawCircle(
48-
color = color,
49-
radius = this.size.maxDimension / 2f
50-
)
51-
}.padding(1.dp)
52-
)
47+
Pill(
48+
backgroundColor = color,
49+
contentColor = contentColor,
50+
contentPadding = PaddingValues(
51+
horizontal = CodeTheme.dimens.grid.x1,
52+
vertical = 0.dp
53+
)
54+
) {
55+
Text(
56+
text = text,
57+
style = textStyle,
58+
)
59+
}
5360
}
5461
}

ui/components/src/main/kotlin/com/getcode/ui/components/chat/ChatNode.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import androidx.compose.ui.unit.dp
3333
import com.getcode.theme.CodeTheme
3434
import com.getcode.theme.White10
3535
import com.getcode.ui.components.Badge
36+
import com.getcode.ui.components.Pill
3637
import com.getcode.ui.components.R
3738
import com.getcode.ui.utils.rememberedClickable
3839
import com.getcode.util.DateUtils

0 commit comments

Comments
 (0)