mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
TextComposer: makes animation ok
This commit is contained in:
parent
6b3a407b79
commit
a171f1912a
3 changed files with 9 additions and 10 deletions
|
@ -416,8 +416,8 @@ class RoomDetailFragment @Inject constructor(
|
|||
is TextComposerViewEvents.JoinRoomCommandSuccess -> handleJoinedToAnotherRoom(it)
|
||||
is TextComposerViewEvents.SendMessageResult -> renderSendMessageResult(it)
|
||||
is TextComposerViewEvents.ShowMessage -> showSnackWithMessage(it.message)
|
||||
is TextComposerViewEvents.ShowRoomUpgradeDialog -> handleShowRoomUpgradeDialog(it)
|
||||
is TextComposerViewEvents.OnSendButtonVisibilityChanged -> handleOnSendButtonVisibilityChanged(it)
|
||||
is TextComposerViewEvents.ShowRoomUpgradeDialog -> handleShowRoomUpgradeDialog(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
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue