Explorar el Código

Don't hide side nav when opening ActionToolbar on tablets

arkon hace 3 años
padre
commit
fa872f6cf7

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt

@@ -367,7 +367,7 @@ class LibraryController(
                 actionMode!!,
                 R.menu.library_selection
             ) { onActionItemClicked(it!!) }
-            (activity as? MainActivity)?.showNav(visible = false, collapse = true)
+            (activity as? MainActivity)?.showBottomNav(visible = false, collapse = true)
         }
     }
 
@@ -476,7 +476,7 @@ class LibraryController(
         selectionRelay.call(LibrarySelectionEvent.Cleared())
 
         binding.actionToolbar.hide()
-        (activity as? MainActivity)?.showNav(visible = true, collapse = true)
+        (activity as? MainActivity)?.showBottomNav(visible = true, collapse = true)
 
         actionMode = null
     }

+ 10 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt

@@ -140,7 +140,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
             binding.toolbarLayout.appbar.addOnOffsetChangedListener(
                 AppBarLayout.OnOffsetChangedListener { _, verticalOffset ->
                     if (verticalOffset == 0) {
-                        showNav(true)
+                        showNav(visible = true)
                     }
                 }
             )
@@ -451,7 +451,13 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
         }
     }
 
-    fun showNav(visible: Boolean, collapse: Boolean = false) {
+    private fun showNav(visible: Boolean, collapse: Boolean = false) {
+        showBottomNav(visible, collapse)
+        showSideNav(visible)
+    }
+
+    // Also used from some controllers to swap bottom nav with action toolbar
+    fun showBottomNav(visible: Boolean, collapse: Boolean = false) {
         binding.bottomNav?.let {
             val layoutParams = it.layoutParams as CoordinatorLayout.LayoutParams
             val bottomViewNavigationBehavior =
@@ -470,7 +476,9 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
                 bottomViewNavigationBehavior?.slideDown(it)
             }
         }
+    }
 
+    private fun showSideNav(visible: Boolean) {
         binding.sideNav?.let {
             it.isVisible = visible
         }

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt

@@ -182,7 +182,7 @@ class UpdatesController :
                 actionMode!!,
                 R.menu.updates_chapter_selection
             ) { onActionItemClicked(it!!) }
-            (activity as? MainActivity)?.showNav(visible = false, collapse = true)
+            (activity as? MainActivity)?.showBottomNav(visible = false, collapse = true)
         }
 
         toggleSelection(position)
@@ -380,7 +380,7 @@ class UpdatesController :
         adapter?.clearSelection()
 
         binding.actionToolbar.hide()
-        (activity as? MainActivity)?.showNav(visible = true, collapse = true)
+        (activity as? MainActivity)?.showBottomNav(visible = true, collapse = true)
 
         actionMode = null
     }