dm-75
This commit is contained in:
parent
e8119560b2
commit
18243f8582
1 changed files with 77 additions and 60 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
package com.example.login_v3.home.Message.UI.Detail.Message_Messaging_detail
|
package com.example.login_v3.home.Message.UI.Detail.Message_Messaging_detail
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
|
@ -25,6 +27,7 @@ import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
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.blur
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
|
|
@ -50,67 +53,81 @@ fun MessageActionMenuRow(
|
||||||
.navigationBarsPadding() // 自動適應 Android 系統導覽列(手勢列)高度
|
.navigationBarsPadding() // 自動適應 Android 系統導覽列(手勢列)高度
|
||||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||||
) {
|
) {
|
||||||
Surface(
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
shape = RoundedCornerShape(16.dp), // 保持懸浮圓角感
|
//glass effect
|
||||||
color = Color.White,
|
Box(
|
||||||
tonalElevation = 6.dp,
|
modifier = Modifier
|
||||||
shadowElevation = 6.dp
|
.matchParentSize()
|
||||||
|
.blur(10.dp)
|
||||||
|
)
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.matchParentSize()
|
||||||
|
.background(
|
||||||
|
color = MaterialTheme.colorScheme.primary,
|
||||||
|
RoundedCornerShape(16.dp)
|
||||||
|
)
|
||||||
|
.border(
|
||||||
|
1.dp,
|
||||||
|
Color.White.copy(alpha = 0.3f),
|
||||||
|
RoundedCornerShape(16.dp)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(horizontal = 12.dp, vertical = 30.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
) {
|
) {
|
||||||
Row(
|
// 左側:取消關閉選單按鈕
|
||||||
modifier = Modifier
|
IconButton(onClick = onCancel) {
|
||||||
.fillMaxWidth()
|
Icon(
|
||||||
.padding(horizontal = 12.dp, vertical = 30.dp),
|
imageVector = Icons.Default.Close,
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
contentDescription = "取消選取",
|
||||||
horizontalArrangement = Arrangement.SpaceBetween
|
tint = Color.Gray
|
||||||
) {
|
)
|
||||||
// 左側:取消關閉選單按鈕
|
|
||||||
IconButton(onClick = onCancel) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Close,
|
|
||||||
contentDescription = "取消選取",
|
|
||||||
tint = Color.Gray
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 中間:各個功能按鈕
|
|
||||||
Row(
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(20.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically
|
|
||||||
) {
|
|
||||||
// 1. 回覆
|
|
||||||
ChatMenuButton(
|
|
||||||
imageVector = Icons.Default.Reply,
|
|
||||||
label = "回覆",
|
|
||||||
onClick = { onReplyClick(message) }
|
|
||||||
)
|
|
||||||
|
|
||||||
// 2. 複製文字
|
|
||||||
val isImage = message.content?.startsWith("http") == true || message.attachment != null
|
|
||||||
ChatMenuButton(
|
|
||||||
imageVector = Icons.Default.ContentCopy,
|
|
||||||
label = "複製",
|
|
||||||
enabled = !isImage,
|
|
||||||
onClick = {
|
|
||||||
message.content?.let { text ->
|
|
||||||
clipboardManager.setText(AnnotatedString(text))
|
|
||||||
}
|
|
||||||
onCancel()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// 3. 刪除
|
|
||||||
ChatMenuButton(
|
|
||||||
imageVector = Icons.Default.Delete,
|
|
||||||
label = "刪除",
|
|
||||||
tint = MaterialTheme.colorScheme.error,
|
|
||||||
onClick = { onDeleteClick(message) }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 為了讓中間的按鈕群置中,右邊放一個等寬的 Spacer
|
|
||||||
Spacer(modifier = Modifier.size(48.dp))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 中間:各個功能按鈕
|
||||||
|
Row(
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(20.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
// 1. 回覆
|
||||||
|
ChatMenuButton(
|
||||||
|
imageVector = Icons.Default.Reply,
|
||||||
|
label = "回覆",
|
||||||
|
onClick = { onReplyClick(message) }
|
||||||
|
)
|
||||||
|
|
||||||
|
// 2. 複製文字
|
||||||
|
val isImage = message.content?.startsWith("http") == true || message.attachment != null
|
||||||
|
ChatMenuButton(
|
||||||
|
imageVector = Icons.Default.ContentCopy,
|
||||||
|
label = "複製",
|
||||||
|
enabled = !isImage,
|
||||||
|
onClick = {
|
||||||
|
message.content?.let { text ->
|
||||||
|
clipboardManager.setText(AnnotatedString(text))
|
||||||
|
}
|
||||||
|
onCancel()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// 3. 刪除
|
||||||
|
ChatMenuButton(
|
||||||
|
imageVector = Icons.Default.Delete,
|
||||||
|
label = "刪除",
|
||||||
|
tint = MaterialTheme.colorScheme.error,
|
||||||
|
onClick = { onDeleteClick(message) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 為了讓中間的按鈕群置中,右邊放一個等寬的 Spacer
|
||||||
|
Spacer(modifier = Modifier.size(48.dp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +155,7 @@ fun ChatMenuButton(
|
||||||
imageVector = imageVector,
|
imageVector = imageVector,
|
||||||
contentDescription = label,
|
contentDescription = label,
|
||||||
tint = contentColor,
|
tint = contentColor,
|
||||||
modifier = Modifier.size(24.dp)
|
modifier = Modifier.size(32.dp)
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(2.dp))
|
Spacer(modifier = Modifier.height(2.dp))
|
||||||
Text(
|
Text(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue