mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-25 14:14:39 +00:00
android: Group chat items (#1423)
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
f8cf35879f
commit
098cbf33b6
@@ -1270,6 +1270,8 @@ sealed class CIContent: ItemContent {
|
||||
@Serializable @SerialName("sndConnEvent") class SndConnEventContent(val sndConnEvent: SndConnEvent): CIContent() { override val msgContent: MsgContent? get() = null }
|
||||
@Serializable @SerialName("rcvChatFeature") class RcvChatFeature(val feature: Feature, val enabled: FeatureEnabled): CIContent() { override val msgContent: MsgContent? get() = null }
|
||||
@Serializable @SerialName("sndChatFeature") class SndChatFeature(val feature: Feature, val enabled: FeatureEnabled): CIContent() { override val msgContent: MsgContent? get() = null }
|
||||
@Serializable @SerialName("rcvGroupFeature") class RcvGroupFeature(val feature: Feature, val preference: GroupPreference): CIContent() { override val msgContent: MsgContent? get() = null }
|
||||
@Serializable @SerialName("sndGroupFeature") class SndGroupFeature(val feature: Feature, val preference: GroupPreference): CIContent() { override val msgContent: MsgContent? get() = null }
|
||||
@Serializable @SerialName("rcvChatFeatureRejected") class RcvChatFeatureRejected(val feature: Feature): CIContent() { override val msgContent: MsgContent? get() = null }
|
||||
|
||||
override val text: String get() = when (this) {
|
||||
@@ -1288,6 +1290,8 @@ sealed class CIContent: ItemContent {
|
||||
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)}"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import androidx.compose.material.icons.filled.DeleteForever
|
||||
import androidx.compose.material.icons.filled.KeyboardVoice
|
||||
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.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
@@ -2017,6 +2018,9 @@ data class FeatureEnabled(
|
||||
else -> generalGetString(R.string.feature_off)
|
||||
}
|
||||
|
||||
val iconColor: Color
|
||||
get() = if (forUser) SimplexGreen else if (forContact) WarningYellow else HighOrLowlight
|
||||
|
||||
companion object {
|
||||
fun enabled(user: ChatPreference, contact: ChatPreference): FeatureEnabled =
|
||||
when {
|
||||
@@ -2230,6 +2234,9 @@ enum class GroupFeatureEnabled {
|
||||
OFF -> generalGetString(R.string.chat_preferences_off)
|
||||
}
|
||||
|
||||
val iconColor: Color
|
||||
get() = if (this == ON) SimplexGreen else HighOrLowlight
|
||||
|
||||
}
|
||||
|
||||
val json = Json {
|
||||
|
||||
+1
-5
@@ -15,15 +15,11 @@ import chat.simplex.app.ui.theme.*
|
||||
fun CIChatFeatureView(
|
||||
chatItem: ChatItem,
|
||||
feature: Feature,
|
||||
enabled: FeatureEnabled?
|
||||
iconColor: Color
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
val iconColor = if (enabled != null) {
|
||||
if (enabled.forUser) SimplexGreen else if (enabled.forContact) WarningYellow else HighOrLowlight
|
||||
} else Color.Red
|
||||
|
||||
Icon(feature.icon(true), feature.text(), Modifier.size(15.dp), tint = iconColor)
|
||||
Text(
|
||||
chatEventText(chatItem),
|
||||
|
||||
@@ -170,9 +170,11 @@ fun ChatItemView(
|
||||
is CIContent.SndGroupEventContent -> CIEventView(cItem)
|
||||
is CIContent.RcvConnEventContent -> CIEventView(cItem)
|
||||
is CIContent.SndConnEventContent -> CIEventView(cItem)
|
||||
is CIContent.RcvChatFeature -> CIChatFeatureView(cItem, c.feature, c.enabled)
|
||||
is CIContent.SndChatFeature -> CIChatFeatureView(cItem, c.feature, c.enabled)
|
||||
is CIContent.RcvChatFeatureRejected -> CIChatFeatureView(cItem, c.feature, null)
|
||||
is CIContent.RcvChatFeature -> CIChatFeatureView(cItem, c.feature, c.enabled.iconColor)
|
||||
is CIContent.SndChatFeature -> CIChatFeatureView(cItem, c.feature, c.enabled.iconColor)
|
||||
is CIContent.RcvGroupFeature -> CIChatFeatureView(cItem, c.feature, c.preference.enable.iconColor)
|
||||
is CIContent.SndGroupFeature -> CIChatFeatureView(cItem, c.feature, c.preference.enable.iconColor)
|
||||
is CIContent.RcvChatFeatureRejected -> CIChatFeatureView(cItem, c.feature, Color.Red)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user