Tweak on hide bottom navigation behavior

This commit is contained in:
Zakhar Timoshenko
2022-07-14 00:08:20 +03:00
parent 4607e5ba0f
commit 517f2bcee7

View File

@@ -13,6 +13,7 @@ import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.bottomnavigation.BottomNavigationView
import org.koitharu.kotatsu.utils.ext.animatorDurationScale
import org.koitharu.kotatsu.utils.ext.findChild
import org.koitharu.kotatsu.utils.ext.measureHeight
import kotlin.math.roundToLong
class HideBottomNavigationOnScrollBehavior @JvmOverloads constructor(
@@ -36,9 +37,9 @@ class HideBottomNavigationOnScrollBehavior @JvmOverloads constructor(
child: BottomNavigationView,
dependency: View,
): Boolean {
val toolbarSize = (dependency as ViewGroup).findChild<Toolbar>()?.height ?: 0
dyRatio = if (toolbarSize > 0) {
child.height.toFloat() / toolbarSize
val appBarSize = dependency.measureHeight()
dyRatio = if (appBarSize > 0) {
child.measureHeight().toFloat() / appBarSize
} else {
1F
}