Skip to content

Commit

Permalink
apply only a ChangeBounds when back gesture is cancelled for the pred…
Browse files Browse the repository at this point in the history
…ictive back androidx transitions sample
  • Loading branch information
ashnohe committed Sep 27, 2023
1 parent b1a3787 commit 0dfc962
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,17 @@ class PBTransition : Fragment() {

override fun handleOnBackCancelled() {
// If the user cancels the back gesture, reset the state
transition(ShowText.LONG)
TransitionManager.beginDelayedTransition(
binding.textContainer,
ChangeBounds()
)
changeTextVisibility(ShowText.LONG)
}
}

binding.shortText.setOnClickListener {
transition(ShowText.LONG)
TransitionManager.beginDelayedTransition(binding.textContainer, transitionSet)
changeTextVisibility(ShowText.LONG)
callback.isEnabled = true
}

Expand All @@ -103,11 +108,6 @@ class PBTransition : Fragment() {
_binding = null
}

private fun transition(showText: ShowText) {
TransitionManager.beginDelayedTransition(binding.textContainer, transitionSet)
changeTextVisibility(showText)
}

enum class ShowText { SHORT, LONG }
private fun changeTextVisibility(showText: ShowText) {
when (showText) {
Expand Down

0 comments on commit 0dfc962

Please sign in to comment.