Browse Source

Adopt tab/controller transitions from SY

Original author: @jobobby04
arkon 4 years ago
parent
commit
9ba11a585f

+ 3 - 3
app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt

@@ -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)
-        .pushChangeHandler(FadeChangeHandler(duration))
-        .popChangeHandler(FadeChangeHandler(duration))
+        .pushChangeHandler(FadeChangeHandler())
+        .popChangeHandler(FadeChangeHandler())
 }

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt

@@ -86,7 +86,7 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
 
         setSupportActionBar(binding.toolbar)
 
-        tabAnimator = ViewHeightAnimator(binding.tabs)
+        tabAnimator = ViewHeightAnimator(binding.tabs, 0L)
         bottomNavAnimator = ViewHeightAnimator(binding.bottomNav)
 
         // Set behavior of bottom nav
@@ -312,7 +312,7 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
     }
 
     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) {

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/main/ViewHeightAnimator.kt

@@ -6,7 +6,7 @@ import android.view.ViewTreeObserver
 import android.view.animation.DecelerateInterpolator
 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.
@@ -23,7 +23,7 @@ class ViewHeightAnimator(val view: View) {
      */
     private val animation by lazy {
         ObjectAnimator.ofInt(this, "height", height).apply {
-            duration = 250L
+            duration = [email protected]
             interpolator = DecelerateInterpolator()
         }
     }