Use animation to hide/show fab (#6385)

This commit is contained in:
Ivan Iskandar 2021-12-26 23:38:35 +07:00 committed by GitHub
parent 733cf99bb4
commit 4c8f5e1f7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 10 deletions

View File

@ -159,13 +159,12 @@ open class BrowseSourceController(bundle: Bundle) :
)
filterSheet?.setFilters(presenter.filterItems)
// TODO: [ExtendedFloatingActionButton] hide/show methods don't work properly
filterSheet?.setOnShowListener { actionFab?.isVisible = false }
filterSheet?.setOnDismissListener { actionFab?.isVisible = true }
filterSheet?.setOnShowListener { actionFab?.hide() }
filterSheet?.setOnDismissListener { actionFab?.show() }
actionFab?.setOnClickListener { filterSheet?.show() }
actionFab?.isVisible = true
actionFab?.show()
}
override fun configureFab(fab: ExtendedFloatingActionButton) {
@ -175,7 +174,7 @@ open class BrowseSourceController(bundle: Bundle) :
fab.setIconResource(R.drawable.ic_filter_list_24dp)
// Controlled by initFilterSheet()
fab.isVisible = false
fab.hide()
initFilterSheet()
}

View File

@ -562,12 +562,13 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
binding.tabs.isVisible = to is TabbedController
if (from is FabController) {
binding.fabLayout.rootFab.isVisible = false
from.cleanupFab(binding.fabLayout.rootFab)
}
if (to is FabController) {
binding.fabLayout.rootFab.isVisible = true
binding.fabLayout.rootFab.show()
to.configureFab(binding.fabLayout.rootFab)
} else {
binding.fabLayout.rootFab.hide()
}
if (!isTablet()) {

View File

@ -303,7 +303,7 @@ class MangaController :
actionFabScrollListener = actionFab?.shrinkOnScroll(chapterRecycler)
// Initially set FAB invisible; will become visible if unread chapters are present
actionFab?.isVisible = false
actionFab?.hide()
binding.swipeRefresh.refreshes()
.onEach {

View File

@ -125,7 +125,7 @@ class ClearDatabaseController :
override fun configureFab(fab: ExtendedFloatingActionButton) {
fab.setIconResource(R.drawable.ic_delete_24dp)
fab.setText(R.string.action_delete)
fab.isVisible = false
fab.hide()
fab.setOnClickListener {
val ctrl = ClearDatabaseSourcesDialog()
ctrl.targetController = this
@ -136,7 +136,11 @@ class ClearDatabaseController :
private fun updateFab() {
val adapter = adapter ?: return
actionFab?.isVisible = adapter.selectedItemCount > 0
if (adapter.selectedItemCount > 0) {
actionFab?.show()
} else {
actionFab?.hide()
}
}
override fun cleanupFab(fab: ExtendedFloatingActionButton) {