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