From 27fd73dbb5d1cddeb2e4c6a1358a51891dc7ae38 Mon Sep 17 00:00:00 2001 From: Ivan Iskandar Date: Tue, 20 Apr 2021 13:39:59 +0700 Subject: [PATCH] MainActivity: Show bottom nav when the tab page is changed --- .../java/eu/kanade/tachiyomi/ui/main/MainActivity.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 0865205403..04ca81a17f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -24,6 +24,7 @@ import com.bluelinelabs.conductor.Router import com.bluelinelabs.conductor.RouterTransaction import com.google.android.material.appbar.AppBarLayout import com.google.android.material.behavior.HideBottomViewOnScrollBehavior +import com.google.android.material.tabs.TabLayout import dev.chrisbanes.insetter.applyInsetter import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.Migrations @@ -53,6 +54,7 @@ import eu.kanade.tachiyomi.util.lang.launchUI import eu.kanade.tachiyomi.util.system.InternalResourceHelper import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.toast +import eu.kanade.tachiyomi.widget.SimpleTabSelectedListener import kotlinx.coroutines.delay import kotlinx.coroutines.flow.launchIn import timber.log.Timber @@ -130,6 +132,14 @@ class MainActivity : BaseViewBindingActivity() { tabAnimator = ViewHeightAnimator(binding.tabs, 0L) bottomNavAnimator = ViewHeightAnimator(binding.bottomNav) + // If bottom nav is hidden, make it visible again when the tab page is changed + // in case the new page is un-scrollable. + binding.tabs.addOnTabSelectedListener(object : SimpleTabSelectedListener() { + override fun onTabSelected(tab: TabLayout.Tab?) { + showBottomNav(true) + } + }) + // Set behavior of bottom nav preferences.hideBottomBar() .asImmediateFlow { setBottomNavBehaviorOnScroll() }