feat: Enhance packet sending logic to handle connection issues and implement swipe-to-reply functionality in chat UI
This commit is contained in:
@@ -206,7 +206,8 @@ fun AppleEmojiTextField(
|
||||
textColor: androidx.compose.ui.graphics.Color = androidx.compose.ui.graphics.Color.White,
|
||||
textSize: Float = 16f,
|
||||
hint: String = "Message",
|
||||
hintColor: androidx.compose.ui.graphics.Color = androidx.compose.ui.graphics.Color.Gray
|
||||
hintColor: androidx.compose.ui.graphics.Color = androidx.compose.ui.graphics.Color.Gray,
|
||||
onViewCreated: ((AppleEmojiEditTextView) -> Unit)? = null
|
||||
) {
|
||||
AndroidView(
|
||||
factory = { ctx ->
|
||||
@@ -219,6 +220,8 @@ fun AppleEmojiTextField(
|
||||
// Убираем все возможные фоны у EditText
|
||||
background = null
|
||||
setBackgroundColor(android.graphics.Color.TRANSPARENT)
|
||||
// Уведомляем о создании view
|
||||
onViewCreated?.invoke(this)
|
||||
}
|
||||
},
|
||||
update = { view ->
|
||||
|
||||
@@ -151,7 +151,10 @@ object EmojiCache {
|
||||
|
||||
// Предзагрузка при старте приложения (вызывать из Application или MainActivity)
|
||||
fun preload(context: Context) {
|
||||
if (allEmojis != null) return
|
||||
if (allEmojis != null) {
|
||||
isLoaded = true
|
||||
return
|
||||
}
|
||||
kotlinx.coroutines.CoroutineScope(Dispatchers.IO).launch {
|
||||
loadEmojisInternal(context)
|
||||
}
|
||||
@@ -356,19 +359,23 @@ fun AppleEmojiPickerPanel(
|
||||
var selectedCategory by remember { mutableStateOf(EMOJI_CATEGORIES[0]) }
|
||||
val gridState = rememberLazyGridState()
|
||||
|
||||
// Загружаем эмодзи если еще не загружены (без задержки если уже в кеше)
|
||||
// Загружаем эмодзи если еще не загружены (синхронно из кеша если уже загружено)
|
||||
LaunchedEffect(Unit) {
|
||||
if (!EmojiCache.isLoaded) {
|
||||
EmojiCache.loadEmojis(context)
|
||||
kotlinx.coroutines.launch(kotlinx.coroutines.Dispatchers.Main) {
|
||||
EmojiCache.loadEmojis(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Текущие эмодзи для выбранной категории
|
||||
val currentEmojis = remember(selectedCategory.key, EmojiCache.isLoaded) {
|
||||
if (EmojiCache.isLoaded) {
|
||||
EmojiCache.getEmojisForCategory(selectedCategory.key)
|
||||
} else {
|
||||
emptyList()
|
||||
// Текущие эмодзи для выбранной категории - используем derivedStateOf для оптимизации
|
||||
val currentEmojis by remember {
|
||||
derivedStateOf {
|
||||
if (EmojiCache.isLoaded) {
|
||||
EmojiCache.getEmojisForCategory(selectedCategory.key)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,10 +397,10 @@ fun AppleEmojiPickerPanel(
|
||||
LazyRow(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.background(categoryBarBackground)
|
||||
.padding(horizontal = 8.dp, vertical = 6.dp),
|
||||
.background(categoryBarBackground),
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 6.dp)
|
||||
) {
|
||||
items(EMOJI_CATEGORIES) { category ->
|
||||
CategoryButton(
|
||||
@@ -446,15 +453,15 @@ fun AppleEmojiPickerPanel(
|
||||
columns = GridCells.Fixed(8),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.weight(1f)
|
||||
.padding(horizontal = 4.dp),
|
||||
.weight(1f),
|
||||
horizontalArrangement = Arrangement.spacedBy(1.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(1.dp),
|
||||
contentPadding = PaddingValues(vertical = 4.dp)
|
||||
contentPadding = PaddingValues(horizontal = 12.dp, top = 4.dp, bottom = 16.dp)
|
||||
) {
|
||||
items(
|
||||
items = currentEmojis,
|
||||
key = { it }
|
||||
key = { emoji -> emoji },
|
||||
contentType = { "emoji" }
|
||||
) { unified ->
|
||||
EmojiButton(
|
||||
unified = unified,
|
||||
|
||||
Reference in New Issue
Block a user