Skip to content

Commit

Permalink
fix: disabled interaction availibility is not displaying message hist…
Browse files Browse the repository at this point in the history
…ory (#2007)
  • Loading branch information
trOnk12 authored Jul 26, 2023
1 parent fa5de38 commit 0b358cb
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -454,7 +537,8 @@ private fun ActiveMessageComposer(

BackHandler {
if (additionalOptionStateHolder
.additionalOptionsSubMenuState != AdditionalOptionSubMenuState.RecordAudio) {
.additionalOptionsSubMenuState != AdditionalOptionSubMenuState.RecordAudio
) {
onTransitionToInActive()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0b358cb

Please sign in to comment.