Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typing): back handler and jumping screen typing indicator #2325

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package com.wire.android.ui.home.conversations

import SwipeableSnackbar
import android.net.Uri
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
Expand All @@ -42,6 +43,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusManager
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.LocalUriHandler
Expand Down Expand Up @@ -318,11 +320,7 @@ fun ConversationScreen(
}
}
},
onBackButtonClick = {
messageComposerViewModel.sendTypingEvent(TypingIndicatorMode.STOPPED)
focusManager.clearFocus(true)
navigator.navigateBack()
},
onBackButtonClick = { conversationScreenOnBackButtonClick(messageComposerViewModel, focusManager, navigator) },
composerMessages = messageComposerViewModel.infoMessage,
conversationMessages = conversationMessagesViewModel.infoMessage,
conversationMessagesViewModel = conversationMessagesViewModel,
Expand Down Expand Up @@ -351,6 +349,7 @@ fun ConversationScreen(
},
onTypingEvent = messageComposerViewModel::sendTypingEvent
)
BackHandler { conversationScreenOnBackButtonClick(messageComposerViewModel, focusManager, navigator) }
DeleteMessageDialog(
state = messageComposerViewModel.deleteMessageDialogsState,
actions = messageComposerViewModel.deleteMessageHelper
Expand Down Expand Up @@ -430,6 +429,16 @@ fun ConversationScreen(
}
}

private fun conversationScreenOnBackButtonClick(
messageComposerViewModel: MessageComposerViewModel,
focusManager: FocusManager,
navigator: Navigator
) {
messageComposerViewModel.sendTypingEvent(TypingIndicatorMode.STOPPED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: Not for this PR itself, but it would be best if the the ViewModel isn't commanded by the UI. i.e. instead of viewModel.sendTypingEvent it could be something like viewModel.onNavigateBack and then the ViewModel decides what should be done.

focusManager.clearFocus(true)
navigator.navigateBack()
}

@Suppress("LongParameterList")
private fun startCallIfPossible(
conversationCallViewModel: ConversationCallViewModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@ fun UsersTypingIndicatorForConversation(

@Composable
fun UsersTypingIndicator(usersTyping: List<UIParticipant>) {
if (usersTyping.isNotEmpty()) {
val rememberTransition =
rememberInfiniteTransition(label = stringResource(R.string.animation_label_typing_indicator_horizontal_transition))
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.height(dimensions().spacing24x)
.background(
color = colorsScheme().surface,
shape = RoundedCornerShape(dimensions().corner14x),
)
) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.height(dimensions().spacing24x)
.background(
color = colorsScheme().surface,
shape = RoundedCornerShape(dimensions().corner14x),
)
) {
if (usersTyping.isNotEmpty()) {
val rememberTransition =
rememberInfiniteTransition(label = stringResource(R.string.animation_label_typing_indicator_horizontal_transition))
UsersTypingAvatarPreviews(usersTyping)
Text(
text = pluralStringResource(
Expand Down
Loading