|
@@ -1,12 +1,11 @@
|
|
|
package io.nexilis.alpha.ui.main
|
|
|
|
|
|
-import androidx.compose.animation.AnimatedVisibility
|
|
|
import androidx.compose.foundation.layout.*
|
|
|
import androidx.compose.foundation.lazy.LazyColumn
|
|
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
|
|
import androidx.compose.foundation.shape.CircleShape
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
-import androidx.compose.material.icons.filled.KeyboardDoubleArrowDown
|
|
|
+import androidx.compose.material.icons.filled.KeyboardArrowDown
|
|
|
import androidx.compose.material3.*
|
|
|
import androidx.compose.runtime.*
|
|
|
import androidx.compose.ui.Modifier
|
|
@@ -34,7 +33,7 @@ fun Chat(
|
|
|
me: Buddy
|
|
|
) {
|
|
|
val messageModel: MessageViewModel = hiltViewModel()
|
|
|
- val flow = remember { messageModel.getOpposite(pin) }
|
|
|
+ val flow = remember { messageModel.getOpposite(pin) }
|
|
|
val lazyPagingItems = flow.collectAsLazyPagingItems()
|
|
|
val listState = rememberLazyListState()
|
|
|
val scope = rememberCoroutineScope()
|
|
@@ -43,7 +42,7 @@ fun Chat(
|
|
|
.fillMaxSize()
|
|
|
.consumeWindowInsets(contentPadding)
|
|
|
.imePadding()
|
|
|
- .imeNestedScroll()
|
|
|
+// .imeNestedScroll()
|
|
|
) {
|
|
|
val (lazyColumn, fab, input) = createRefs()
|
|
|
LazyColumn(
|
|
@@ -55,7 +54,9 @@ fun Chat(
|
|
|
state = listState,
|
|
|
reverseLayout = true
|
|
|
) {
|
|
|
- items(count = lazyPagingItems.itemCount, key = lazyPagingItems.itemKey { it.message_id }) { index ->
|
|
|
+ items(
|
|
|
+ count = lazyPagingItems.itemCount,
|
|
|
+ key = lazyPagingItems.itemKey { it.message_id }) { index ->
|
|
|
lazyPagingItems[index]?.let { message ->
|
|
|
ListItem(modifier = Modifier.fillMaxWidth(), headlineContent = {
|
|
|
Row(
|
|
@@ -95,21 +96,22 @@ fun Chat(
|
|
|
listState.firstVisibleItemIndex > 0
|
|
|
}
|
|
|
}
|
|
|
- AnimatedVisibility(visible = showButton, modifier = Modifier.constrainAs(fab) {
|
|
|
- end.linkTo(parent.end)
|
|
|
- bottom.linkTo(input.top)
|
|
|
- }) {
|
|
|
+ if (showButton) {
|
|
|
Button(
|
|
|
onClick = {
|
|
|
scope.launch { listState.scrollToItem(0) }
|
|
|
},
|
|
|
modifier = Modifier
|
|
|
+ .constrainAs(fab) {
|
|
|
+ end.linkTo(parent.end)
|
|
|
+ bottom.linkTo(input.top)
|
|
|
+ }
|
|
|
.padding(end = 6.dp, bottom = 6.dp)
|
|
|
.size(32.dp),
|
|
|
shape = CircleShape,
|
|
|
contentPadding = PaddingValues(0.dp)
|
|
|
) {
|
|
|
- Icon(imageVector = Icons.Default.KeyboardDoubleArrowDown, contentDescription = "")
|
|
|
+ Icon(imageVector = Icons.Default.KeyboardArrowDown, contentDescription = "")
|
|
|
}
|
|
|
}
|
|
|
InputChat(
|