TextComposer: makes animation ok
This commit is contained in:
parent
6b3a407b79
commit
a171f1912a
@ -416,8 +416,8 @@ class RoomDetailFragment @Inject constructor(
|
|||||||
is TextComposerViewEvents.JoinRoomCommandSuccess -> handleJoinedToAnotherRoom(it)
|
is TextComposerViewEvents.JoinRoomCommandSuccess -> handleJoinedToAnotherRoom(it)
|
||||||
is TextComposerViewEvents.SendMessageResult -> renderSendMessageResult(it)
|
is TextComposerViewEvents.SendMessageResult -> renderSendMessageResult(it)
|
||||||
is TextComposerViewEvents.ShowMessage -> showSnackWithMessage(it.message)
|
is TextComposerViewEvents.ShowMessage -> showSnackWithMessage(it.message)
|
||||||
is TextComposerViewEvents.ShowRoomUpgradeDialog -> handleShowRoomUpgradeDialog(it)
|
is TextComposerViewEvents.ShowRoomUpgradeDialog -> handleShowRoomUpgradeDialog(it)
|
||||||
is TextComposerViewEvents.OnSendButtonVisibilityChanged -> handleOnSendButtonVisibilityChanged(it)
|
is TextComposerViewEvents.AnimateSendButtonVisibility -> handleSendButtonVisibilityChanged(it)
|
||||||
}.exhaustive
|
}.exhaustive
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,8 +468,7 @@ class RoomDetailFragment @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleOnSendButtonVisibilityChanged(event: TextComposerViewEvents.OnSendButtonVisibilityChanged) {
|
private fun handleSendButtonVisibilityChanged(event: TextComposerViewEvents.AnimateSendButtonVisibility) {
|
||||||
Timber.v("Handle on SendButtonVisibility: $event")
|
|
||||||
if (event.isVisible) {
|
if (event.isVisible) {
|
||||||
views.voiceMessageRecorderView.isVisible = false
|
views.voiceMessageRecorderView.isVisible = false
|
||||||
views.composerLayout.views.sendButton.alpha = 0f
|
views.composerLayout.views.sendButton.alpha = 0f
|
||||||
|
@ -22,7 +22,7 @@ import im.vector.app.features.command.Command
|
|||||||
|
|
||||||
sealed class TextComposerViewEvents : VectorViewEvents {
|
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()
|
data class ShowMessage(val message: String) : TextComposerViewEvents()
|
||||||
|
|
||||||
|
@ -99,19 +99,19 @@ class TextComposerViewModel @AssistedInject constructor(
|
|||||||
currentComposerText = action.text
|
currentComposerText = action.text
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
updateIsSendButtonVisibility()
|
updateIsSendButtonVisibility(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun subscribeToStateInternal() {
|
private fun subscribeToStateInternal() {
|
||||||
selectSubscribe(TextComposerViewState::sendMode, TextComposerViewState::canSendMessage, TextComposerViewState::isVoiceRecording) { _, _, _ ->
|
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())
|
val isSendButtonVisible = isComposerVisible && (sendMode !is SendMode.REGULAR || currentComposerText.isNotBlank())
|
||||||
if (this.isSendButtonVisible != isSendButtonVisible) {
|
if (this.isSendButtonVisible != isSendButtonVisible && triggerAnimation) {
|
||||||
_viewEvents.post(TextComposerViewEvents.OnSendButtonVisibilityChanged(isSendButtonVisible))
|
_viewEvents.post(TextComposerViewEvents.AnimateSendButtonVisibility(isSendButtonVisible))
|
||||||
}
|
}
|
||||||
copy(isSendButtonVisible = isSendButtonVisible)
|
copy(isSendButtonVisible = isSendButtonVisible)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user