Skip to content

Commit 6de04da

Browse files
committed
Move DisabledComposer to MessageView.
1 parent 81a4aa0 commit 6de04da

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import io.element.android.features.messages.impl.actionlist.ActionListView
5555
import io.element.android.features.messages.impl.actionlist.model.TimelineItemAction
5656
import io.element.android.features.messages.impl.crypto.identity.IdentityChangeStateView
5757
import io.element.android.features.messages.impl.messagecomposer.AttachmentsBottomSheet
58+
import io.element.android.features.messages.impl.messagecomposer.DisabledComposerView
5859
import io.element.android.features.messages.impl.messagecomposer.MessageComposerEvents
5960
import io.element.android.features.messages.impl.messagecomposer.MessageComposerView
6061
import io.element.android.features.messages.impl.messagecomposer.suggestions.SuggestionsPickerView
@@ -97,6 +98,7 @@ import io.element.android.libraries.designsystem.utils.snackbar.SnackbarHost
9798
import io.element.android.libraries.designsystem.utils.snackbar.rememberSnackbarHostState
9899
import io.element.android.libraries.matrix.api.core.EventId
99100
import io.element.android.libraries.matrix.api.core.UserId
101+
import io.element.android.libraries.matrix.api.encryption.identity.IdentityState
100102
import io.element.android.libraries.textcomposer.model.TextEditorState
101103
import io.element.android.libraries.ui.strings.CommonStrings
102104
import kotlinx.collections.immutable.ImmutableList
@@ -196,8 +198,8 @@ fun MessagesView(
196198
MessagesViewContent(
197199
state = state,
198200
modifier = Modifier
199-
.padding(padding)
200-
.consumeWindowInsets(padding),
201+
.padding(padding)
202+
.consumeWindowInsets(padding),
201203
onContentClick = ::onContentClick,
202204
onMessageLongClick = ::onMessageLongClick,
203205
onUserDataClick = { hidingKeyboard { onUserDataClick(it) } },
@@ -290,9 +292,9 @@ private fun MessagesViewContent(
290292
) {
291293
Box(
292294
modifier = modifier
293-
.fillMaxSize()
294-
.navigationBarsPadding()
295-
.imePadding(),
295+
.fillMaxSize()
296+
.navigationBarsPadding()
297+
.imePadding(),
296298
) {
297299
AttachmentsBottomSheet(
298300
state = state.composerState,
@@ -402,13 +404,13 @@ private fun MessagesViewComposerBottomSheetContents(
402404
Column(modifier = Modifier.fillMaxWidth()) {
403405
SuggestionsPickerView(
404406
modifier = Modifier
405-
.heightIn(max = 230.dp)
406-
// Consume all scrolling, preventing the bottom sheet from being dragged when interacting with the list of suggestions
407-
.nestedScroll(object : NestedScrollConnection {
408-
override fun onPostScroll(consumed: Offset, available: Offset, source: NestedScrollSource): Offset {
409-
return available
410-
}
411-
}),
407+
.heightIn(max = 230.dp)
408+
// Consume all scrolling, preventing the bottom sheet from being dragged when interacting with the list of suggestions
409+
.nestedScroll(object : NestedScrollConnection {
410+
override fun onPostScroll(consumed: Offset, available: Offset, source: NestedScrollSource): Offset {
411+
return available
412+
}
413+
}),
412414
roomId = state.roomId,
413415
roomName = state.roomName.dataOrNull(),
414416
roomAvatarData = state.roomAvatar.dataOrNull(),
@@ -425,13 +427,20 @@ private fun MessagesViewComposerBottomSheetContents(
425427
onLinkClick = onLinkClick,
426428
)
427429
}
428-
MessageComposerView(
429-
state = state.composerState,
430-
voiceMessageState = state.voiceMessageComposerState,
431-
subcomposing = subcomposing,
432-
enableVoiceMessages = state.enableVoiceMessages,
433-
modifier = Modifier.fillMaxWidth(),
434-
)
430+
val verificationViolation = state.composerState.roomMemberIdentityStateChanges.firstOrNull {
431+
it.identityState == IdentityState.VerificationViolation
432+
}
433+
if (verificationViolation != null) {
434+
DisabledComposerView(modifier = Modifier.fillMaxWidth())
435+
} else {
436+
MessageComposerView(
437+
state = state.composerState,
438+
voiceMessageState = state.voiceMessageComposerState,
439+
subcomposing = subcomposing,
440+
enableVoiceMessages = state.enableVoiceMessages,
441+
modifier = Modifier.fillMaxWidth(),
442+
)
443+
}
435444
}
436445
} else {
437446
CantSendMessageBanner()
@@ -456,8 +465,8 @@ private fun MessagesViewTopBar(
456465
title = {
457466
val roundedCornerShape = RoundedCornerShape(8.dp)
458467
val titleModifier = Modifier
459-
.clip(roundedCornerShape)
460-
.clickable { onRoomDetailsClick() }
468+
.clip(roundedCornerShape)
469+
.clickable { onRoomDetailsClick() }
461470
if (roomName != null && roomAvatar != null) {
462471
RoomAvatarAndNameRow(
463472
roomName = roomName,
@@ -512,9 +521,9 @@ private fun RoomAvatarAndNameRow(
512521
private fun CantSendMessageBanner() {
513522
Row(
514523
modifier = Modifier
515-
.fillMaxWidth()
516-
.background(MaterialTheme.colorScheme.secondary)
517-
.padding(16.dp),
524+
.fillMaxWidth()
525+
.background(MaterialTheme.colorScheme.secondary)
526+
.padding(16.dp),
518527
verticalAlignment = Alignment.CenterVertically,
519528
horizontalArrangement = Arrangement.Center
520529
) {

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/messagecomposer/MessageComposerView.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import io.element.android.features.messages.impl.voicemessages.composer.VoiceMes
2323
import io.element.android.features.messages.impl.voicemessages.composer.aVoiceMessageComposerState
2424
import io.element.android.libraries.designsystem.preview.ElementPreview
2525
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
26-
import io.element.android.libraries.matrix.api.encryption.identity.IdentityState
2726
import io.element.android.libraries.textcomposer.TextComposer
2827
import io.element.android.libraries.textcomposer.model.Suggestion
2928
import io.element.android.libraries.textcomposer.model.VoiceMessagePlayerEvent
@@ -38,14 +37,6 @@ internal fun MessageComposerView(
3837
enableVoiceMessages: Boolean,
3938
modifier: Modifier = Modifier,
4039
) {
41-
val verificationViolation = state.roomMemberIdentityStateChanges.firstOrNull {
42-
it.identityState == IdentityState.VerificationViolation
43-
}
44-
if (verificationViolation != null) {
45-
DisabledComposerView(modifier = modifier)
46-
return
47-
}
48-
4940
val view = LocalView.current
5041
fun sendMessage() {
5142
state.eventSink(MessageComposerEvents.SendMessage)

0 commit comments

Comments
 (0)