feat: Implement back gesture handling in SearchScreen for improved navigation
This commit is contained in:
@@ -2,6 +2,7 @@ package com.rosetta.messenger.ui.chats
|
||||
|
||||
import android.content.Context
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.animation.core.*
|
||||
import androidx.compose.foundation.*
|
||||
@@ -62,9 +63,11 @@ fun SearchScreen(
|
||||
}
|
||||
|
||||
// Цвета ТОЧНО как в ChatsListScreen - remember для избежания пересоздания
|
||||
val backgroundColor = remember(isDarkTheme) { if (isDarkTheme) Color(0xFF1A1A1A) else Color(0xFFFFFFFF) }
|
||||
val backgroundColor =
|
||||
remember(isDarkTheme) { if (isDarkTheme) Color(0xFF1A1A1A) else Color(0xFFFFFFFF) }
|
||||
val textColor = remember(isDarkTheme) { if (isDarkTheme) Color.White else Color(0xFF1a1a1a) }
|
||||
val secondaryTextColor = remember(isDarkTheme) { if (isDarkTheme) Color(0xFFB0B0B0) else Color(0xFF6c757d) }
|
||||
val secondaryTextColor =
|
||||
remember(isDarkTheme) { if (isDarkTheme) Color(0xFFB0B0B0) else Color(0xFF6c757d) }
|
||||
|
||||
// 🔥 ОПТИМИЗАЦИЯ: Отложенный рендеринг контента для плавной анимации перехода
|
||||
var isContentReady by remember { mutableStateOf(false) }
|
||||
@@ -79,13 +82,18 @@ fun SearchScreen(
|
||||
val recentUsers by RecentSearchesManager.recentUsers.collectAsState()
|
||||
|
||||
// 🔥 ОПТИМИЗАЦИЯ: Lottie загружается асинхронно и не блокирует первый кадр
|
||||
val searchLottieComposition by rememberLottieComposition(
|
||||
LottieCompositionSpec.RawRes(R.raw.search)
|
||||
)
|
||||
val searchLottieComposition by
|
||||
rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.search))
|
||||
|
||||
// Focus requester для автофокуса
|
||||
val focusRequester = remember { FocusRequester() }
|
||||
|
||||
// 🔥 Обработка системного жеста Back
|
||||
BackHandler {
|
||||
hideKeyboardInstantly()
|
||||
onBackClick()
|
||||
}
|
||||
|
||||
// 🔥 ОПТИМИЗАЦИЯ: Все тяжелые операции выполняем после первого кадра
|
||||
LaunchedEffect(Unit) {
|
||||
// Даем анимации перехода завершиться
|
||||
@@ -204,15 +212,16 @@ fun SearchScreen(
|
||||
) { paddingValues ->
|
||||
// Контент - показываем recent users если поле пустое, иначе результаты
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(paddingValues)
|
||||
// 🔥 ОПТИМИЗАЦИЯ: Скрываем контент до готовности без блокировки рендера
|
||||
.drawWithContent {
|
||||
if (isContentReady) {
|
||||
drawContent()
|
||||
}
|
||||
}
|
||||
modifier =
|
||||
Modifier.fillMaxSize()
|
||||
.padding(paddingValues)
|
||||
// 🔥 ОПТИМИЗАЦИЯ: Скрываем контент до готовности без блокировки
|
||||
// рендера
|
||||
.drawWithContent {
|
||||
if (isContentReady) {
|
||||
drawContent()
|
||||
}
|
||||
}
|
||||
) {
|
||||
if (searchQuery.isEmpty() && recentUsers.isNotEmpty()) {
|
||||
// Recent Users с аватарками
|
||||
|
||||
Reference in New Issue
Block a user