Adopt tab/controller transitions from SY

Original author: @jobobby04
This commit is contained in:
arkon 2020-08-22 13:03:39 -04:00
parent 9920ff617b
commit 9ba11a585f
3 changed files with 7 additions and 7 deletions

View file

@ -28,8 +28,8 @@ fun Controller.requestPermissionsSafe(permissions: Array<String>, requestCode: I
} }
} }
fun Controller.withFadeTransaction(duration: Long = 150L): RouterTransaction { fun Controller.withFadeTransaction(): RouterTransaction {
return RouterTransaction.with(this) return RouterTransaction.with(this)
.pushChangeHandler(FadeChangeHandler(duration)) .pushChangeHandler(FadeChangeHandler())
.popChangeHandler(FadeChangeHandler(duration)) .popChangeHandler(FadeChangeHandler())
} }

View file

@ -86,7 +86,7 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
setSupportActionBar(binding.toolbar) setSupportActionBar(binding.toolbar)
tabAnimator = ViewHeightAnimator(binding.tabs) tabAnimator = ViewHeightAnimator(binding.tabs, 0L)
bottomNavAnimator = ViewHeightAnimator(binding.bottomNav) bottomNavAnimator = ViewHeightAnimator(binding.bottomNav)
// Set behavior of bottom nav // Set behavior of bottom nav
@ -312,7 +312,7 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
} }
private fun setRoot(controller: Controller, id: Int) { private fun setRoot(controller: Controller, id: Int) {
router.setRoot(RouterTransaction.with(controller).tag(id.toString())) router.setRoot(controller.withFadeTransaction().tag(id.toString()))
} }
private fun syncActivityViewWithController(to: Controller?, from: Controller? = null) { private fun syncActivityViewWithController(to: Controller?, from: Controller? = null) {

View file

@ -6,7 +6,7 @@ import android.view.ViewTreeObserver
import android.view.animation.DecelerateInterpolator import android.view.animation.DecelerateInterpolator
import androidx.annotation.Keep import androidx.annotation.Keep
class ViewHeightAnimator(val view: View) { class ViewHeightAnimator(val view: View, val duration: Long = 250L) {
/** /**
* The default height of the view. It's unknown until the view is layout. * The default height of the view. It's unknown until the view is layout.
@ -23,7 +23,7 @@ class ViewHeightAnimator(val view: View) {
*/ */
private val animation by lazy { private val animation by lazy {
ObjectAnimator.ofInt(this, "height", height).apply { ObjectAnimator.ofInt(this, "height", height).apply {
duration = 250L duration = this@ViewHeightAnimator.duration
interpolator = DecelerateInterpolator() interpolator = DecelerateInterpolator()
} }
} }