ui adjustments

This commit is contained in:
Alex Yong 2025-09-10 19:39:11 +00:00
parent c12c128cb8
commit 0c7f90438a
3 changed files with 35 additions and 18 deletions

View File

@ -422,19 +422,19 @@ fun EmojiPicker(
modifier = Modifier.fillMaxWidth()
) {
Text(
text = "Recently Used",
style = MaterialTheme.typography.labelMedium,
modifier = Modifier.padding(start = 8.dp, bottom = 4.dp)
text = stringResource(R.string.emoji_picker_recently_used),
style = MaterialTheme.typography.labelSmall,
modifier = Modifier.padding(start = 8.dp, bottom = 2.dp)
)
Row(
modifier = Modifier
.horizontalScroll(rememberScrollState())
.padding(horizontal = 8.dp, vertical = 4.dp)
.padding(horizontal = 8.dp, vertical = 2.dp)
.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(8.dp)
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
recentEmojis.forEach { emoji ->
recentEmojis.take(8).forEach { emoji ->
if (emoji.matches(Regex(":[0-9A-Z]{26}:"))) {
val emojiId = emoji.removeSurrounding(":", ":")
RemoteImage(
@ -448,13 +448,13 @@ fun EmojiPicker(
EmojiUsageTracker.recordUsage(emoji)
onEmojiSelected(emoji)
}
.padding(8.dp)
.size(32.dp)
.padding(4.dp)
.size(28.dp)
)
} else {
Text(
text = emoji,
fontSize = 20.sp,
fontSize = 18.sp,
modifier = Modifier
.clip(CircleShape)
.clickable {
@ -462,15 +462,15 @@ fun EmojiPicker(
EmojiUsageTracker.recordUsage(emoji)
onEmojiSelected(emoji)
}
.padding(8.dp)
.size(32.dp),
.padding(4.dp)
.size(28.dp),
textAlign = TextAlign.Center
)
}
}
}
Spacer(Modifier.height(8.dp))
Spacer(Modifier.height(4.dp))
}
}

View File

@ -1,14 +1,12 @@
package chat.revolt.composables.generic
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.text.InlineTextContent
import androidx.compose.foundation.text.appendInlineContent
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.Placeholder
import androidx.compose.ui.text.PlaceholderVerticalAlign
@ -17,6 +15,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.unit.isUnspecified
import chat.revolt.api.REVOLT_FILES
import chat.revolt.composables.generic.RemoteImage
/**
* Text composable that automatically detects and renders custom emojis in the format :ULID:
@ -31,7 +30,7 @@ fun EmojiAwareText(
onTextLayout: ((androidx.compose.ui.text.TextLayoutResult) -> Unit)? = null
) {
val fontSize = LocalTextStyle.current.fontSize
val emojiSize = if (fontSize.isUnspecified) 16.sp else fontSize
val emojiSize = if (fontSize.isUnspecified) 24.sp else (fontSize * 1.5f)
val customEmojiRegex = Regex(":([0-9A-HJKMNP-TV-Z]{26}):")
val matches = customEmojiRegex.findAll(text.text).toList()
@ -42,6 +41,15 @@ fun EmojiAwareText(
modifier = modifier,
maxLines = maxLines,
inlineContent = inlineContent,
style = LocalTextStyle.current.copy(
lineHeight = if (LocalTextStyle.current.lineHeight.isUnspecified) {
(LocalTextStyle.current.fontSize * 1.5f)
} else {
val currentLineHeight = LocalTextStyle.current.lineHeight
val minLineHeight = LocalTextStyle.current.fontSize * 1.5f
if (currentLineHeight.value < minLineHeight.value) minLineHeight else currentLineHeight
}
),
onTextLayout = onTextLayout ?: {}
)
return
@ -98,7 +106,7 @@ fun EmojiAwareText(
placeholderKey to InlineTextContent(
placeholder = Placeholder(
width = emojiSize,
height = emojiSize,
height = emojiSize * 1.5f,
placeholderVerticalAlign = PlaceholderVerticalAlign.Center
)
) {
@ -106,8 +114,7 @@ fun EmojiAwareText(
url = "$REVOLT_FILES/emojis/$emojiId",
description = ":$emojiId:",
modifier = Modifier
.size(emojiSize.value.dp)
.clip(CircleShape)
.size(width = emojiSize.value.dp, height = (emojiSize.value * 1.5f).dp)
)
}
}
@ -119,6 +126,15 @@ fun EmojiAwareText(
inlineContent = mergedInlineContent,
modifier = modifier,
maxLines = maxLines,
style = LocalTextStyle.current.copy(
lineHeight = if (LocalTextStyle.current.lineHeight.isUnspecified) {
(LocalTextStyle.current.fontSize * 1.5f)
} else {
val currentLineHeight = LocalTextStyle.current.lineHeight
val minLineHeight = LocalTextStyle.current.fontSize * 1.5f
if (currentLineHeight.value < minLineHeight.value) minLineHeight else currentLineHeight
}
),
onTextLayout = onTextLayout ?: {}
)
}

View File

@ -620,6 +620,7 @@
<string name="emoji_picker_skin_tone_fitzpatrick_6">Dark skin tone</string>
<string name="emoji_picker_search_results_header">Search results</string>
<string name="emoji_picker_clear_search">Clear search</string>
<string name="emoji_picker_recently_used">Recently Used</string>
<string name="voice_join_offering">Join the voice channel</string>
<string name="voice_join_offering_description_zero">Start the call</string>