Tweak on hide bottom navigation behavior
This commit is contained in:
@@ -13,6 +13,7 @@ import com.google.android.material.appbar.AppBarLayout
|
|||||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
import org.koitharu.kotatsu.utils.ext.animatorDurationScale
|
import org.koitharu.kotatsu.utils.ext.animatorDurationScale
|
||||||
import org.koitharu.kotatsu.utils.ext.findChild
|
import org.koitharu.kotatsu.utils.ext.findChild
|
||||||
|
import org.koitharu.kotatsu.utils.ext.measureHeight
|
||||||
import kotlin.math.roundToLong
|
import kotlin.math.roundToLong
|
||||||
|
|
||||||
class HideBottomNavigationOnScrollBehavior @JvmOverloads constructor(
|
class HideBottomNavigationOnScrollBehavior @JvmOverloads constructor(
|
||||||
@@ -36,9 +37,9 @@ class HideBottomNavigationOnScrollBehavior @JvmOverloads constructor(
|
|||||||
child: BottomNavigationView,
|
child: BottomNavigationView,
|
||||||
dependency: View,
|
dependency: View,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val toolbarSize = (dependency as ViewGroup).findChild<Toolbar>()?.height ?: 0
|
val appBarSize = dependency.measureHeight()
|
||||||
dyRatio = if (toolbarSize > 0) {
|
dyRatio = if (appBarSize > 0) {
|
||||||
child.height.toFloat() / toolbarSize
|
child.measureHeight().toFloat() / appBarSize
|
||||||
} else {
|
} else {
|
||||||
1F
|
1F
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user