Animate the transition (faster than default), and ensure the callback is called, even if it's a no-op

This commit is contained in:
Benoit Marty 2021-06-10 14:55:17 +02:00 committed by Benoit Marty
parent e91b09ca44
commit 3f4e80992b
1 changed files with 10 additions and 2 deletions

View File

@ -25,6 +25,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.text.toSpannable
import androidx.core.view.isVisible
import androidx.transition.AutoTransition
import androidx.transition.ChangeBounds
import androidx.transition.Fade
import androidx.transition.Transition
@ -35,7 +36,6 @@ import im.vector.app.databinding.ComposerLayoutBinding
/**
* Encapsulate the timeline composer UX.
*
*/
class TextComposerView @JvmOverloads constructor(
context: Context,
@ -71,7 +71,15 @@ class TextComposerView @JvmOverloads constructor(
}
override fun onTextBlankStateChanged(isBlank: Boolean) {
views.sendButton.isVisible = currentConstraintSetId == R.layout.composer_layout_constraint_set_expanded || !isBlank
callback?.onTextBlankStateChanged(isBlank)
val shouldBeVisible = currentConstraintSetId == R.layout.composer_layout_constraint_set_expanded || !isBlank
if (views.sendButton.isVisible != shouldBeVisible) {
TransitionManager.beginDelayedTransition(
this@TextComposerView,
AutoTransition().also { it.duration = 150 }
)
views.sendButton.isVisible = shouldBeVisible
}
}
}
views.composerRelatedMessageCloseButton.setOnClickListener {