聊天室和群聊信息调整
This commit is contained in:
@@ -16,7 +16,9 @@ import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.ViewModel
|
||||
@@ -76,10 +78,11 @@ fun GroupChatInfoScreen(groupId: String) {
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
Text(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
textAlign = TextAlign.Start,
|
||||
text = "群聊信息",
|
||||
style = androidx.compose.ui.text.TextStyle(
|
||||
color = AppColors.text,
|
||||
fontSize = 18.sp,
|
||||
fontSize = 17.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
|
||||
@@ -104,7 +107,7 @@ fun GroupChatInfoScreen(groupId: String) {
|
||||
imageUrl = viewModel.groupInfo!!.groupAvatar,
|
||||
modifier = Modifier
|
||||
.size(80.dp)
|
||||
.clip(CircleShape),
|
||||
.clip(RoundedCornerShape(12.dp)),
|
||||
contentDescription = "群聊头像"
|
||||
)
|
||||
} else {
|
||||
@@ -136,19 +139,6 @@ fun GroupChatInfoScreen(groupId: String) {
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Text(
|
||||
text = "更改名称和图片",
|
||||
style = androidx.compose.ui.text.TextStyle(
|
||||
color = Color(0xFF007AFF),
|
||||
fontSize = 14.sp
|
||||
),
|
||||
modifier = Modifier.noRippleClickable {
|
||||
// TODO: 实现更改群聊名称和图片功能
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,20 +159,20 @@ fun GroupChatInfoScreen(groupId: String) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(48.dp)
|
||||
.clip(CircleShape)
|
||||
.background(Color(0xFF007AFF)),
|
||||
.clip(CircleShape),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(R.drawable.rider_pro_back_icon),
|
||||
painter = painterResource(R.drawable.rider_pro_add_other),
|
||||
modifier = Modifier.size(24.dp),
|
||||
contentDescription = null,
|
||||
colorFilter = ColorFilter.tint(Color.White)
|
||||
colorFilter = ColorFilter.tint(
|
||||
AppColors.text)
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Text(
|
||||
text = "添加其他人",
|
||||
text = stringResource(R.string.group_info_add_other),
|
||||
style = androidx.compose.ui.text.TextStyle(
|
||||
color = AppColors.text,
|
||||
fontSize = 12.sp
|
||||
@@ -194,26 +184,30 @@ fun GroupChatInfoScreen(groupId: String) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier.noRippleClickable {
|
||||
// TODO: 实现通知设置功能
|
||||
/* if (viewModel.notificationStrategy == "mute") {
|
||||
viewModel.updateNotificationStrategy("active")
|
||||
} else {
|
||||
viewModel.updateNotificationStrategy("mute")
|
||||
}*/
|
||||
}
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(48.dp)
|
||||
.clip(CircleShape)
|
||||
.background(Color(0xFF007AFF)),
|
||||
.clip(CircleShape),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(R.drawable.rider_pro_notice_active),
|
||||
painter = painterResource(if (viewModel.notificationStrategy == "mute") R.drawable.rider_pro_notice_mute else R.drawable.rider_pro_notice_active,),
|
||||
modifier = Modifier.size(24.dp),
|
||||
contentDescription = null,
|
||||
colorFilter = ColorFilter.tint(Color.White)
|
||||
colorFilter = ColorFilter.tint(
|
||||
AppColors.text)
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Text(
|
||||
text = "通知",
|
||||
text = stringResource(R.string.group_info_notice_setting),
|
||||
style = androidx.compose.ui.text.TextStyle(
|
||||
color = AppColors.text,
|
||||
fontSize = 12.sp
|
||||
@@ -231,20 +225,21 @@ fun GroupChatInfoScreen(groupId: String) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(48.dp)
|
||||
.clip(CircleShape)
|
||||
.background(Color(0xFFFF3B30)),
|
||||
.clip(CircleShape),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(R.drawable.rider_pro_back_icon),
|
||||
painter = painterResource(R.drawable.group_info_exit
|
||||
),
|
||||
modifier = Modifier.size(24.dp),
|
||||
contentDescription = null,
|
||||
colorFilter = ColorFilter.tint(Color.White)
|
||||
colorFilter = ColorFilter.tint(
|
||||
AppColors.text)
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Text(
|
||||
text = "退出",
|
||||
text = stringResource(R.string.group_info_exit),
|
||||
style = androidx.compose.ui.text.TextStyle(
|
||||
color = AppColors.text,
|
||||
fontSize = 12.sp
|
||||
@@ -263,7 +258,6 @@ fun GroupChatInfoScreen(groupId: String) {
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.background(AppColors.decentBackground)
|
||||
.padding(16.dp)
|
||||
.noRippleClickable {
|
||||
// TODO: 实现设置聊天主题功能
|
||||
@@ -271,14 +265,15 @@ fun GroupChatInfoScreen(groupId: String) {
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(R.drawable.rider_pro_back_icon),
|
||||
painter = painterResource(R.drawable.group_info_edit),
|
||||
modifier = Modifier.size(24.dp),
|
||||
contentDescription = null,
|
||||
colorFilter = ColorFilter.tint(AppColors.text)
|
||||
colorFilter = ColorFilter.tint(
|
||||
AppColors.text)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
Text(
|
||||
text = "设置聊天主题",
|
||||
text = stringResource(R.string.group_info_edit),
|
||||
style = androidx.compose.ui.text.TextStyle(
|
||||
color = AppColors.text,
|
||||
fontSize = 16.sp
|
||||
@@ -286,10 +281,9 @@ fun GroupChatInfoScreen(groupId: String) {
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
Image(
|
||||
painter = painterResource(R.drawable.rider_pro_back_icon),
|
||||
modifier = Modifier.size(16.dp),
|
||||
painter = painterResource(R.drawable.rave_now_nav_right),
|
||||
modifier = Modifier.size(18.dp),
|
||||
contentDescription = null,
|
||||
colorFilter = ColorFilter.tint(AppColors.secondaryText)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -300,7 +294,6 @@ fun GroupChatInfoScreen(groupId: String) {
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.background(AppColors.decentBackground)
|
||||
.padding(16.dp)
|
||||
.noRippleClickable {
|
||||
// TODO: 实现查看群聊成员功能
|
||||
@@ -308,10 +301,11 @@ fun GroupChatInfoScreen(groupId: String) {
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(R.drawable.rider_pro_back_icon),
|
||||
painter = painterResource(R.drawable.group_info_users),
|
||||
modifier = Modifier.size(24.dp),
|
||||
contentDescription = null,
|
||||
colorFilter = ColorFilter.tint(AppColors.text)
|
||||
colorFilter = ColorFilter.tint(
|
||||
AppColors.text)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
Text(
|
||||
@@ -323,64 +317,12 @@ fun GroupChatInfoScreen(groupId: String) {
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
Image(
|
||||
painter = painterResource(R.drawable.rider_pro_back_icon),
|
||||
modifier = Modifier.size(16.dp),
|
||||
painter = painterResource(R.drawable.rave_now_nav_right),
|
||||
modifier = Modifier.size(18.dp),
|
||||
contentDescription = null,
|
||||
colorFilter = ColorFilter.tint(AppColors.secondaryText)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// 成员列表
|
||||
if (viewModel.groupInfo?.members?.isNotEmpty() == true) {
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Text(
|
||||
text = "群成员",
|
||||
style = androidx.compose.ui.text.TextStyle(
|
||||
color = AppColors.text,
|
||||
fontSize = 16.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
items(viewModel.groupInfo!!.members) { member ->
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
CustomAsyncImage(
|
||||
imageUrl = member.avatar,
|
||||
modifier = Modifier
|
||||
.size(40.dp)
|
||||
.clip(CircleShape),
|
||||
contentDescription = "成员头像"
|
||||
)
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
Column {
|
||||
Text(
|
||||
text = member.nickname,
|
||||
style = androidx.compose.ui.text.TextStyle(
|
||||
color = AppColors.text,
|
||||
fontSize = 16.sp
|
||||
)
|
||||
)
|
||||
if (member.isOwner) {
|
||||
Text(
|
||||
text = "群主",
|
||||
style = androidx.compose.ui.text.TextStyle(
|
||||
color = AppColors.secondaryText,
|
||||
fontSize = 12.sp
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,10 @@ import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.aiosman.ravenow.AppStore
|
||||
import com.aiosman.ravenow.ChatState
|
||||
import com.aiosman.ravenow.data.api.ApiClient
|
||||
import com.aiosman.ravenow.entity.ChatNotification
|
||||
import com.aiosman.ravenow.entity.GroupInfo
|
||||
import com.aiosman.ravenow.entity.GroupMember
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -17,13 +20,21 @@ class GroupChatInfoViewModel(
|
||||
var groupInfo by mutableStateOf<GroupInfo?>(null)
|
||||
var isLoading by mutableStateOf(false)
|
||||
var error by mutableStateOf<String?>(null)
|
||||
|
||||
var chatNotification by mutableStateOf<ChatNotification?>(null)
|
||||
val notificationStrategy get() = chatNotification?.strategy ?: "default"
|
||||
init {
|
||||
loadGroupInfo()
|
||||
}
|
||||
suspend fun updateNotificationStrategy(strategy: String) {
|
||||
val result = ChatState.updateChatNotification(groupId.hashCode(), strategy)
|
||||
chatNotification = result
|
||||
}
|
||||
|
||||
|
||||
private fun loadGroupInfo() {
|
||||
viewModelScope.launch {
|
||||
val notiStrategy = ChatState.getStrategyByTargetTrtcId(groupId)
|
||||
chatNotification = notiStrategy
|
||||
try {
|
||||
isLoading = true
|
||||
error = null
|
||||
@@ -37,16 +48,17 @@ class GroupChatInfoViewModel(
|
||||
GroupInfo(
|
||||
groupId = groupId,
|
||||
groupName = it.name,
|
||||
groupAvatar = room.avatar,
|
||||
memberCount = room.userCount,
|
||||
members = listOf(
|
||||
GroupMember(
|
||||
userId = room.creator.userId,
|
||||
nickname = room.creator.profile.nickname,
|
||||
avatar = room.creator.profile.avatar,
|
||||
isOwner = true
|
||||
groupAvatar = if (it.avatar.isNullOrEmpty()) {
|
||||
// 将 groupId 转换为 Base64
|
||||
val groupIdBase64 = android.util.Base64.encodeToString(
|
||||
groupId.toByteArray(),
|
||||
android.util.Base64.NO_WRAP
|
||||
)
|
||||
)
|
||||
"${ApiClient.RETROFIT_URL+"group/avatar?groupIdBase64="}${groupIdBase64}"+"&token="+"${AppStore.token}"
|
||||
} else {
|
||||
"${ApiClient.BASE_API_URL+"/outside/rooms/avatar/"}${it.avatar}"+"?token="+"${AppStore.token}"
|
||||
},
|
||||
memberCount = room.userCount,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user