mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 11:17:25 +01:00
Swap bottom nav and ActionToolbar when appropriate
This commit is contained in:
parent
b06189ff95
commit
e2158af592
@ -32,6 +32,7 @@ import eu.kanade.tachiyomi.ui.base.controller.RootController
|
|||||||
import eu.kanade.tachiyomi.ui.base.controller.TabbedController
|
import eu.kanade.tachiyomi.ui.base.controller.TabbedController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
|
import eu.kanade.tachiyomi.ui.main.offsetFabAppbarHeight
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
@ -177,6 +178,8 @@ class LibraryController(
|
|||||||
if (preferences.downloadedOnly().get()) {
|
if (preferences.downloadedOnly().get()) {
|
||||||
binding.downloadedOnly.visible()
|
binding.downloadedOnly.visible()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.actionToolbar.offsetFabAppbarHeight(activity!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||||
@ -316,6 +319,7 @@ class LibraryController(
|
|||||||
actionMode!!,
|
actionMode!!,
|
||||||
R.menu.library_selection
|
R.menu.library_selection
|
||||||
) { onActionItemClicked(actionMode!!, it!!) }
|
) { onActionItemClicked(actionMode!!, it!!) }
|
||||||
|
(activity as? MainActivity)?.showBottomNav(visible = false, collapse = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,6 +327,7 @@ class LibraryController(
|
|||||||
* Destroys the action mode.
|
* Destroys the action mode.
|
||||||
*/
|
*/
|
||||||
private fun destroyActionModeIfNeeded() {
|
private fun destroyActionModeIfNeeded() {
|
||||||
|
(activity as? MainActivity)?.showBottomNav(visible = true, collapse = true)
|
||||||
actionMode?.finish()
|
actionMode?.finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,17 +328,11 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
|
|||||||
binding.appbar.setExpanded(true)
|
binding.appbar.setExpanded(true)
|
||||||
|
|
||||||
if ((from == null || from is RootController) && to !is RootController) {
|
if ((from == null || from is RootController) && to !is RootController) {
|
||||||
bottomNavAnimator.collapse()
|
showBottomNav(visible = false, collapse = true)
|
||||||
}
|
}
|
||||||
if (to is RootController) {
|
if (to is RootController) {
|
||||||
if (from !is RootController) {
|
|
||||||
bottomNavAnimator.expand()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Always show bottom nav again when returning to a RootController
|
// Always show bottom nav again when returning to a RootController
|
||||||
val layoutParams = binding.bottomNav.layoutParams as CoordinatorLayout.LayoutParams
|
showBottomNav(visible = true, collapse = from !is RootController)
|
||||||
val bottomViewNavigationBehavior = layoutParams.behavior as HideBottomViewOnScrollBehavior
|
|
||||||
bottomViewNavigationBehavior.slideUp(binding.bottomNav)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (from is TabbedController) {
|
if (from is TabbedController) {
|
||||||
@ -359,6 +353,24 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun showBottomNav(visible: Boolean, collapse: Boolean = false) {
|
||||||
|
val layoutParams = binding.bottomNav.layoutParams as CoordinatorLayout.LayoutParams
|
||||||
|
val bottomViewNavigationBehavior = layoutParams.behavior as HideBottomViewOnScrollBehavior
|
||||||
|
if (visible) {
|
||||||
|
if (collapse) {
|
||||||
|
bottomNavAnimator.expand()
|
||||||
|
}
|
||||||
|
|
||||||
|
bottomViewNavigationBehavior.slideUp(binding.bottomNav)
|
||||||
|
} else {
|
||||||
|
if (collapse) {
|
||||||
|
bottomNavAnimator.collapse()
|
||||||
|
}
|
||||||
|
|
||||||
|
bottomViewNavigationBehavior.slideDown(binding.bottomNav)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
// Shortcut actions
|
// Shortcut actions
|
||||||
const val SHORTCUT_LIBRARY = "eu.kanade.tachiyomi.SHOW_LIBRARY"
|
const val SHORTCUT_LIBRARY = "eu.kanade.tachiyomi.SHOW_LIBRARY"
|
||||||
|
@ -121,8 +121,10 @@ class ChaptersController :
|
|||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
binding.fab.offsetFabAppbarHeight(activity!!)
|
|
||||||
binding.fab.shrinkOnScroll(binding.recycler)
|
binding.fab.shrinkOnScroll(binding.recycler)
|
||||||
|
|
||||||
|
binding.actionToolbar.offsetFabAppbarHeight(activity!!)
|
||||||
|
binding.fab.offsetFabAppbarHeight(activity!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView(view: View) {
|
override fun onDestroyView(view: View) {
|
||||||
|
@ -22,6 +22,8 @@ import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController
|
|||||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
|
import eu.kanade.tachiyomi.ui.main.offsetFabAppbarHeight
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
import eu.kanade.tachiyomi.util.system.notificationManager
|
import eu.kanade.tachiyomi.util.system.notificationManager
|
||||||
@ -109,6 +111,8 @@ class UpdatesController :
|
|||||||
binding.swipeRefresh.isRefreshing = false
|
binding.swipeRefresh.isRefreshing = false
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
|
binding.actionToolbar.offsetFabAppbarHeight(activity!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView(view: View) {
|
override fun onDestroyView(view: View) {
|
||||||
@ -176,6 +180,7 @@ class UpdatesController :
|
|||||||
actionMode!!,
|
actionMode!!,
|
||||||
R.menu.updates_chapter_selection
|
R.menu.updates_chapter_selection
|
||||||
) { onActionItemClicked(actionMode!!, it!!) }
|
) { onActionItemClicked(actionMode!!, it!!) }
|
||||||
|
(activity as? MainActivity)?.showBottomNav(visible = false, collapse = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleSelection(position)
|
toggleSelection(position)
|
||||||
@ -266,6 +271,7 @@ class UpdatesController :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun destroyActionModeIfNeeded() {
|
private fun destroyActionModeIfNeeded() {
|
||||||
|
(activity as? MainActivity)?.showBottomNav(visible = true, collapse = true)
|
||||||
actionMode?.finish()
|
actionMode?.finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user