mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-11 13:39:11 +01:00
Hiding blocking bottom view on scroll + appbar/bottombar snap together
just as a reminder bottom view is the view under bottom nav to block touches while bottom nav is showwing
This commit is contained in:
parent
0bb399979f
commit
003c6ed255
@ -250,6 +250,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bottom_nav.visibleIf(!hideBottomNav)
|
bottom_nav.visibleIf(!hideBottomNav)
|
||||||
|
bottom_view.visibility = if (hideBottomNav) View.GONE else bottom_view.visibility
|
||||||
bottom_nav.alpha = if (hideBottomNav) 0f else 1f
|
bottom_nav.alpha = if (hideBottomNav) 0f else 1f
|
||||||
router.addChangeListener(
|
router.addChangeListener(
|
||||||
object : ControllerChangeHandler.ControllerChangeListener {
|
object : ControllerChangeHandler.ControllerChangeListener {
|
||||||
@ -625,7 +626,8 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
|||||||
}
|
}
|
||||||
alphaAnimation.addListener(
|
alphaAnimation.addListener(
|
||||||
EndAnimatorListener {
|
EndAnimatorListener {
|
||||||
bottom_nav.visibility = if (hideBottomNav) View.GONE else View.VISIBLE
|
bottom_nav.visibleIf(!hideBottomNav)
|
||||||
|
bottom_view.visibility = if (hideBottomNav) View.GONE else bottom_view.visibility
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
alphaAnimation.duration = 200
|
alphaAnimation.duration = 200
|
||||||
|
@ -15,6 +15,7 @@ import androidx.appcompat.widget.SearchView
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.math.MathUtils
|
import androidx.core.math.MathUtils
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
import com.bluelinelabs.conductor.Controller
|
import com.bluelinelabs.conductor.Controller
|
||||||
@ -123,8 +124,12 @@ fun Controller.scrollViewWith(
|
|||||||
recycler.requestApplyInsets()
|
recycler.requestApplyInsets()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recycler.post {
|
val updateViewsNearBottom = {
|
||||||
onBottomNavUpdate?.invoke()
|
onBottomNavUpdate?.invoke()
|
||||||
|
activity?.bottom_view?.translationY = activity?.bottom_nav?.translationY ?: 0f
|
||||||
|
}
|
||||||
|
recycler.post {
|
||||||
|
updateViewsNearBottom()
|
||||||
}
|
}
|
||||||
val randomTag = Random.nextLong()
|
val randomTag = Random.nextLong()
|
||||||
var lastY = 0f
|
var lastY = 0f
|
||||||
@ -248,14 +253,16 @@ fun Controller.scrollViewWith(
|
|||||||
activity!!.appbar.animate().y(0f)
|
activity!!.appbar.animate().y(0f)
|
||||||
.setDuration(shortAnimationDuration.toLong())
|
.setDuration(shortAnimationDuration.toLong())
|
||||||
.start()
|
.start()
|
||||||
|
if (router.backstackSize == 1) {
|
||||||
activity!!.bottom_nav?.let {
|
activity!!.bottom_nav?.let {
|
||||||
val animator = it.animate()?.translationY(0f)
|
val animator = it.animate()?.translationY(0f)
|
||||||
?.setDuration(shortAnimationDuration.toLong())
|
?.setDuration(shortAnimationDuration.toLong())
|
||||||
animator?.setUpdateListener {
|
animator?.setUpdateListener {
|
||||||
onBottomNavUpdate?.invoke()
|
updateViewsNearBottom()
|
||||||
}
|
}
|
||||||
animator?.start()
|
animator?.start()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
lastY = 0f
|
lastY = 0f
|
||||||
if (elevate) elevateFunc(false)
|
if (elevate) elevateFunc(false)
|
||||||
} else {
|
} else {
|
||||||
@ -275,8 +282,7 @@ fun Controller.scrollViewWith(
|
|||||||
0f,
|
0f,
|
||||||
tabBar.height.toFloat()
|
tabBar.height.toFloat()
|
||||||
)
|
)
|
||||||
activity!!.bottom_view?.translationY = tabBar.translationY
|
updateViewsNearBottom()
|
||||||
onBottomNavUpdate?.invoke()
|
|
||||||
} else if (tabBar.translationY != 0f) {
|
} else if (tabBar.translationY != 0f) {
|
||||||
tabBar.translationY = 0f
|
tabBar.translationY = 0f
|
||||||
activity!!.bottom_view?.translationY = 0f
|
activity!!.bottom_view?.translationY = 0f
|
||||||
@ -305,25 +311,28 @@ fun Controller.scrollViewWith(
|
|||||||
activity != null && activity!!.appbar.height > 0 &&
|
activity != null && activity!!.appbar.height > 0 &&
|
||||||
recycler.translationY == 0f
|
recycler.translationY == 0f
|
||||||
) {
|
) {
|
||||||
val halfWay = abs((-activity!!.appbar.height.toFloat()) / 2)
|
val halfWay = activity!!.appbar.height.toFloat() / 2
|
||||||
val shortAnimationDuration = resources?.getInteger(
|
val shortAnimationDuration = resources?.getInteger(
|
||||||
android.R.integer.config_shortAnimTime
|
android.R.integer.config_shortAnimTime
|
||||||
) ?: 0
|
) ?: 0
|
||||||
val closerToTop = abs(activity!!.appbar.y) - halfWay > 0
|
val closerToTop = abs(activity!!.appbar.y) > halfWay
|
||||||
|
val halfWayBottom = activity!!.bottom_nav.height.toFloat() / 2
|
||||||
|
val closerToBottom = activity!!.bottom_nav.translationY > halfWayBottom
|
||||||
val atTop = !recycler.canScrollVertically(-1)
|
val atTop = !recycler.canScrollVertically(-1)
|
||||||
lastY = if (closerToTop && !atTop) (-activity!!.appbar.height.toFloat()) else 0f
|
val closerToEdge = if (activity!!.bottom_nav.isVisible) closerToBottom else closerToTop
|
||||||
|
lastY = if (closerToEdge && !atTop) (-activity!!.appbar.height.toFloat()) else 0f
|
||||||
activity!!.appbar.animate().y(lastY).setDuration(shortAnimationDuration.toLong()).start()
|
activity!!.appbar.animate().y(lastY).setDuration(shortAnimationDuration.toLong()).start()
|
||||||
|
if (activity!!.bottom_nav.isVisible) {
|
||||||
activity!!.bottom_nav?.let {
|
activity!!.bottom_nav?.let {
|
||||||
val halfWayBottom = abs((it.height.toFloat()) / 2)
|
val lastBottomY = if (closerToEdge && !atTop) it.height.toFloat() else 0f
|
||||||
val closerToBottom = it.translationY > halfWayBottom
|
|
||||||
val lastBottomY = if (closerToBottom && !atTop) it.height.toFloat() else 0f
|
|
||||||
val animator = it.animate()?.translationY(lastBottomY)
|
val animator = it.animate()?.translationY(lastBottomY)
|
||||||
?.setDuration(shortAnimationDuration.toLong())
|
?.setDuration(shortAnimationDuration.toLong())
|
||||||
animator?.setUpdateListener {
|
animator?.setUpdateListener {
|
||||||
onBottomNavUpdate?.invoke()
|
updateViewsNearBottom()
|
||||||
}
|
}
|
||||||
animator?.start()
|
animator?.start()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (recycler.canScrollVertically(-1) && !elevate) elevateFunc(true)
|
if (recycler.canScrollVertically(-1) && !elevate) elevateFunc(true)
|
||||||
else if (!recycler.canScrollVertically(-1) && elevate) elevateFunc(false)
|
else if (!recycler.canScrollVertically(-1) && elevate) elevateFunc(false)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user