diff --git a/src/main/kotlin/com/zoffcc/applications/trifa2/ChatMessage.kt b/src/main/kotlin/com/zoffcc/applications/trifa2/ChatMessage.kt index c077e697..7e7d1b10 100644 --- a/src/main/kotlin/com/zoffcc/applications/trifa2/ChatMessage.kt +++ b/src/main/kotlin/com/zoffcc/applications/trifa2/ChatMessage.kt @@ -93,10 +93,10 @@ fun randomColor() = Color( @OptIn(ExperimentalFoundationApi::class) @Composable -inline fun ChatMessage(isMyMessage: Boolean, message: UIMessage, ui_scale: Float) { +inline fun ChatMessage(isMyMessage: Boolean, message: UIMessage, ui_scale: Float, modifier: Modifier = Modifier) { val TAG = "trifa.ChatMessage" Box( - modifier = Modifier.fillMaxWidth(), + modifier = modifier.fillMaxWidth(), contentAlignment = if (isMyMessage) Alignment.CenterEnd else Alignment.CenterStart, ) { diff --git a/src/main/kotlin/com/zoffcc/applications/trifa2/GroupChatMessage.kt b/src/main/kotlin/com/zoffcc/applications/trifa2/GroupChatMessage.kt index f5531d31..1a3fe219 100644 --- a/src/main/kotlin/com/zoffcc/applications/trifa2/GroupChatMessage.kt +++ b/src/main/kotlin/com/zoffcc/applications/trifa2/GroupChatMessage.kt @@ -77,9 +77,9 @@ fun GroupTriangle(risingToTheRight: Boolean, background: Color, padding_bottom: @OptIn(ExperimentalFoundationApi::class, DelicateCoroutinesApi::class) @Composable -inline fun GroupChatMessage(isMyMessage: Boolean, groupmessage: UIGroupMessage, ui_scale: Float) { +inline fun GroupChatMessage(isMyMessage: Boolean, groupmessage: UIGroupMessage, ui_scale: Float, modifier: Modifier = Modifier) { Box( - modifier = Modifier.fillMaxWidth(), + modifier = modifier.fillMaxWidth(), contentAlignment = if (isMyMessage) Alignment.CenterEnd else Alignment.CenterStart ) { diff --git a/src/main/kotlin/com/zoffcc/applications/trifa2/GroupMessages.kt b/src/main/kotlin/com/zoffcc/applications/trifa2/GroupMessages.kt index 9332ec6b..453dd0fc 100644 --- a/src/main/kotlin/com/zoffcc/applications/trifa2/GroupMessages.kt +++ b/src/main/kotlin/com/zoffcc/applications/trifa2/GroupMessages.kt @@ -1,3 +1,4 @@ +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.Image import androidx.compose.foundation.VerticalScrollbar import androidx.compose.foundation.layout.* @@ -26,6 +27,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import org.jetbrains.compose.resources.ExperimentalResourceApi +@OptIn(ExperimentalFoundationApi::class) @Composable internal fun GroupMessages(ui_scale: Float, selectedGroupId: String?) { val listState = rememberLazyListState() @@ -38,7 +40,8 @@ internal fun GroupMessages(ui_scale: Float, selectedGroupId: String?) { ) { item { Spacer(Modifier.size(SPACE_BEFORE_FIRST_MESSAGE)) } items(grpmsgs.groupmessages, key = { it.msgDatabaseId }) { - GroupChatMessage(isMyMessage = it.user == myUser, it, ui_scale) + GroupChatMessage(isMyMessage = it.user == myUser, it, ui_scale, + modifier = Modifier.animateItemPlacement()) } item { Box(Modifier.height(SPACE_AFTER_LAST_MESSAGE)) diff --git a/src/main/kotlin/com/zoffcc/applications/trifa2/Messages.kt b/src/main/kotlin/com/zoffcc/applications/trifa2/Messages.kt index db66e717..dda96d9b 100644 --- a/src/main/kotlin/com/zoffcc/applications/trifa2/Messages.kt +++ b/src/main/kotlin/com/zoffcc/applications/trifa2/Messages.kt @@ -1,3 +1,4 @@ +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.Image import androidx.compose.foundation.VerticalScrollbar import androidx.compose.foundation.layout.* @@ -24,6 +25,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import org.jetbrains.compose.resources.ExperimentalResourceApi +@OptIn(ExperimentalFoundationApi::class) @Composable internal fun Messages(ui_scale: Float, selectedContactPubkey: String?) { val listState = rememberLazyListState() @@ -38,7 +40,8 @@ internal fun Messages(ui_scale: Float, selectedContactPubkey: String?) { // Log.i(com.zoffcc.applications.trifa.TAG, "LazyColumn --> draw") items(msgs.messages, key = { it.msgDatabaseId }) { // Log.i(com.zoffcc.applications.trifa.TAG, "LazyColumn -> it.msgDatabaseId = " + it.msgDatabaseId) - ChatMessage(isMyMessage = (it.user == myUser), it, ui_scale) + ChatMessage(isMyMessage = (it.user == myUser), it, ui_scale, + modifier = Modifier.animateItemPlacement()) } item { Box(Modifier.height(SPACE_AFTER_LAST_MESSAGE))