mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 00:59:49 +01:00
Member label performance optimizations.
This commit is contained in:
committed by
Greyson Parrelli
parent
80ff64ddd3
commit
a61072b249
@@ -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(
|
||||
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user