From b02eb79a2c234f89ecad4affe23171d76e0d14c6 Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Thu, 10 Aug 2023 23:49:44 +0300 Subject: [PATCH] multiplatform: showing progress indicator while sending a text message (#2880) * multiplatform: showing progress indicator while sending a text message * progress indicator after timeout --------- Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> --- .../simplex/common/views/chat/SendMsgView.kt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/SendMsgView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/SendMsgView.kt index 4d9e636ad..0d07fe626 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/SendMsgView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/SendMsgView.kt @@ -64,12 +64,22 @@ fun SendMsgView( Box(Modifier.padding(vertical = 8.dp)) { val cs = composeState.value - val showProgress = cs.inProgress && (cs.preview is ComposePreview.MediaPreview || cs.preview is ComposePreview.FilePreview) + var progressByTimeout by rememberSaveable { mutableStateOf(false) } + LaunchedEffect(composeState.value.inProgress) { + progressByTimeout = if (composeState.value.inProgress) { + delay(500) + composeState.value.inProgress + } else { + false + } + } val showVoiceButton = cs.message.isEmpty() && showVoiceRecordIcon && !composeState.value.editing && cs.liveMessage == null && (cs.preview is ComposePreview.NoPreview || recState.value is RecordingState.Started) val showDeleteTextButton = rememberSaveable { mutableStateOf(false) } PlatformTextField(composeState, textStyle, showDeleteTextButton, userIsObserver, onMessageChange, editPrevMessage) { - sendMessage(null) + if (!cs.inProgress) { + sendMessage(null) + } } // Disable clicks on text field if (cs.preview is ComposePreview.VoicePreview || !userCanSend || cs.inProgress) { @@ -98,7 +108,7 @@ fun SendMsgView( } } when { - showProgress -> ProgressIndicator() + progressByTimeout -> ProgressIndicator() showVoiceButton -> { Row(verticalAlignment = Alignment.CenterVertically) { val stopRecOnNextClick = remember { mutableStateOf(false) }