feat: Add message count query to MessageDao, enhance ChatDetailScreen with auto-focus on reply input, and improve read receipt handling in ChatViewModel
This commit is contained in:
@@ -207,8 +207,22 @@ fun AppleEmojiTextField(
|
||||
textSize: Float = 16f,
|
||||
hint: String = "Message",
|
||||
hintColor: androidx.compose.ui.graphics.Color = androidx.compose.ui.graphics.Color.Gray,
|
||||
onViewCreated: ((AppleEmojiEditTextView) -> Unit)? = null
|
||||
onViewCreated: ((AppleEmojiEditTextView) -> Unit)? = null,
|
||||
requestFocus: Boolean = false
|
||||
) {
|
||||
// Храним ссылку на view для управления фокусом
|
||||
var editTextView by remember { mutableStateOf<AppleEmojiEditTextView?>(null) }
|
||||
|
||||
// 🔥 Автоматический запрос фокуса когда requestFocus = true
|
||||
LaunchedEffect(requestFocus) {
|
||||
if (requestFocus && editTextView != null) {
|
||||
editTextView?.requestFocus()
|
||||
// Показываем клавиатуру
|
||||
val imm = editTextView?.context?.getSystemService(android.content.Context.INPUT_METHOD_SERVICE) as? android.view.inputmethod.InputMethodManager
|
||||
imm?.showSoftInput(editTextView, android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT)
|
||||
}
|
||||
}
|
||||
|
||||
AndroidView(
|
||||
factory = { ctx ->
|
||||
AppleEmojiEditTextView(ctx).apply {
|
||||
@@ -220,6 +234,8 @@ fun AppleEmojiTextField(
|
||||
// Убираем все возможные фоны у EditText
|
||||
background = null
|
||||
setBackgroundColor(android.graphics.Color.TRANSPARENT)
|
||||
// Сохраняем ссылку на view
|
||||
editTextView = this
|
||||
// Уведомляем о создании view
|
||||
onViewCreated?.invoke(this)
|
||||
}
|
||||
@@ -249,7 +265,8 @@ fun AppleEmojiText(
|
||||
text: String,
|
||||
modifier: Modifier = Modifier,
|
||||
color: androidx.compose.ui.graphics.Color = androidx.compose.ui.graphics.Color.White,
|
||||
fontSize: androidx.compose.ui.unit.TextUnit = androidx.compose.ui.unit.TextUnit.Unspecified
|
||||
fontSize: androidx.compose.ui.unit.TextUnit = androidx.compose.ui.unit.TextUnit.Unspecified,
|
||||
fontWeight: androidx.compose.ui.text.font.FontWeight? = null
|
||||
) {
|
||||
val fontSizeValue = if (fontSize == androidx.compose.ui.unit.TextUnit.Unspecified) 15f
|
||||
else fontSize.value
|
||||
@@ -257,17 +274,29 @@ fun AppleEmojiText(
|
||||
// Минимальная высота для корректного отображения emoji
|
||||
val minHeight = (fontSizeValue * 1.5).toInt()
|
||||
|
||||
// Преобразуем FontWeight в Android typeface style
|
||||
val typefaceStyle = when (fontWeight) {
|
||||
androidx.compose.ui.text.font.FontWeight.Bold,
|
||||
androidx.compose.ui.text.font.FontWeight.ExtraBold,
|
||||
androidx.compose.ui.text.font.FontWeight.Black,
|
||||
androidx.compose.ui.text.font.FontWeight.SemiBold -> android.graphics.Typeface.BOLD
|
||||
androidx.compose.ui.text.font.FontWeight.Medium -> android.graphics.Typeface.NORMAL // Medium не поддерживается напрямую
|
||||
else -> android.graphics.Typeface.NORMAL
|
||||
}
|
||||
|
||||
AndroidView(
|
||||
factory = { ctx ->
|
||||
AppleEmojiTextView(ctx).apply {
|
||||
setTextColor(color.toArgb())
|
||||
setTextSize(fontSizeValue)
|
||||
minimumHeight = (minHeight * ctx.resources.displayMetrics.density).toInt()
|
||||
setTypeface(typeface, typefaceStyle)
|
||||
}
|
||||
},
|
||||
update = { view ->
|
||||
view.setTextWithEmojis(text)
|
||||
view.setTextColor(color.toArgb())
|
||||
view.setTypeface(view.typeface, typefaceStyle)
|
||||
},
|
||||
modifier = modifier
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user