Кнопка вниз
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -47,7 +47,10 @@ import android.Manifest
|
||||
import android.content.pm.PackageManager
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.ui.draw.shadow
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.BasicTextField
|
||||
import androidx.compose.ui.unit.sp
|
||||
@@ -70,6 +73,7 @@ fun ChatDetailScreen(
|
||||
val context = LocalContext.current
|
||||
val listState = rememberLazyListState()
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
val voiceRecorder = remember { VoiceRecorder(context) }
|
||||
var isEmojiPickerVisible by remember { mutableStateOf(false) }
|
||||
var isRecording by remember { mutableStateOf(false) }
|
||||
@@ -179,15 +183,11 @@ fun ChatDetailScreen(
|
||||
|
||||
// Показывать ли кнопку "вниз"
|
||||
// Она должна появляться если мы не в самом низу
|
||||
// Проверка видимости кнопки скролла вниз
|
||||
val showScrollToBottom by remember {
|
||||
derivedStateOf {
|
||||
val layoutInfo = listState.layoutInfo
|
||||
if (layoutInfo.totalItemsCount == 0) return@derivedStateOf false
|
||||
|
||||
val lastVisibleIndex = layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: 0
|
||||
// Показываем, если не в самом низу (с запасом 1-2 элемента)
|
||||
lastVisibleIndex < listItems.size - 2
|
||||
}
|
||||
derivedStateOf {
|
||||
listState.firstVisibleItemIndex > 5
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Авто-скролл к новым сообщениям
|
||||
@@ -420,19 +420,26 @@ fun ChatDetailScreen(
|
||||
.align(Alignment.BottomEnd)
|
||||
.padding(bottom = 16.dp, end = 16.dp)
|
||||
) {
|
||||
FloatingActionButton(
|
||||
onClick = {
|
||||
scope.launch {
|
||||
listState.animateScrollToItem(listItems.size - 1)
|
||||
}
|
||||
},
|
||||
containerColor = MaterialTheme.colorScheme.surface,
|
||||
contentColor = MaterialTheme.colorScheme.primary,
|
||||
shape = CircleShape,
|
||||
modifier = Modifier.size(44.dp),
|
||||
elevation = FloatingActionButtonDefaults.elevation(2.dp)
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(44.dp)
|
||||
.shadow(8.dp, CircleShape)
|
||||
.clip(CircleShape)
|
||||
.background(MaterialTheme.colorScheme.surface.copy(alpha = 0.6f))
|
||||
.border(0.5.dp, Color.White.copy(alpha = 0.3f), CircleShape)
|
||||
.clickable {
|
||||
scope.launch {
|
||||
listState.animateScrollToItem(0)
|
||||
}
|
||||
},
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Icon(Icons.Default.KeyboardArrowDown, contentDescription = null)
|
||||
Icon(
|
||||
Icons.Default.KeyboardArrowDown,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.size(28.dp)
|
||||
)
|
||||
}
|
||||
|
||||
if (unreadCount > 0) {
|
||||
|
||||
Reference in New Issue
Block a user