add delta sync for dm-v15
This commit is contained in:
parent
dc6186233c
commit
b0b5c4d43c
5 changed files with 45 additions and 45 deletions
|
|
@ -22,6 +22,7 @@ import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.graphics.Brush
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
|
|
@ -34,7 +35,8 @@ fun AudioMessageBubble(
|
||||||
message: MessageUiModel,
|
message: MessageUiModel,
|
||||||
audioUrl: String,
|
audioUrl: String,
|
||||||
isMe: Boolean,
|
isMe: Boolean,
|
||||||
bubbleColor: Color,
|
bubbleBrush: Brush,
|
||||||
|
bubbleAlpha: Float = 1.0f,
|
||||||
viewModel: ChatViewModel // 🎯 傳入 ViewModel
|
viewModel: ChatViewModel // 🎯 傳入 ViewModel
|
||||||
) {
|
) {
|
||||||
// 訂閱全域的播放狀態
|
// 訂閱全域的播放狀態
|
||||||
|
|
@ -57,7 +59,7 @@ fun AudioMessageBubble(
|
||||||
bottomEnd = if (isMe) 0.dp else 12.dp
|
bottomEnd = if (isMe) 0.dp else 12.dp
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.background(bubbleColor)
|
.background(brush = bubbleBrush, alpha = bubbleAlpha)
|
||||||
.padding(horizontal = 8.dp, vertical = 6.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp)) {
|
.padding(horizontal = 8.dp, vertical = 6.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||||
// 播放 / 暫停按鈕
|
// 播放 / 暫停按鈕
|
||||||
IconButton(
|
IconButton(
|
||||||
|
|
|
||||||
|
|
@ -56,17 +56,8 @@ fun MessageInputBar(
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.navigationBarsPadding() // 自動適應 Android 系統導覽列高度
|
.navigationBarsPadding() // 自動適應 Android 系統導覽列高度
|
||||||
.padding(horizontal = 16.dp, vertical = 8.dp) // 懸浮的外邊距
|
.padding(horizontal = 16.dp, vertical = 8.dp) // 懸浮的外邊距
|
||||||
) {
|
|
||||||
|
|
||||||
//glass effect
|
//color
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.matchParentSize()
|
|
||||||
.blur(10.dp)
|
|
||||||
)
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.matchParentSize()
|
|
||||||
.background(
|
.background(
|
||||||
color = MaterialTheme.colorScheme.primary,
|
color = MaterialTheme.colorScheme.primary,
|
||||||
RoundedCornerShape(16.dp)
|
RoundedCornerShape(16.dp)
|
||||||
|
|
@ -76,7 +67,8 @@ fun MessageInputBar(
|
||||||
Color.White.copy(alpha = 0.3f),
|
Color.White.copy(alpha = 0.3f),
|
||||||
RoundedCornerShape(16.dp)
|
RoundedCornerShape(16.dp)
|
||||||
)
|
)
|
||||||
)
|
) {
|
||||||
|
|
||||||
|
|
||||||
Column(modifier = Modifier.fillMaxWidth()) {
|
Column(modifier = Modifier.fillMaxWidth()) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Brush
|
import androidx.compose.ui.graphics.Brush
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.SolidColor
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.foundation.layout.aspectRatio
|
import androidx.compose.foundation.layout.aspectRatio
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
|
@ -705,17 +706,23 @@ fun MessageRow(
|
||||||
onReactionClick: (MessageUiModel, String) -> Unit,
|
onReactionClick: (MessageUiModel, String) -> Unit,
|
||||||
onRowClick: (MessageUiModel) -> Unit,
|
onRowClick: (MessageUiModel) -> Unit,
|
||||||
) {
|
) {
|
||||||
val finalBubbleColor = remember(message.status, isHighlight, message.callLogInfo) {
|
val (bubbleBrush, bubbleAlpha) = remember(message.status, isHighlight, message.callLogInfo, isMe) {
|
||||||
val baseColor = when {
|
val alpha = if (message.status == MessageStatus.SENDING) 0.75f else 1.0f
|
||||||
|
val brush = when {
|
||||||
message.callLogInfo != null -> {
|
message.callLogInfo != null -> {
|
||||||
if (message.callLogInfo.type == "call_missed") Color(0xFFFCE8E6) else Color(0xFFF1F3F4)
|
SolidColor(if (message.callLogInfo.type == "call_missed") Color(0xFFFCE8E6) else Color(0xFFF1F3F4))
|
||||||
}
|
}
|
||||||
isMe && isHighlight -> Color(0xFFB4E197)
|
isMe -> {
|
||||||
isMe -> Color(0xFFDCF8C6)
|
if (isHighlight) {
|
||||||
!isMe && isHighlight -> Color(0xFFCFD8DC)
|
Brush.linearGradient(listOf(Color(0xFFFF8F00), Color(0xFFFFA000)))
|
||||||
else -> Color(0xFFECEFF1)
|
} else {
|
||||||
|
Brush.linearGradient(listOf(Color(0xFFFF8F00), Color(0xFFFFA000)))
|
||||||
}
|
}
|
||||||
if (message.status == MessageStatus.SENDING) baseColor.copy(alpha = 0.75f) else baseColor
|
}
|
||||||
|
!isMe && isHighlight -> SolidColor(Color(0xFFCFD8DC))
|
||||||
|
else -> SolidColor(Color(0xFFECEFF1))
|
||||||
|
}
|
||||||
|
brush to alpha
|
||||||
}
|
}
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
|
|
@ -761,16 +768,16 @@ fun MessageRow(
|
||||||
VideoMessageContent(message, isMe, partnerDisplayName, currentUserId, onReplyClick, onRowClick)
|
VideoMessageContent(message, isMe, partnerDisplayName, currentUserId, onReplyClick, onRowClick)
|
||||||
}
|
}
|
||||||
message.isAudio -> {
|
message.isAudio -> {
|
||||||
AudioMessageContent(message, isMe, partnerDisplayName, currentUserId, finalBubbleColor, viewModel, onReplyClick)
|
AudioMessageContent(message, isMe, partnerDisplayName, currentUserId, bubbleBrush, bubbleAlpha, viewModel, onReplyClick)
|
||||||
}
|
}
|
||||||
message.isFile -> {
|
message.isFile -> {
|
||||||
FileMessageContent(message, isMe, partnerDisplayName, currentUserId, finalBubbleColor, viewModel, onReplyClick, onRowClick)
|
FileMessageContent(message, isMe, partnerDisplayName, currentUserId, bubbleBrush, bubbleAlpha, viewModel, onReplyClick, onRowClick)
|
||||||
}
|
}
|
||||||
message.callLogInfo != null -> {
|
message.callLogInfo != null -> {
|
||||||
CallLogMessageContent(message, isMe, partnerDisplayName, currentUserId, onReplyClick, onRowClick)
|
CallLogMessageContent(message, isMe, partnerDisplayName, currentUserId, onReplyClick, onRowClick)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
TextMessageContent(message, isMe, partnerDisplayName, currentUserId, finalBubbleColor, onReplyClick, onRowClick)
|
TextMessageContent(message, isMe, partnerDisplayName, currentUserId, bubbleBrush, bubbleAlpha, onReplyClick, onRowClick)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1008,7 +1015,8 @@ private fun AudioMessageContent(
|
||||||
isMe: Boolean,
|
isMe: Boolean,
|
||||||
partnerDisplayName: String,
|
partnerDisplayName: String,
|
||||||
currentUserId: String,
|
currentUserId: String,
|
||||||
bubbleColor: Color,
|
bubbleBrush: Brush,
|
||||||
|
bubbleAlpha: Float,
|
||||||
viewModel: ChatViewModel,
|
viewModel: ChatViewModel,
|
||||||
onReplyClick: (MessageUiModel) -> Unit
|
onReplyClick: (MessageUiModel) -> Unit
|
||||||
) {
|
) {
|
||||||
|
|
@ -1029,7 +1037,8 @@ private fun AudioMessageContent(
|
||||||
message = message,
|
message = message,
|
||||||
audioUrl = message.mediaUrl,
|
audioUrl = message.mediaUrl,
|
||||||
isMe = isMe,
|
isMe = isMe,
|
||||||
bubbleColor = bubbleColor,
|
bubbleBrush = bubbleBrush,
|
||||||
|
bubbleAlpha = bubbleAlpha,
|
||||||
viewModel = viewModel
|
viewModel = viewModel
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -1041,7 +1050,8 @@ private fun FileMessageContent(
|
||||||
isMe: Boolean,
|
isMe: Boolean,
|
||||||
partnerDisplayName: String,
|
partnerDisplayName: String,
|
||||||
currentUserId: String,
|
currentUserId: String,
|
||||||
bubbleColor: Color,
|
bubbleBrush: Brush,
|
||||||
|
bubbleAlpha: Float,
|
||||||
viewModel: ChatViewModel,
|
viewModel: ChatViewModel,
|
||||||
onReplyClick: (MessageUiModel) -> Unit,
|
onReplyClick: (MessageUiModel) -> Unit,
|
||||||
onRowClick: (MessageUiModel) -> Unit
|
onRowClick: (MessageUiModel) -> Unit
|
||||||
|
|
@ -1069,7 +1079,7 @@ private fun FileMessageContent(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.background(color = bubbleColor)
|
.background(brush = bubbleBrush, alpha = bubbleAlpha)
|
||||||
.padding(horizontal = 12.dp, vertical = 10.dp)
|
.padding(horizontal = 12.dp, vertical = 10.dp)
|
||||||
) {
|
) {
|
||||||
Column {
|
Column {
|
||||||
|
|
@ -1181,7 +1191,8 @@ private fun TextMessageContent(
|
||||||
isMe: Boolean,
|
isMe: Boolean,
|
||||||
partnerDisplayName: String,
|
partnerDisplayName: String,
|
||||||
currentUserId: String,
|
currentUserId: String,
|
||||||
bubbleColor: Color,
|
bubbleBrush: Brush,
|
||||||
|
bubbleAlpha: Float,
|
||||||
onReplyClick: (MessageUiModel) -> Unit,
|
onReplyClick: (MessageUiModel) -> Unit,
|
||||||
onRowClick: (MessageUiModel) -> Unit
|
onRowClick: (MessageUiModel) -> Unit
|
||||||
) {
|
) {
|
||||||
|
|
@ -1199,7 +1210,7 @@ private fun TextMessageContent(
|
||||||
onLongClick = { onReplyClick(message) },
|
onLongClick = { onReplyClick(message) },
|
||||||
onClick = { onRowClick(message) }
|
onClick = { onRowClick(message) }
|
||||||
)
|
)
|
||||||
.background(color = bubbleColor)
|
.background(brush = bubbleBrush, alpha = bubbleAlpha)
|
||||||
.padding(horizontal = 12.dp, vertical = 8.dp)
|
.padding(horizontal = 12.dp, vertical = 8.dp)
|
||||||
) {
|
) {
|
||||||
Column {
|
Column {
|
||||||
|
|
|
||||||
|
|
@ -153,12 +153,7 @@ fun Loaded_Tg_Message(
|
||||||
},
|
},
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.background(
|
.background(
|
||||||
color = MaterialTheme.colorScheme.primary, // ⭐ 調低透明度
|
color = MaterialTheme.colorScheme.primary,
|
||||||
shape = RoundedCornerShape(0.dp)
|
|
||||||
)
|
|
||||||
.border(
|
|
||||||
width = 0.5.dp,
|
|
||||||
color = Color.White.copy(alpha = 0.4f),
|
|
||||||
shape = RoundedCornerShape(0.dp)
|
shape = RoundedCornerShape(0.dp)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ fun HorizontalWheelPicker(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.matchParentSize()
|
.matchParentSize()
|
||||||
.background(
|
.background(
|
||||||
color = MaterialTheme.colorScheme.primary,
|
Color(0x14FFFFFF),
|
||||||
RoundedCornerShape(16.dp)
|
RoundedCornerShape(16.dp)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue