Member label performance optimizations.

This commit is contained in:
jeffrey-signal
2026-04-08 11:48:41 -04:00
committed by Greyson Parrelli
parent 80ff64ddd3
commit a61072b249
2 changed files with 40 additions and 24 deletions

View File

@@ -16,6 +16,7 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ProvideTextStyle
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
@@ -54,12 +55,16 @@ fun MemberLabelPill(
maxLines: Int = 1
) {
val isDark = isSystemInDarkTheme()
val backgroundColor = tintColor.copy(alpha = if (isDark) 0.32f else 0.10f)
val backgroundColor = remember(isDark, tintColor) {
tintColor.copy(alpha = if (isDark) 0.32f else 0.10f)
}
val textColor = if (isDark) {
Color.White.copy(alpha = 0.25f).compositeOver(tintColor)
} else {
Color.Black.copy(alpha = 0.30f).compositeOver(tintColor)
val textColor = remember(isDark, tintColor) {
if (isDark) {
Color.White.copy(alpha = 0.25f).compositeOver(tintColor)
} else {
Color.Black.copy(alpha = 0.30f).compositeOver(tintColor)
}
}
MemberLabelPill(

View File

@@ -97,27 +97,38 @@ private fun SenderNameWithLabel(
modifier: Modifier = Modifier,
labelSlot: @Composable (MemberLabel) -> Unit
) {
FlowRow(
modifier = modifier,
horizontalArrangement = Arrangement.spacedBy(4.dp),
verticalArrangement = Arrangement.spacedBy(2.dp),
itemVerticalAlignment = Alignment.CenterVertically
) {
ProvideTextStyle(MaterialTheme.typography.labelMedium.copy(fontWeight = FontWeight.Bold)) {
Emojifier(text = senderName) { annotatedText, inlineContent ->
Text(
text = annotatedText,
inlineContent = inlineContent,
color = senderColor,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
}
if (memberLabel != null) {
if (memberLabel != null) {
FlowRow(
modifier = modifier,
horizontalArrangement = Arrangement.spacedBy(4.dp),
verticalArrangement = Arrangement.spacedBy(2.dp),
itemVerticalAlignment = Alignment.CenterVertically
) {
SenderNameText(senderName, senderColor)
labelSlot(memberLabel)
}
} else {
SenderNameText(senderName, senderColor, modifier)
}
}
@Composable
private fun SenderNameText(
senderName: String,
senderColor: Color,
modifier: Modifier = Modifier
) {
ProvideTextStyle(MaterialTheme.typography.labelMedium.copy(fontWeight = FontWeight.Bold)) {
Emojifier(text = senderName) { annotatedText, inlineContent ->
Text(
modifier = modifier,
text = annotatedText,
inlineContent = inlineContent,
color = senderColor,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
}
}