瀏覽代碼

Use animation to hide/show fab (#6385)

Ivan Iskandar 3 年之前
父節點
當前提交
4c8f5e1f7a

+ 4 - 5
app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt

@@ -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()
     }
 

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

@@ -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()) {

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt

@@ -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 {

+ 6 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabaseController.kt

@@ -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) {