Fix desktop hover and emoji playback; share Android chat background

This commit is contained in:
evgeny committed 2026-10-02 23:19:13 +03:00
1 parent 35648a19ce
commit 1e9264735b
13 files changed
+338 -51

No files matched your search

@@ -3,9 +3,21 @@ package com.utun.chat.ui.components
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.ImageShader
import androidx.compose.ui.graphics.ShaderBrush
import androidx.compose.ui.graphics.TileMode
import androidx.compose.ui.graphics.drawscope.scale
import androidx.compose.ui.res.imageResource
import androidx.compose.ui.unit.dp
import com.utun.chat.R
import com.utun.chat.data.ConversationTarget
import com.utun.chat.data.LogManager
import com.utun.chat.data.Message
import com.utun.chat.viewmodel.ChatViewModel
@@ -16,7 +28,20 @@ fun ConversationMessages(target: ConversationTarget, messages: List<Message>, st
onPlayVoice: (String, Int) -> Unit, onSeekVoice: (String, Int, Int) -> Unit,
onOpenFile: (Message) -> Unit, onPlayVideo: (Message) -> Unit,
onDownloadFile: (Message) -> Unit = {}, onOpenImage: (Message) -> Unit = {}) {
LazyColumn(modifier = modifier, state = state, reverseLayout = true) {
val background = ImageBitmap.imageResource(R.drawable.chat_background)
LaunchedEffect(background) {
LogManager.addLog("DEBUG", "UI", "Chat background ready: desktop bg.png tile=${background.width}x${background.height}")
}
// Плитка закреплена за областью списка; плотность экрана сохраняет размер узора в dp.
val backgroundModifier = Modifier.drawWithCache {
val brush = ShaderBrush(ImageShader(background, TileMode.Repeated, TileMode.Repeated))
onDrawBehind {
scale(density, density, pivot = Offset.Zero) {
drawRect(brush, size = Size(size.width / density, size.height / density))
}
}
}
LazyColumn(modifier = modifier.then(backgroundModifier), state = state, reverseLayout = true) {
item { Spacer(Modifier.height(8.dp)) }
items(messages.reversed(), key = { "${target.nativeId}:${it.isOutgoing}:${it.id}" }) { message ->
MessageBubble(message, playbackState, onPlayVoice, onSeekVoice, onDownloadFile, onOpenFile, onOpenImage, onPlayVideo)