Chat mute UX: dynamic channel toggle, top-bar indicator, no success toast
This commit is contained in:
@@ -133,6 +133,7 @@ import androidx.compose.material.icons.filled.RadioButtonChecked
|
||||
import androidx.compose.material.icons.filled.RadioButtonUnchecked
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.material.icons.filled.Notifications
|
||||
import androidx.compose.material.icons.filled.NotificationsOff
|
||||
import androidx.compose.material.icons.filled.Pause
|
||||
import androidx.compose.material.icons.filled.Info
|
||||
import androidx.compose.material.icons.filled.Image
|
||||
@@ -692,11 +693,24 @@ fun ChatScreen(
|
||||
maxLines = 1,
|
||||
)
|
||||
if (state.chatSubtitle.isNotBlank()) {
|
||||
Text(
|
||||
text = state.chatSubtitle,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
Text(
|
||||
text = state.chatSubtitle,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
if (state.chatMuted) {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.NotificationsOff,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.size(13.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -719,7 +733,12 @@ fun ChatScreen(
|
||||
) {
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(id = R.string.chat_menu_notifications)) },
|
||||
leadingIcon = { Icon(Icons.Filled.Notifications, contentDescription = null) },
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
if (state.chatMuted) Icons.Filled.NotificationsOff else Icons.Filled.Notifications,
|
||||
contentDescription = null,
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
showChatMenu = false
|
||||
onToggleChatNotifications()
|
||||
@@ -1426,6 +1445,7 @@ fun ChatScreen(
|
||||
} else if (isChannelChat && !state.canSendMessages) {
|
||||
ChannelReadOnlyBar(
|
||||
onToggleNotifications = onToggleChatNotifications,
|
||||
isMuted = state.chatMuted,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.navigationBarsPadding()
|
||||
@@ -2745,6 +2765,7 @@ private fun DaySeparatorChip(label: String) {
|
||||
@Composable
|
||||
private fun ChannelReadOnlyBar(
|
||||
onToggleNotifications: () -> Unit,
|
||||
isMuted: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Row(
|
||||
@@ -2760,7 +2781,11 @@ private fun ChannelReadOnlyBar(
|
||||
.clickable { onToggleNotifications() },
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.chat_enable_sound),
|
||||
text = if (isMuted) {
|
||||
stringResource(id = R.string.chat_enable_sound)
|
||||
} else {
|
||||
stringResource(id = R.string.chat_disable_sound)
|
||||
},
|
||||
modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
textAlign = androidx.compose.ui.text.style.TextAlign.Center,
|
||||
|
||||
@@ -456,9 +456,7 @@ class ChatViewModel @Inject constructor(
|
||||
when (val current = chatRepository.getChatNotifications(chatId = chatId)) {
|
||||
is AppResult.Success -> {
|
||||
when (val updated = chatRepository.updateChatNotifications(chatId = chatId, muted = !current.data.muted)) {
|
||||
is AppResult.Success -> _uiState.update {
|
||||
it.copy(errorMessage = if (updated.data.muted) "Notifications muted." else "Notifications enabled.")
|
||||
}
|
||||
is AppResult.Success -> _uiState.update { it.copy(chatMuted = updated.data.muted) }
|
||||
is AppResult.Error -> _uiState.update { it.copy(errorMessage = updated.reason.toUiMessage()) }
|
||||
}
|
||||
}
|
||||
@@ -760,6 +758,7 @@ class ChatViewModel @Inject constructor(
|
||||
it.copy(
|
||||
chatType = chat.type,
|
||||
chatRole = role,
|
||||
chatMuted = chat.muted,
|
||||
chatTitle = chatTitle,
|
||||
chatSubtitle = chatSubtitle,
|
||||
chatAvatarUrl = chat.avatarUrl ?: chat.counterpartAvatarUrl,
|
||||
|
||||
@@ -18,6 +18,7 @@ data class MessageUiState(
|
||||
val chatAvatarUrl: String? = null,
|
||||
val chatType: String = "",
|
||||
val chatRole: String? = null,
|
||||
val chatMuted: Boolean = false,
|
||||
val chatUnreadCount: Int = 0,
|
||||
val chatMembers: List<ChatMemberItem> = emptyList(),
|
||||
val chatBans: List<ChatBanItem> = emptyList(),
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
<string name="chat_delete_dialog_confirm">Удалить диалог у вас? История будет очищена.</string>
|
||||
<string name="chat_leave_delete_confirm">Выйти из чата и убрать его из списка?</string>
|
||||
<string name="chat_enable_sound">Включить звук</string>
|
||||
<string name="chat_disable_sound">Выключить звук</string>
|
||||
<string name="chat_circle_video">Видеокружок</string>
|
||||
|
||||
<string name="settings_user_fallback">Пользователь</string>
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
<string name="chat_delete_dialog_confirm">Delete dialog for you? History will be cleared.</string>
|
||||
<string name="chat_leave_delete_confirm">Leave the chat and remove it from your list?</string>
|
||||
<string name="chat_enable_sound">Enable sound</string>
|
||||
<string name="chat_disable_sound">Disable sound</string>
|
||||
<string name="chat_circle_video">Circle video</string>
|
||||
|
||||
<string name="settings_user_fallback">User</string>
|
||||
|
||||
Reference in New Issue
Block a user