1
- @file:Suppress(" LocalVariableName" , " FunctionName" , " SpellCheckingInspection" )
1
+ @file:Suppress(" LocalVariableName" , " FunctionName" , " SpellCheckingInspection" , " PackageDirectoryMismatch " )
2
2
3
3
import androidx.compose.foundation.ExperimentalFoundationApi
4
4
import androidx.compose.foundation.Image
@@ -27,7 +27,6 @@ import androidx.compose.ui.res.painterResource
27
27
import androidx.compose.ui.unit.dp
28
28
import org.jetbrains.compose.resources.ExperimentalResourceApi
29
29
30
- @OptIn(ExperimentalFoundationApi ::class )
31
30
@Composable
32
31
internal fun Messages (ui_scale : Float , selectedContactPubkey : String? ) {
33
32
val listState = rememberLazyListState()
@@ -38,15 +37,17 @@ internal fun Messages(ui_scale: Float, selectedContactPubkey: String?) {
38
37
verticalArrangement = Arrangement .spacedBy(0 .dp),
39
38
state = listState,
40
39
) {
41
- item { Spacer (Modifier .size(SPACE_BEFORE_FIRST_MESSAGE )) }
40
+ item (key = " FIRST_ITEM" ) {
41
+ Spacer (Modifier .size(SPACE_BEFORE_FIRST_MESSAGE ))
42
+ }
42
43
// Log.i(com.zoffcc.applications.trifa.TAG, "LazyColumn --> draw")
43
44
items(msgs.messages, key = { it.msgDatabaseId }) {
44
45
// Log.i(com.zoffcc.applications.trifa.TAG, "LazyColumn -> it.msgDatabaseId = " + it.msgDatabaseId)
45
46
ChatMessage (isMyMessage = (it.user == myUser), it, ui_scale,
46
47
// modifier = Modifier.animateItemPlacement()
47
48
)
48
49
}
49
- item {
50
+ item (key = " LAST_ITEM " ) {
50
51
Box (Modifier .height(SPACE_AFTER_LAST_MESSAGE ))
51
52
}
52
53
}
@@ -72,7 +73,7 @@ internal fun Messages(ui_scale: Float, selectedContactPubkey: String?) {
72
73
? : - 1L
73
74
if ((lastVisibleSerial >= prevLastSerial || lastVisibleSerial == - 1L ) && msgs.messages.lastIndex > 0 ) {
74
75
// scroll to the end if we were at the end
75
- listState.scrollToItem(msgs.messages.lastIndex)
76
+ listState.scrollToItem(msgs.messages.lastIndex, LAST_MSG_SCROLL_TO_SCROLL_OFFSET )
76
77
// Log.i(com.zoffcc.applications.trifa.TAG, "messages -> scroll to the end")
77
78
}
78
79
// remember the last serial
0 commit comments