Fix pressing back while bottom bar is hidden

This commit is contained in:
Jays2Kings 2021-03-26 13:00:27 -04:00
parent 0c41a3cd96
commit 5e2cad868d
2 changed files with 6 additions and 4 deletions

View File

@ -274,7 +274,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
) { ) {
syncActivityViewWithController(to, from, isPush) syncActivityViewWithController(to, from, isPush)
appbar.y = 0f appbar.y = 0f
if (!isPush) { if (!isPush || router.backstackSize == 1) {
bottom_nav.translationY = 0f bottom_nav.translationY = 0f
} }
snackBar?.dismiss() snackBar?.dismiss()

View File

@ -156,6 +156,7 @@ fun Controller.scrollViewWith(
} }
var elevationAnim: ValueAnimator? = null var elevationAnim: ValueAnimator? = null
var elevate = false var elevate = false
var isInView = true
val elevateFunc: (Boolean) -> Unit = { el -> val elevateFunc: (Boolean) -> Unit = { el ->
elevate = el elevate = el
if (liftOnScroll != null) { if (liftOnScroll != null) {
@ -180,6 +181,7 @@ fun Controller.scrollViewWith(
changeType: ControllerChangeType changeType: ControllerChangeType
) { ) {
super.onChangeStart(controller, changeHandler, changeType) super.onChangeStart(controller, changeHandler, changeType)
isInView = changeType.isEnter
if (changeType.isEnter) { if (changeType.isEnter) {
elevateFunc(elevate) elevateFunc(elevate)
if (fakeToolbarView?.parent != null) { if (fakeToolbarView?.parent != null) {
@ -253,7 +255,7 @@ 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) { if (router.backstackSize == 1 && isInView) {
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())
@ -273,7 +275,7 @@ fun Controller.scrollViewWith(
0f 0f
) )
val tabBar = activity!!.bottom_nav val tabBar = activity!!.bottom_nav
if (tabBar != null && tabBar.isVisible()) { if (tabBar != null && tabBar.isVisible() && isInView) {
val preferences: PreferencesHelper = Injekt.get() val preferences: PreferencesHelper = Injekt.get()
if (preferences.hideBottomNavOnScroll().get()) { if (preferences.hideBottomNavOnScroll().get()) {
tabBar.translationY += dy tabBar.translationY += dy
@ -322,7 +324,7 @@ fun Controller.scrollViewWith(
val closerToEdge = if (activity!!.bottom_nav.isVisible) closerToBottom else closerToTop val closerToEdge = if (activity!!.bottom_nav.isVisible) closerToBottom else closerToTop
lastY = if (closerToEdge && !atTop) (-activity!!.appbar.height.toFloat()) else 0f 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) { if (activity!!.bottom_nav.isVisible && isInView) {
activity!!.bottom_nav?.let { activity!!.bottom_nav?.let {
val lastBottomY = if (closerToEdge && !atTop) it.height.toFloat() else 0f val lastBottomY = if (closerToEdge && !atTop) it.height.toFloat() else 0f
val animator = it.animate()?.translationY(lastBottomY) val animator = it.animate()?.translationY(lastBottomY)