diff --git a/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatScreen.kt b/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatScreen.kt index 6083d73..cd6c7fd 100644 --- a/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatScreen.kt +++ b/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatScreen.kt @@ -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, diff --git a/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatViewModel.kt b/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatViewModel.kt index 6ab0e8a..5b4f4c7 100644 --- a/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatViewModel.kt +++ b/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatViewModel.kt @@ -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, diff --git a/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/MessageUiState.kt b/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/MessageUiState.kt index b2d6524..7e21b08 100644 --- a/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/MessageUiState.kt +++ b/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/MessageUiState.kt @@ -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 = emptyList(), val chatBans: List = emptyList(), diff --git a/android/app/src/main/res/values-ru/strings.xml b/android/app/src/main/res/values-ru/strings.xml index ed38280..133b0c6 100644 --- a/android/app/src/main/res/values-ru/strings.xml +++ b/android/app/src/main/res/values-ru/strings.xml @@ -64,6 +64,7 @@ Удалить диалог у вас? История будет очищена. Выйти из чата и убрать его из списка? Включить звук + Выключить звук Видеокружок Пользователь diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index e401776..0f3cec0 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -64,6 +64,7 @@ Delete dialog for you? History will be cleared. Leave the chat and remove it from your list? Enable sound + Disable sound Circle video User