TextComposer: makes animation ok

This commit is contained in:
ganfra 2021-09-30 11:57:57 +02:00
parent 6b3a407b79
commit a171f1912a
3 changed files with 9 additions and 10 deletions

View file

@ -417,7 +417,7 @@ class RoomDetailFragment @Inject constructor(
is TextComposerViewEvents.SendMessageResult -> renderSendMessageResult(it)
is TextComposerViewEvents.ShowMessage -> showSnackWithMessage(it.message)
is TextComposerViewEvents.ShowRoomUpgradeDialog -> handleShowRoomUpgradeDialog(it)
is TextComposerViewEvents.OnSendButtonVisibilityChanged -> handleOnSendButtonVisibilityChanged(it)
is TextComposerViewEvents.AnimateSendButtonVisibility -> handleSendButtonVisibilityChanged(it)
}.exhaustive
}
@ -468,8 +468,7 @@ class RoomDetailFragment @Inject constructor(
}
}
private fun handleOnSendButtonVisibilityChanged(event: TextComposerViewEvents.OnSendButtonVisibilityChanged) {
Timber.v("Handle on SendButtonVisibility: $event")
private fun handleSendButtonVisibilityChanged(event: TextComposerViewEvents.AnimateSendButtonVisibility) {
if (event.isVisible) {
views.voiceMessageRecorderView.isVisible = false
views.composerLayout.views.sendButton.alpha = 0f

View file

@ -22,7 +22,7 @@ import im.vector.app.features.command.Command
sealed class TextComposerViewEvents : VectorViewEvents {
data class OnSendButtonVisibilityChanged(val isVisible: Boolean): TextComposerViewEvents()
data class AnimateSendButtonVisibility(val isVisible: Boolean): TextComposerViewEvents()
data class ShowMessage(val message: String) : TextComposerViewEvents()

View file

@ -99,19 +99,19 @@ class TextComposerViewModel @AssistedInject constructor(
currentComposerText = action.text
this
}
updateIsSendButtonVisibility()
updateIsSendButtonVisibility(true)
}
private fun subscribeToStateInternal() {
selectSubscribe(TextComposerViewState::sendMode, TextComposerViewState::canSendMessage, TextComposerViewState::isVoiceRecording) { _, _, _ ->
updateIsSendButtonVisibility()
updateIsSendButtonVisibility(false)
}
}
private fun updateIsSendButtonVisibility() = setState {
private fun updateIsSendButtonVisibility(triggerAnimation: Boolean) = setState {
val isSendButtonVisible = isComposerVisible && (sendMode !is SendMode.REGULAR || currentComposerText.isNotBlank())
if (this.isSendButtonVisible != isSendButtonVisible) {
_viewEvents.post(TextComposerViewEvents.OnSendButtonVisibilityChanged(isSendButtonVisible))
if (this.isSendButtonVisible != isSendButtonVisible && triggerAnimation) {
_viewEvents.post(TextComposerViewEvents.AnimateSendButtonVisibility(isSendButtonVisible))
}
copy(isSendButtonVisible = isSendButtonVisible)
}