Hide & Expand Categories buttons now show/hide dynamically

This commit is contained in:
Jay 2020-05-08 15:08:17 -04:00
parent 38ea9eea16
commit 1aede09d35
2 changed files with 13 additions and 0 deletions

View File

@ -639,6 +639,10 @@ class LibraryController(
scrollToHeader(activeCategory)
}
category_hopper_frame.visibleIf(!singleCategory)
filter_bottom_sheet.updateButtons(
showHideCategories = presenter.allCategories.size > 1,
showExpand = !singleCategory && presenter.showAllCategories
)
adapter.isLongPressDragEnabled = canDrag()
category_recycler.setCategories(presenter.categories)
filter_bottom_sheet.setExpandText(preferences.collapsedCategories().getOrDefault().isNotEmpty())

View File

@ -27,6 +27,7 @@ import eu.kanade.tachiyomi.util.view.hide
import eu.kanade.tachiyomi.util.view.inflate
import eu.kanade.tachiyomi.util.view.isExpanded
import eu.kanade.tachiyomi.util.view.isHidden
import eu.kanade.tachiyomi.util.view.isVisible
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.android.synthetic.main.filter_bottom_sheet.view.*
@ -429,6 +430,14 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
}
}
fun updateButtons(showHideCategories: Boolean, showExpand: Boolean) {
hide_categories.visibleIf(showHideCategories)
expand_categories.visibleIf(showExpand)
first_layout.visibleIf(
hide_categories.isVisible() || expand_categories.isVisible() || !second_layout.isVisible()
)
}
private fun clearFilters() {
preferences.filterDownloaded().set(0)
preferences.filterUnread().set(0)