From 3a755286c19c70dd8ed98451c72013ca1511729f Mon Sep 17 00:00:00 2001 From: JRoberts <8711996+jr-simplex@users.noreply.github.com> Date: Mon, 28 Nov 2022 20:03:39 +0400 Subject: [PATCH] ios, android: improve preference change chat items layout (#1454) --- .../java/chat/simplex/app/model/ChatModel.kt | 10 +++--- .../java/chat/simplex/app/model/SimpleXAPI.kt | 19 +++++++---- .../app/views/chat/ContactPreferences.kt | 4 +-- .../app/views/chat/group/GroupPreferences.kt | 6 ++-- .../app/views/chat/item/CIChatFeatureView.kt | 7 ++-- .../app/views/chat/item/CIEventView.kt | 33 +++++++++++-------- .../app/views/usersettings/Preferences.kt | 4 +-- .../Chat/ChatItem/CIChatFeatureView.swift | 4 +-- apps/ios/SimpleXChat/ChatTypes.swift | 9 ++++- 9 files changed, 59 insertions(+), 37 deletions(-) diff --git a/apps/android/app/src/main/java/chat/simplex/app/model/ChatModel.kt b/apps/android/app/src/main/java/chat/simplex/app/model/ChatModel.kt index 931aafb4c9..8a5b9e18e3 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/model/ChatModel.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/model/ChatModel.kt @@ -1297,11 +1297,11 @@ sealed class CIContent: ItemContent { is SndGroupEventContent -> sndGroupEvent.text is RcvConnEventContent -> rcvConnEvent.text is SndConnEventContent -> sndConnEvent.text - is RcvChatFeature -> "${feature.text()}: ${enabled.text}" - is SndChatFeature -> "${feature.text()}: ${enabled.text}" - is RcvGroupFeature -> "${feature.text()}: ${preference.enable.text}" - is SndGroupFeature -> "${feature.text()}: ${preference.enable.text}" - is RcvChatFeatureRejected -> "${feature.text()}: ${generalGetString(R.string.feature_received_prohibited)}" + is RcvChatFeature -> "${feature.text}: ${enabled.text}" + is SndChatFeature -> "${feature.text}: ${enabled.text}" + is RcvGroupFeature -> "${feature.text}: ${preference.enable.text}" + is SndGroupFeature -> "${feature.text}: ${preference.enable.text}" + is RcvChatFeatureRejected -> "${feature.text}: ${generalGetString(R.string.feature_received_prohibited)}" } } diff --git a/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt b/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt index ced948eb88..242bca6777 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt @@ -18,6 +18,7 @@ import androidx.compose.material.icons.outlined.* import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp @@ -2052,16 +2053,22 @@ enum class Feature { @SerialName("fullDelete") FullDelete, @SerialName("voice") Voice; - fun text() = - when(this) { + val text: String + get() = when(this) { FullDelete -> generalGetString(R.string.full_deletion) Voice -> generalGetString(R.string.voice_messages) } - fun icon(filled: Boolean) = - when(this) { - FullDelete -> if (filled) Icons.Filled.DeleteForever else Icons.Outlined.DeleteForever - Voice -> if (filled) Icons.Filled.KeyboardVoice else Icons.Outlined.KeyboardVoice + val icon: ImageVector + get() = when(this) { + FullDelete -> Icons.Outlined.DeleteForever + Voice -> Icons.Outlined.KeyboardVoice + } + + val iconFilled: ImageVector + get() = when(this) { + FullDelete -> Icons.Filled.DeleteForever + Voice -> Icons.Filled.KeyboardVoice } fun allowDescription(allowed: FeatureAllowed): String = diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ContactPreferences.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ContactPreferences.kt index 8fb643e15e..fdc1c651c1 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ContactPreferences.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ContactPreferences.kt @@ -104,8 +104,8 @@ private fun FeatureSection( ) SectionView( - feature.text().uppercase(), - icon = feature.icon(true), + feature.text.uppercase(), + icon = feature.iconFilled, iconTint = if (enabled.forUser) SimplexGreen else if (enabled.forContact) WarningYellow else Color.Red, leadingIcon = true, ) { diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupPreferences.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupPreferences.kt index b4afdd9d84..b8d7e31e6e 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupPreferences.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupPreferences.kt @@ -86,16 +86,16 @@ private fun FeatureSection(feature: Feature, enableFeature: State SectionView { SectionItemView { ExposedDropDownSettingRow( - feature.text(), + feature.text, FeatureAllowed.values().map { it to it.text }, allowFeature, - icon = feature.icon(false), + icon = feature.icon, onSelected = onSelected ) } diff --git a/apps/ios/Shared/Views/Chat/ChatItem/CIChatFeatureView.swift b/apps/ios/Shared/Views/Chat/ChatItem/CIChatFeatureView.swift index 98ef18f2b0..bdbb7c8cef 100644 --- a/apps/ios/Shared/Views/Chat/ChatItem/CIChatFeatureView.swift +++ b/apps/ios/Shared/Views/Chat/ChatItem/CIChatFeatureView.swift @@ -15,8 +15,8 @@ struct CIChatFeatureView: View { var iconColor: Color var body: some View { - HStack(alignment: .bottom, spacing: 0) { - Image(systemName: feature.icon + ".fill") + HStack(alignment: .bottom, spacing: 4) { + Image(systemName: feature.iconFilled) .foregroundColor(iconColor) chatEventText(chatItem) } diff --git a/apps/ios/SimpleXChat/ChatTypes.swift b/apps/ios/SimpleXChat/ChatTypes.swift index b9c4dea1ef..465ea071a1 100644 --- a/apps/ios/SimpleXChat/ChatTypes.swift +++ b/apps/ios/SimpleXChat/ChatTypes.swift @@ -263,7 +263,14 @@ public enum Feature: String, Decodable { public var icon: String { switch self { case .fullDelete: return "trash.slash" - case .voice: return "speaker.wave.2" + case .voice: return "mic" + } + } + + public var iconFilled: String { + switch self { + case .fullDelete: return "trash.slash.fill" + case .voice: return "mic.fill" } }