dm-74
This commit is contained in:
parent
d1b1f999c2
commit
e8119560b2
1 changed files with 29 additions and 23 deletions
|
|
@ -5,6 +5,7 @@ import android.util.Log
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
|
import androidx.compose.animation.AnimatedContent
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
|
|
@ -184,19 +185,23 @@ fun MessageMessaging(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
//to be animated
|
|
||||||
bottomBar = {
|
bottomBar = {
|
||||||
if (actionMessage != null) {
|
// 👈 1. 直接將 actionMessage 作為 targetState
|
||||||
|
AnimatedContent(
|
||||||
|
targetState = actionMessage,
|
||||||
|
label = "BottomBarSwitchAnimation"
|
||||||
|
) { currentActionMessage -> // 👈 2. 這裡拿到的 currentActionMessage 在動畫期間會保持不變
|
||||||
|
if (currentActionMessage != null) {
|
||||||
// 顯示動作選單
|
// 顯示動作選單
|
||||||
MessageActionMenuRow(
|
MessageActionMenuRow(
|
||||||
message = actionMessage!!,
|
message = currentActionMessage, // 👈 3. 乾淨安全,再也不需要寫 !! 了
|
||||||
onCancel = { viewModel.clearActionMessage() }, // 👈 呼叫 ViewModel 的清除
|
onCancel = { viewModel.clearActionMessage() },
|
||||||
onReplyClick = { msg ->
|
onReplyClick = { msg ->
|
||||||
viewModel.setReplyingMessage(msg) // 👈 原本的回覆邏輯
|
viewModel.setReplyingMessage(msg)
|
||||||
viewModel.clearActionMessage() // 👈 點擊回覆後關閉動作選單
|
viewModel.clearActionMessage()
|
||||||
},
|
},
|
||||||
onDeleteClick = { msg ->
|
onDeleteClick = { msg ->
|
||||||
viewModel.deleteMessage(roomId, msg.id) // 👈 觸發刪除(內部成功後會自己關閉)
|
viewModel.deleteMessage(roomId, msg.id)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -204,12 +209,13 @@ fun MessageMessaging(
|
||||||
MessageInputBar(
|
MessageInputBar(
|
||||||
isLoading = sendStatus is SendMessageState.Loading,
|
isLoading = sendStatus is SendMessageState.Loading,
|
||||||
replyingMessage = replyingMessage,
|
replyingMessage = replyingMessage,
|
||||||
onCancelReply = { viewModel.setReplyingMessage(null) }, // 傳 null 等同清除
|
onCancelReply = { viewModel.setReplyingMessage(null) },
|
||||||
onSendClick = { content -> viewModel.sendMessage(roomId, content) },
|
onSendClick = { content -> viewModel.sendMessage(roomId, content) },
|
||||||
onImageSelected = { uri -> viewModel.uploadAttachment(roomId, uri) }
|
onImageSelected = { uri -> viewModel.uploadAttachment(roomId, uri) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
) { innerPadding ->
|
) { innerPadding ->
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue