refactor(chat): improve FloatingChatWidget layout safety and back button handling
This commit is contained in:
parent
1cf1ffd9e8
commit
30939f13fd
|
|
@ -1,5 +1,7 @@
|
|||
package com.stand.standapp.ui.chat
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
|
|
@ -10,6 +12,7 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.draw.shadow
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Popup
|
||||
import androidx.compose.ui.window.PopupProperties
|
||||
|
|
@ -18,6 +21,14 @@ import com.stand.standapp.ui.chat.components.ChatScaffold
|
|||
@Composable
|
||||
fun FloatingChatWidget() {
|
||||
var isExpanded by remember { mutableStateOf(false) }
|
||||
val configuration = LocalConfiguration.current
|
||||
val maxHeight = (configuration.screenHeightDp * 0.75f).dp
|
||||
|
||||
if (isExpanded) {
|
||||
BackHandler {
|
||||
isExpanded = false
|
||||
}
|
||||
}
|
||||
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
// 右下角悬浮按钮
|
||||
|
|
@ -44,9 +55,10 @@ fun FloatingChatWidget() {
|
|||
modifier = Modifier
|
||||
.padding(16.dp)
|
||||
.padding(bottom = 32.dp)
|
||||
.width(340.dp) // 限定卡片宽度
|
||||
.height(500.dp) // 限定卡片高度
|
||||
.widthIn(max = 340.dp) // 限定卡片宽度
|
||||
.heightIn(max = maxHeight) // 限定卡片高度
|
||||
.shadow(8.dp, RoundedCornerShape(16.dp))
|
||||
.background(MaterialTheme.colorScheme.surface, RoundedCornerShape(16.dp))
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
) {
|
||||
ChatScaffold(
|
||||
|
|
|
|||
Loading…
Reference in New Issue