feat: Preload emojis asynchronously and improve keyboard height handling in ChatDetailScreen
This commit is contained in:
@@ -38,6 +38,7 @@ import com.rosetta.messenger.ui.chats.ChatsListScreen
|
||||
import com.rosetta.messenger.ui.chats.ChatDetailScreen
|
||||
import com.rosetta.messenger.ui.chats.SearchScreen
|
||||
import com.rosetta.messenger.network.SearchUser
|
||||
import com.rosetta.messenger.ui.components.EmojiCache
|
||||
import com.rosetta.messenger.ui.onboarding.OnboardingScreen
|
||||
import com.rosetta.messenger.ui.splash.SplashScreen
|
||||
import com.rosetta.messenger.ui.theme.RosettaAndroidTheme
|
||||
@@ -58,6 +59,9 @@ class MainActivity : ComponentActivity() {
|
||||
// 🔥 Инициализируем ProtocolManager для обработки онлайн статусов
|
||||
ProtocolManager.initialize(this)
|
||||
|
||||
// 🚀 Предзагружаем эмодзи в фоне для мгновенного открытия пикера
|
||||
EmojiCache.preload(this)
|
||||
|
||||
setContent {
|
||||
val scope = rememberCoroutineScope()
|
||||
val isDarkTheme by preferencesManager.isDarkTheme.collectAsState(initial = true)
|
||||
|
||||
@@ -247,7 +247,15 @@ fun ChatDetailScreen(
|
||||
// Высота эмодзи панели - берём высоту клавиатуры если она открыта, иначе 280dp
|
||||
val imeInsets = WindowInsets.ime
|
||||
val imeHeight = with(density) { imeInsets.getBottom(density).toDp() }
|
||||
val emojiPanelHeight = if (imeHeight > 50.dp) imeHeight else 280.dp
|
||||
|
||||
// 🔥 Запоминаем высоту клавиатуры когда она открыта
|
||||
var savedKeyboardHeight by remember { mutableStateOf(280.dp) }
|
||||
LaunchedEffect(imeHeight) {
|
||||
if (imeHeight > 50.dp) {
|
||||
savedKeyboardHeight = imeHeight
|
||||
}
|
||||
}
|
||||
val emojiPanelHeight = savedKeyboardHeight
|
||||
|
||||
// 🔥 Reply/Forward state
|
||||
val replyMessages by viewModel.replyMessages.collectAsState()
|
||||
@@ -1927,8 +1935,16 @@ private fun MessageInputBar(
|
||||
val imeHeight = with(density) { imeInsets.getBottom(density).toDp() }
|
||||
val isKeyboardVisible = imeHeight > 0.dp
|
||||
|
||||
// Высота панели эмодзи = высота клавиатуры (или 280dp по умолчанию)
|
||||
val emojiPanelHeight = if (imeHeight > 50.dp) imeHeight else 280.dp
|
||||
// 🔥 Запоминаем высоту клавиатуры когда она открыта
|
||||
var savedKeyboardHeight by remember { mutableStateOf(280.dp) }
|
||||
LaunchedEffect(imeHeight) {
|
||||
if (imeHeight > 50.dp) {
|
||||
savedKeyboardHeight = imeHeight
|
||||
}
|
||||
}
|
||||
|
||||
// Высота панели эмодзи = сохранённая высота клавиатуры
|
||||
val emojiPanelHeight = savedKeyboardHeight
|
||||
|
||||
// Состояние отправки
|
||||
val canSend = remember(value) { value.isNotBlank() }
|
||||
|
||||
@@ -36,7 +36,6 @@ import coil.request.ImageRequest
|
||||
import com.rosetta.messenger.ui.onboarding.PrimaryBlue
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
/**
|
||||
@@ -608,15 +607,11 @@ fun AppleEmojiPickerPanel(
|
||||
var selectedCategory by remember { mutableStateOf(EMOJI_CATEGORIES[0]) }
|
||||
val gridState = rememberLazyGridState()
|
||||
|
||||
// 🚀 Предзагружаем эмодзи СИНХРОННО при создании компонента
|
||||
val emojisReady = remember {
|
||||
// 🚀 Загружаем эмодзи АСИНХРОННО - без блокировки UI
|
||||
LaunchedEffect(Unit) {
|
||||
if (!EmojiCache.isLoaded) {
|
||||
// Загружаем синхронно для мгновенного отображения
|
||||
runBlocking {
|
||||
EmojiCache.loadEmojis(context)
|
||||
}
|
||||
EmojiCache.loadEmojis(context)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
// Текущие эмодзи для выбранной категории - используем derivedStateOf для оптимизации
|
||||
|
||||
Reference in New Issue
Block a user