mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 03:07:25 +01:00
Adopt tab/controller transitions from SY
Original author: @jobobby04
This commit is contained in:
parent
9920ff617b
commit
9ba11a585f
@ -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())
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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 = this@ViewHeightAnimator.duration
|
||||
interpolator = DecelerateInterpolator()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user