Fixes to autohide bottomnav

This commit is contained in:
Jays2Kings 2021-03-20 20:32:47 -04:00
parent d96f0518f2
commit e5d15894dc
2 changed files with 33 additions and 18 deletions

View File

@ -209,7 +209,6 @@ class LibraryController(
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy) super.onScrolled(recyclerView, dx, dy)
val recyclerCover = recycler_cover ?: return val recyclerCover = recycler_cover ?: return
val bottomBar = activity?.bottom_nav
if (!recyclerCover.isClickable && isAnimatingHopper != true) { if (!recyclerCover.isClickable && isAnimatingHopper != true) {
category_hopper_frame.translationY += dy category_hopper_frame.translationY += dy
category_hopper_frame.translationY = category_hopper_frame.translationY =
@ -231,23 +230,7 @@ class LibraryController(
showCategoryText(currentCategory.name) showCategoryText(currentCategory.name)
} }
} }
if (bottomBar != null) { updateFilterSheetY()
if (filter_bottom_sheet.sheetBehavior.isHidden()) {
val pad = bottomBar.translationY - bottomBar.height
filter_bottom_sheet.translationY = pad
} else {
filter_bottom_sheet.translationY = 0f
}
val pad = bottomBar.translationY - bottomBar.height
shadow2.translationY = pad
filter_bottom_sheet.updatePaddingRelative(
bottom = max(
(-bottomBar.translationY + bottomBar.height).toInt(),
view?.rootWindowInsets?.getBottomGestureInsets() ?: 0
)
)
filter_bottom_sheet.sheetBehavior?.peekHeight = 60.dpToPx + filter_bottom_sheet.paddingBottom
}
val savedCurrentCategory = getHeader(true)?.category ?: return val savedCurrentCategory = getHeader(true)?.category ?: return
if (savedCurrentCategory.order != lastUsedCategory) { if (savedCurrentCategory.order != lastUsedCategory) {
lastUsedCategory = savedCurrentCategory.order lastUsedCategory = savedCurrentCategory.order
@ -269,6 +252,30 @@ class LibraryController(
} }
} }
fun updateFilterSheetY() {
val bottomBar = activity?.bottom_nav
if (bottomBar != null) {
if (filter_bottom_sheet.sheetBehavior.isHidden()) {
val pad = bottomBar.translationY - bottomBar.height
filter_bottom_sheet.translationY = pad
} else {
filter_bottom_sheet.translationY = 0f
}
val pad = bottomBar.translationY - bottomBar.height
shadow2.translationY = pad
filter_bottom_sheet.updatePaddingRelative(
bottom = max(
(-bottomBar.translationY + bottomBar.height).toInt(),
view?.rootWindowInsets?.getBottomGestureInsets() ?: 0
)
)
filter_bottom_sheet.sheetBehavior?.peekHeight = 60.dpToPx + filter_bottom_sheet.paddingBottom
fast_scroller.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = -pad.toInt()
}
}
}
fun updateHopperPosition(show: Boolean = false) { fun updateHopperPosition(show: Boolean = false) {
val shortAnimationDuration = resources?.getInteger( val shortAnimationDuration = resources?.getInteger(
android.R.integer.config_shortAnimTime android.R.integer.config_shortAnimTime
@ -354,6 +361,9 @@ class LibraryController(
adapter = LibraryCategoryAdapter(this) adapter = LibraryCategoryAdapter(this)
setRecyclerLayout() setRecyclerLayout()
recycler.post {
updateFilterSheetY()
}
recycler.manager.spanSizeLookup = ( recycler.manager.spanSizeLookup = (
object : GridLayoutManager.SpanSizeLookup() { object : GridLayoutManager.SpanSizeLookup() {

View File

@ -43,11 +43,13 @@ import eu.kanade.tachiyomi.util.view.requestPermissionsSafe
import eu.kanade.tachiyomi.util.view.scrollViewWith import eu.kanade.tachiyomi.util.view.scrollViewWith
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
import eu.kanade.tachiyomi.util.view.snack import eu.kanade.tachiyomi.util.view.snack
import eu.kanade.tachiyomi.util.view.updateLayoutParams
import eu.kanade.tachiyomi.util.view.updatePaddingRelative import eu.kanade.tachiyomi.util.view.updatePaddingRelative
import eu.kanade.tachiyomi.util.view.withFadeTransaction import eu.kanade.tachiyomi.util.view.withFadeTransaction
import kotlinx.android.parcel.Parcelize import kotlinx.android.parcel.Parcelize
import kotlinx.android.synthetic.main.extensions_bottom_sheet.* import kotlinx.android.synthetic.main.extensions_bottom_sheet.*
import kotlinx.android.synthetic.main.extensions_bottom_sheet.sheet_layout import kotlinx.android.synthetic.main.extensions_bottom_sheet.sheet_layout
import kotlinx.android.synthetic.main.extensions_bottom_sheet.view.*
import kotlinx.android.synthetic.main.filter_bottom_sheet.* import kotlinx.android.synthetic.main.filter_bottom_sheet.*
import kotlinx.android.synthetic.main.library_list_controller.* import kotlinx.android.synthetic.main.library_list_controller.*
import kotlinx.android.synthetic.main.main_activity.* import kotlinx.android.synthetic.main.main_activity.*
@ -224,6 +226,9 @@ class SourceController :
val pad = bottomBar.translationY - bottomBar.height val pad = bottomBar.translationY - bottomBar.height
shadow2.translationY = pad shadow2.translationY = pad
ext_bottom_sheet.sheetBehavior?.peekHeight = 48.spToPx + ext_bottom_sheet.paddingBottom ext_bottom_sheet.sheetBehavior?.peekHeight = 48.spToPx + ext_bottom_sheet.paddingBottom
ext_bottom_sheet.fast_scroller.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = -pad.toInt()
}
} }
override fun showSheet() { override fun showSheet() {