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