Change animation for bottom nav switching to fade in, but not fade out

This commit is contained in:
Jays2Kings 2021-12-14 16:25:53 -05:00
parent f12193c119
commit b3ad1afd9a
3 changed files with 10 additions and 2 deletions

View file

@ -21,6 +21,7 @@ class OneWayFadeChangeHandler : FadeChangeHandler {
removesFromViewOnPush
)
var fadeOut = true
override fun getAnimator(
container: ViewGroup,
from: View?,
@ -36,7 +37,7 @@ class OneWayFadeChangeHandler : FadeChangeHandler {
val hasSideNav = container.context.resources.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE
if (from != null && (!isPush || removesFromViewOnPush())) {
if (!hasSideNav) {
if (!hasSideNav && fadeOut) {
animator.play(ObjectAnimator.ofFloat(from, View.ALPHA, 0f))
} else {
container.removeView(from)

View file

@ -88,6 +88,7 @@ import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsetsCompat
import eu.kanade.tachiyomi.util.view.getItemView
import eu.kanade.tachiyomi.util.view.snack
import eu.kanade.tachiyomi.util.view.withFadeTransaction
import eu.kanade.tachiyomi.util.view.withFadeInTransaction
import eu.kanade.tachiyomi.widget.EndAnimatorListener
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
@ -755,7 +756,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), DownloadServiceLi
}
private fun setRoot(controller: Controller, id: Int) {
router.setRoot(controller.withFadeTransaction().tag(id.toString()))
router.setRoot(controller.withFadeInTransaction().tag(id.toString()))
}
override fun onPrepareOptionsMenu(menu: Menu?): Boolean {

View file

@ -570,6 +570,12 @@ fun Controller.withFadeTransaction(): RouterTransaction {
.popChangeHandler(OneWayFadeChangeHandler())
}
fun Controller.withFadeInTransaction(): RouterTransaction {
return RouterTransaction.with(this)
.pushChangeHandler(OneWayFadeChangeHandler().apply { fadeOut = false })
.popChangeHandler(OneWayFadeChangeHandler())
}
fun Controller.openInBrowser(url: String) {
try {
val intent = Intent(Intent.ACTION_VIEW, url.toUri())