Merge pull request #97 from Kevinlinpr/zhong_1
创建群聊页面UI调整:修改创建群聊按钮正常状态下的颜色;新增禁用状态下点击时提示语
This commit is contained in:
@@ -99,6 +99,15 @@ fun CreateGroupChatScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val navigationBarPadding = WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding()
|
val navigationBarPadding = WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding()
|
||||||
|
var showSelectTipsDialog by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
// 自动隐藏“请选择群成员并输入群名称”提示弹窗
|
||||||
|
LaunchedEffect(showSelectTipsDialog) {
|
||||||
|
if (showSelectTipsDialog) {
|
||||||
|
kotlinx.coroutines.delay(2000)
|
||||||
|
showSelectTipsDialog = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 获取费用和余额信息
|
// 获取费用和余额信息
|
||||||
val pointsRules by PointService.pointsRules.collectAsState(initial = null)
|
val pointsRules by PointService.pointsRules.collectAsState(initial = null)
|
||||||
@@ -495,63 +504,134 @@ fun CreateGroupChatScreen() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建群聊按钮 - 固定在底部
|
// 创建群聊按钮 - 固定在底部(启用时使用渐变背景)
|
||||||
Button(
|
val isCreateEnabled =
|
||||||
onClick = {
|
groupName.text.isNotEmpty() && selectedMembers.isNotEmpty() && !CreateGroupChatViewModel.isLoading
|
||||||
// 创建群聊逻辑
|
|
||||||
if (selectedMembers.isNotEmpty()) {
|
Box(
|
||||||
// 检查是否超过上限
|
modifier = Modifier
|
||||||
if (selectedMembers.size > maxMemberLimit) {
|
.fillMaxWidth()
|
||||||
CreateGroupChatViewModel.showError(context.getString(R.string.create_group_chat_exceed_limit, maxMemberLimit))
|
.padding(
|
||||||
return@Button
|
start = 16.dp,
|
||||||
}
|
end = 16.dp,
|
||||||
// 如果费用大于0,显示确认弹窗
|
top = buttonTopPadding,
|
||||||
if (cost > 0) {
|
bottom = navigationBarPadding + 16.dp
|
||||||
CreateGroupChatViewModel.showConfirmDialog()
|
)
|
||||||
|
.let { baseModifier ->
|
||||||
|
if (isCreateEnabled) {
|
||||||
|
baseModifier.background(
|
||||||
|
brush = Brush.linearGradient(
|
||||||
|
colors = listOf(
|
||||||
|
Color(0x997c45ed),
|
||||||
|
Color(0x997c68ef),
|
||||||
|
Color(0x997bd8f8)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
shape = RoundedCornerShape(24.dp)
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
// 费用为0,直接创建
|
baseModifier
|
||||||
scope.launch {
|
}
|
||||||
val success = CreateGroupChatViewModel.createGroupChat(
|
}
|
||||||
groupName = groupName.text,
|
) {
|
||||||
selectedMembers = selectedMembers,
|
Button(
|
||||||
context = context
|
onClick = {
|
||||||
|
// 创建群聊逻辑
|
||||||
|
if (selectedMembers.isNotEmpty()) {
|
||||||
|
// 检查是否超过上限
|
||||||
|
if (selectedMembers.size > maxMemberLimit) {
|
||||||
|
CreateGroupChatViewModel.showError(
|
||||||
|
context.getString(
|
||||||
|
R.string.create_group_chat_exceed_limit,
|
||||||
|
maxMemberLimit
|
||||||
|
)
|
||||||
)
|
)
|
||||||
if (success) {
|
return@Button
|
||||||
navController.popBackStack()
|
}
|
||||||
|
// 如果费用大于0,显示确认弹窗
|
||||||
|
if (cost > 0) {
|
||||||
|
CreateGroupChatViewModel.showConfirmDialog()
|
||||||
|
} else {
|
||||||
|
// 费用为0,直接创建
|
||||||
|
scope.launch {
|
||||||
|
val success = CreateGroupChatViewModel.createGroupChat(
|
||||||
|
groupName = groupName.text,
|
||||||
|
selectedMembers = selectedMembers,
|
||||||
|
context = context
|
||||||
|
)
|
||||||
|
if (success) {
|
||||||
|
navController.popBackStack()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth(),
|
||||||
|
colors = ButtonDefaults.buttonColors(
|
||||||
|
containerColor = if (isCreateEnabled) Color.Transparent else AppColors.main,
|
||||||
|
contentColor = AppColors.mainText,
|
||||||
|
disabledContainerColor = AppColors.disabledBackground,
|
||||||
|
disabledContentColor = AppColors.text
|
||||||
|
),
|
||||||
|
shape = RoundedCornerShape(24.dp),
|
||||||
|
enabled = isCreateEnabled
|
||||||
|
) {
|
||||||
|
if (CreateGroupChatViewModel.isLoading) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.agent_createing),
|
||||||
|
fontSize = 16.sp,
|
||||||
|
fontWeight = FontWeight.W600
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.create_group_chat),
|
||||||
|
fontSize = 16.sp,
|
||||||
|
fontWeight = FontWeight.W600
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
// 禁用状态下拦截点击并弹出提示
|
||||||
.padding(start = 16.dp, end = 16.dp, top = buttonTopPadding, bottom = navigationBarPadding + 16.dp),
|
if (!isCreateEnabled) {
|
||||||
colors = ButtonDefaults.buttonColors(
|
Box(
|
||||||
containerColor = AppColors.main,
|
modifier = Modifier
|
||||||
contentColor = AppColors.mainText,
|
.matchParentSize()
|
||||||
disabledContainerColor = AppColors.disabledBackground,
|
.noRippleClickable {
|
||||||
disabledContentColor = AppColors.text
|
showSelectTipsDialog = true
|
||||||
),
|
}
|
||||||
shape = RoundedCornerShape(24.dp),
|
|
||||||
enabled = groupName.text.isNotEmpty() && selectedMembers.isNotEmpty() && !CreateGroupChatViewModel.isLoading
|
|
||||||
) {
|
|
||||||
if (CreateGroupChatViewModel.isLoading) {
|
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.agent_createing),
|
|
||||||
fontSize = 16.sp,
|
|
||||||
fontWeight = FontWeight.W600
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.create_group_chat),
|
|
||||||
fontSize = 16.sp,
|
|
||||||
fontWeight = FontWeight.W600
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 请选择群成员并输入群名称 提示弹窗
|
||||||
|
if (showSelectTipsDialog) {
|
||||||
|
Dialog(
|
||||||
|
onDismissRequest = { showSelectTipsDialog = false },
|
||||||
|
properties = DialogProperties(dismissOnClickOutside = true, dismissOnBackPress = true)
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.background(color = AppColors.background, shape = RoundedCornerShape(16.dp))
|
||||||
|
.padding(horizontal = 20.dp, vertical = 16.dp)
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.create_group_chat_select_members_and_name),
|
||||||
|
fontSize = 16.sp,
|
||||||
|
fontWeight = FontWeight.W600,
|
||||||
|
color = Color(0xFF7C45ED),
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 消费确认弹窗
|
// 消费确认弹窗
|
||||||
if (CreateGroupChatViewModel.showConfirmDialog) {
|
if (CreateGroupChatViewModel.showConfirmDialog) {
|
||||||
CreateGroupChatConfirmDialog(
|
CreateGroupChatConfirmDialog(
|
||||||
|
|||||||
@@ -225,6 +225,7 @@
|
|||||||
<string name="people">人</string>
|
<string name="people">人</string>
|
||||||
<string name="paipai">Paip.ai</string>
|
<string name="paipai">Paip.ai</string>
|
||||||
<string name="null_search">まだここは空です</string>
|
<string name="null_search">まだここは空です</string>
|
||||||
|
<string name="create_group_chat_select_members_and_name">グループメンバーを選択し、グループ名を入力してください</string>
|
||||||
|
|
||||||
<!-- Create Bottom Sheet -->
|
<!-- Create Bottom Sheet -->
|
||||||
<string name="create_title">作成</string>
|
<string name="create_title">作成</string>
|
||||||
|
|||||||
@@ -225,6 +225,7 @@
|
|||||||
<string name="only_save_the_last_5_drafts">仅保存最近5个草稿</string>
|
<string name="only_save_the_last_5_drafts">仅保存最近5个草稿</string>
|
||||||
<string name="recent_search">历史搜索</string>
|
<string name="recent_search">历史搜索</string>
|
||||||
<string name="null_search">这里还空着呢~</string>
|
<string name="null_search">这里还空着呢~</string>
|
||||||
|
<string name="create_group_chat_select_members_and_name">请选择群成员并输入群名称</string>
|
||||||
<!-- Create Bottom Sheet -->
|
<!-- Create Bottom Sheet -->
|
||||||
<string name="create_title">创建</string>
|
<string name="create_title">创建</string>
|
||||||
<string name="create_ai">AI</string>
|
<string name="create_ai">AI</string>
|
||||||
|
|||||||
@@ -224,6 +224,9 @@
|
|||||||
<string name="people">people</string>
|
<string name="people">people</string>
|
||||||
<string name="paipai">Paip.ai</string>
|
<string name="paipai">Paip.ai</string>
|
||||||
<string name="null_search">It\'s still empty here</string>
|
<string name="null_search">It\'s still empty here</string>
|
||||||
|
<string name="create_group_chat_select_members_and_name">Please select group members and enter group name</string>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Create Bottom Sheet -->
|
<!-- Create Bottom Sheet -->
|
||||||
<string name="create_title">Create</string>
|
<string name="create_title">Create</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user