Make animations smoother, add change handlers to bottom nav transactions, make animations go by their default value instead of a custom fast one

This commit is contained in:
Jobobby04 2020-08-18 22:23:39 -04:00
parent eb0a1668f8
commit c41148b465
2 changed files with 6 additions and 5 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)
.pushChangeHandler(FadeChangeHandler(duration))
.popChangeHandler(FadeChangeHandler(duration))
.pushChangeHandler(FadeChangeHandler())
.popChangeHandler(FadeChangeHandler())
}

View File

@ -16,6 +16,7 @@ import com.bluelinelabs.conductor.Controller
import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.behavior.HideBottomViewOnScrollBehavior
import com.google.android.material.tabs.TabLayout
@ -110,7 +111,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
@ -368,7 +369,7 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
}
private fun setRoot(controller: Controller, id: Int) {
router.setRoot(RouterTransaction.with(controller).tag(id.toString()))
router.setRoot(RouterTransaction.with(controller).tag(id.toString()).pushChangeHandler(FadeChangeHandler()).popChangeHandler(FadeChangeHandler()))
}
private fun syncActivityViewWithController(to: Controller?, from: Controller? = null) {