diff --git a/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/MessageComposer.kt b/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/MessageComposer.kt index 02ca4601caf..45de150573d 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/MessageComposer.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/MessageComposer.kt @@ -27,19 +27,21 @@ import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.material3.Divider +import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.Surface +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -48,12 +50,17 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.res.vectorResource +import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import com.wire.android.R import com.wire.android.ui.common.KeyboardHelper import com.wire.android.ui.common.SecurityClassificationBanner import com.wire.android.ui.common.bottomsheet.WireModalSheetState @@ -75,7 +82,9 @@ import com.wire.android.ui.home.messagecomposer.state.MessageCompositionInputSta import com.wire.android.ui.home.messagecomposer.state.MessageCompositionType import com.wire.android.ui.home.messagecomposer.state.Ping import com.wire.android.ui.theme.wireColorScheme +import com.wire.android.ui.theme.wireTypography import com.wire.android.util.ui.KeyboardHeight +import com.wire.android.util.ui.stringWithStyledArgs import com.wire.kalium.logic.feature.conversation.InteractionAvailability import com.wire.kalium.logic.feature.conversation.SecurityClassificationType import com.wire.kalium.logic.feature.selfDeletingMessages.SelfDeletionTimer @@ -98,19 +107,38 @@ fun MessageComposer( val securityClassificationType = messageComposerViewState.value.securityClassificationType when (messageComposerViewState.value.interactionAvailability) { - InteractionAvailability.BLOCKED_USER -> BlockedUserComposerInput( - securityClassificationType = securityClassificationType - ) + InteractionAvailability.BLOCKED_USER -> { + DisabledInteractionMessageComposer( + securityClassificationType = securityClassificationType, + warningText = LocalContext.current.resources.stringWithStyledArgs( + R.string.label_system_message_blocked_user, + MaterialTheme.wireTypography.body01, + MaterialTheme.wireTypography.body02, + colorsScheme().secondaryText, + colorsScheme().onBackground, + stringResource(id = R.string.member_name_you_label_titlecase) + ), + messageListContent = messageListContent + ) + } - InteractionAvailability.DELETED_USER -> DeletedUserComposerInput( - securityClassificationType = securityClassificationType + InteractionAvailability.DELETED_USER -> DisabledInteractionMessageComposer( + securityClassificationType = securityClassificationType, + warningText = LocalContext.current.resources.stringWithStyledArgs( + R.string.label_system_message_user_not_available, + MaterialTheme.wireTypography.body01, + MaterialTheme.wireTypography.body02, + colorsScheme().secondaryText, + colorsScheme().onBackground, + ), + messageListContent = messageListContent ) - InteractionAvailability.NOT_MEMBER, InteractionAvailability.DISABLED -> - MessageComposerClassifiedBanner( - securityClassificationType = securityClassificationType, - paddingValues = PaddingValues(vertical = dimensions().spacing16x) - ) + InteractionAvailability.NOT_MEMBER, InteractionAvailability.DISABLED -> DisabledInteractionMessageComposer( + securityClassificationType = securityClassificationType, + warningText = null, + messageListContent = messageListContent + ) InteractionAvailability.ENABLED -> { EnabledMessageComposer( @@ -137,6 +165,61 @@ fun MessageComposer( } } +@Composable +private fun DisabledInteractionMessageComposer( + warningText: AnnotatedString?, + messageListContent: @Composable () -> Unit, + securityClassificationType: SecurityClassificationType, +) { + Surface(color = colorsScheme().messageComposerBackgroundColor) { + Column( + Modifier + .fillMaxWidth() + .fillMaxHeight() + ) { + val fillRemainingSpaceBetweenMessageListContentAndMessageComposer = Modifier + .fillMaxWidth() + .weight(1f) + + Box( + Modifier + .background(color = colorsScheme().backgroundVariant) + .then(fillRemainingSpaceBetweenMessageListContentAndMessageComposer) + ) { + messageListContent() + } + if (warningText != null) { + Divider(color = MaterialTheme.wireColorScheme.outline) + Row( + verticalAlignment = Alignment.CenterVertically, + modifier = Modifier + .fillMaxWidth() + .background(color = colorsScheme().backgroundVariant) + .padding(dimensions().spacing16x) + ) { + Icon( + imageVector = ImageVector.vectorResource(id = R.drawable.ic_conversation), + tint = MaterialTheme.colorScheme.onBackground, + contentDescription = "", + modifier = Modifier + .padding(start = dimensions().spacing8x) + .size(dimensions().spacing12x) + ) + Text( + text = warningText, + style = MaterialTheme.wireTypography.body01, + maxLines = 1, + modifier = Modifier + .weight(weight = 1f, fill = false) + .padding(start = dimensions().spacing16x) + ) + } + } + MessageComposerClassifiedBanner(securityClassificationType = securityClassificationType) + } + } +} + @Composable private fun EnabledMessageComposer( messageComposerStateHolder: MessageComposerStateHolder, @@ -454,7 +537,8 @@ private fun ActiveMessageComposer( BackHandler { if (additionalOptionStateHolder - .additionalOptionsSubMenuState != AdditionalOptionSubMenuState.RecordAudio) { + .additionalOptionsSubMenuState != AdditionalOptionSubMenuState.RecordAudio + ) { onTransitionToInActive() } } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/MessageComposerInput.kt b/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/MessageComposerInput.kt index bc47eacfdc2..d524a21a6f6 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/MessageComposerInput.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/messagecomposer/MessageComposerInput.kt @@ -36,7 +36,6 @@ import androidx.compose.material3.Divider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -50,12 +49,9 @@ import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.focus.onFocusChanged import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.vector.ImageVector -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource -import androidx.compose.ui.res.vectorResource import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.unit.dp import com.wire.android.R @@ -71,8 +67,6 @@ import com.wire.android.ui.home.messagecomposer.state.MessageCompositionType import com.wire.android.ui.home.messagecomposer.state.MessageType import com.wire.android.ui.theme.wireColorScheme import com.wire.android.ui.theme.wireTypography -import com.wire.android.util.ui.stringWithStyledArgs -import com.wire.kalium.logic.feature.conversation.SecurityClassificationType @Composable fun InactiveMessageComposerInput( @@ -249,77 +243,6 @@ private fun MessageComposerTextInput( ) } -@Composable -fun BlockedUserComposerInput(securityClassificationType: SecurityClassificationType) { - Row( - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .fillMaxWidth() - .background(color = colorsScheme().backgroundVariant) - .padding(dimensions().spacing16x) - ) { - Icon( - imageVector = ImageVector.vectorResource(id = R.drawable.ic_conversation), - tint = MaterialTheme.colorScheme.onBackground, - contentDescription = "", - modifier = Modifier - .padding(start = dimensions().spacing8x) - .size(dimensions().spacing12x) - ) - Text( - text = LocalContext.current.resources.stringWithStyledArgs( - R.string.label_system_message_blocked_user, - MaterialTheme.wireTypography.body01, - MaterialTheme.wireTypography.body02, - colorsScheme().secondaryText, - colorsScheme().onBackground, - stringResource(id = R.string.member_name_you_label_titlecase) - ), - style = MaterialTheme.wireTypography.body01, - maxLines = 1, - modifier = Modifier - .weight(weight = 1f, fill = false) - .padding(start = dimensions().spacing16x) - ) - } - MessageComposerClassifiedBanner(securityClassificationType = securityClassificationType) -} - -@Composable -fun DeletedUserComposerInput(securityClassificationType: SecurityClassificationType) { - Row( - verticalAlignment = Alignment.CenterVertically, - modifier = Modifier - .fillMaxWidth() - .background(color = colorsScheme().backgroundVariant) - .padding(dimensions().spacing16x) - ) { - Icon( - imageVector = ImageVector.vectorResource(id = R.drawable.ic_conversation), - tint = MaterialTheme.colorScheme.onBackground, - contentDescription = "", - modifier = Modifier - .padding(start = dimensions().spacing8x) - .size(dimensions().spacing12x) - ) - Text( - text = LocalContext.current.resources.stringWithStyledArgs( - R.string.label_system_message_user_not_available, - MaterialTheme.wireTypography.body01, - MaterialTheme.wireTypography.body02, - colorsScheme().secondaryText, - colorsScheme().onBackground, - ), - style = MaterialTheme.wireTypography.body01, - maxLines = 1, - modifier = Modifier - .weight(weight = 1f, fill = false) - .padding(start = dimensions().spacing16x) - ) - } - MessageComposerClassifiedBanner(securityClassificationType = securityClassificationType) -} - @Composable private fun CollapseButton( onCollapseClick: () -> Unit