mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 19:05:05 +01:00
Clean up bottom nav bar scrolling behavior toggling
This commit is contained in:
parent
7c69b1b649
commit
caeab0a63b
@ -9,6 +9,7 @@ import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.preference.PreferenceDialogController
|
||||
import com.bluelinelabs.conductor.Conductor
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
@ -43,7 +44,6 @@ import eu.kanade.tachiyomi.ui.recent.history.HistoryController
|
||||
import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.android.synthetic.main.main_activity.appbar
|
||||
import kotlinx.android.synthetic.main.main_activity.tabs
|
||||
import kotlinx.coroutines.delay
|
||||
@ -90,7 +90,10 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
|
||||
bottomNavAnimator = ViewHeightAnimator(binding.bottomNav)
|
||||
|
||||
// Set behavior of bottom nav
|
||||
setBottomBarBehaviorOnScroll()
|
||||
preferences.hideBottomBar()
|
||||
.asImmediateFlow { setBottomNavBehaviorOnScroll() }
|
||||
.launchIn(scope)
|
||||
|
||||
binding.bottomNav.setOnNavigationItemSelectedListener { item ->
|
||||
val id = item.itemId
|
||||
|
||||
@ -308,12 +311,6 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
|
||||
!isConfirmingExit
|
||||
}
|
||||
|
||||
private fun setBottomBarBehaviorOnScroll() {
|
||||
val layoutParams = binding.bottomNav.layoutParams as CoordinatorLayout.LayoutParams
|
||||
layoutParams.behavior =
|
||||
if (preferences.hideBottomBar().get()) HideBottomViewOnScrollBehavior<View>() else null
|
||||
}
|
||||
|
||||
fun setSelectedNavItem(itemId: Int) {
|
||||
if (!isFinishing) {
|
||||
binding.bottomNav.selectedItemId = itemId
|
||||
@ -343,7 +340,6 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
|
||||
if (to is RootController) {
|
||||
// Always show bottom nav again when returning to a RootController
|
||||
showBottomNav(visible = true, collapse = from !is RootController)
|
||||
setBottomBarBehaviorOnScroll()
|
||||
}
|
||||
|
||||
if (from is TabbedController) {
|
||||
@ -397,6 +393,17 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun setBottomNavBehaviorOnScroll() {
|
||||
showBottomNav(visible = true)
|
||||
|
||||
binding.bottomNav.updateLayoutParams<CoordinatorLayout.LayoutParams> {
|
||||
behavior = when {
|
||||
preferences.hideBottomBar().get() -> HideBottomViewOnScrollBehavior<View>()
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
// Shortcut actions
|
||||
const val SHORTCUT_LIBRARY = "eu.kanade.tachiyomi.SHOW_LIBRARY"
|
||||
|
Loading…
Reference in New Issue
Block a user