|
@@ -5,6 +5,7 @@ import androidx.compose.foundation.background
|
|
|
import androidx.compose.foundation.layout.*
|
|
|
import androidx.compose.foundation.lazy.LazyColumn
|
|
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
|
|
+import androidx.compose.foundation.lazy.items
|
|
|
import androidx.compose.foundation.shape.CircleShape
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
import androidx.compose.foundation.text.KeyboardOptions
|
|
@@ -38,10 +39,11 @@ import io.nexilis.service.data.viewmodels.MessageViewModel
|
|
|
import kotlinx.serialization.encodeToString
|
|
|
import kotlinx.serialization.json.Json
|
|
|
|
|
|
+@OptIn(ExperimentalLayoutApi::class)
|
|
|
@Composable
|
|
|
fun Chat(
|
|
|
navController: NavHostController,
|
|
|
- contentPadding: PaddingValues = PaddingValues(0.dp),
|
|
|
+ contentPadding: PaddingValues,
|
|
|
pin: String,
|
|
|
me: Buddy
|
|
|
) {
|
|
@@ -52,28 +54,25 @@ fun Chat(
|
|
|
val list by messageModel.getOpposite(pin).observeAsState()
|
|
|
val state = rememberLazyListState()
|
|
|
val context = LocalContext.current
|
|
|
- LaunchedEffect(key1 = list) {
|
|
|
- list?.size?.let { size ->
|
|
|
- if (size > 0) {
|
|
|
- size.minus(1).let { state.scrollToItem(it) }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
var openAlertDialog by remember { mutableStateOf(false) }
|
|
|
val attachments = remember { mutableStateListOf<Uri>() }
|
|
|
Column(
|
|
|
modifier = Modifier
|
|
|
.fillMaxSize()
|
|
|
.background(color = MaterialTheme.colorScheme.surfaceContainer)
|
|
|
- .padding(contentPadding)
|
|
|
+ .consumeWindowInsets(contentPadding)
|
|
|
+ .imePadding()
|
|
|
+ .imeNestedScroll()
|
|
|
) {
|
|
|
LazyColumn(
|
|
|
- modifier = Modifier.weight(1.0f),
|
|
|
- state = state
|
|
|
+ modifier = Modifier
|
|
|
+ .weight(1f),
|
|
|
+ state = state,
|
|
|
+// contentPadding = contentPadding,
|
|
|
+ reverseLayout = true
|
|
|
) {
|
|
|
- items(count = list?.size ?: 0) {
|
|
|
- list?.let { l ->
|
|
|
- val message = l[it]
|
|
|
+ list?.let { l ->
|
|
|
+ items(l) { message ->
|
|
|
ListItem(modifier = Modifier.fillMaxWidth(), headlineContent = {
|
|
|
Row(
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
@@ -105,7 +104,6 @@ fun Chat(
|
|
|
}
|
|
|
}, colors = ListItemDefaults.colors(containerColor = Color.Transparent))
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
TextField(
|