mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 16:45:06 +01:00
Improvements for transitioning to a new screen from a root controlelr
This commit is contained in:
parent
dd88dbfa29
commit
0bb399979f
@ -262,7 +262,9 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
|||||||
) {
|
) {
|
||||||
syncActivityViewWithController(to, from, isPush)
|
syncActivityViewWithController(to, from, isPush)
|
||||||
appbar.y = 0f
|
appbar.y = 0f
|
||||||
|
if (!isPush) {
|
||||||
bottom_nav.translationY = 0f
|
bottom_nav.translationY = 0f
|
||||||
|
}
|
||||||
snackBar?.dismiss()
|
snackBar?.dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,11 +4,13 @@ import android.animation.ValueAnimator
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
|
import android.view.Gravity
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
import android.view.WindowInsets
|
import android.view.WindowInsets
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
|
import android.widget.FrameLayout
|
||||||
import androidx.appcompat.widget.SearchView
|
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
|
||||||
@ -127,6 +129,7 @@ fun Controller.scrollViewWith(
|
|||||||
val randomTag = Random.nextLong()
|
val randomTag = Random.nextLong()
|
||||||
var lastY = 0f
|
var lastY = 0f
|
||||||
var fakeToolbarView: View? = null
|
var fakeToolbarView: View? = null
|
||||||
|
var fakeBottomNavView: View? = null
|
||||||
if (!customPadding) {
|
if (!customPadding) {
|
||||||
recycler.updatePaddingRelative(
|
recycler.updatePaddingRelative(
|
||||||
top = activity!!.toolbar.y.toInt() + appBarHeight
|
top = activity!!.toolbar.y.toInt() + appBarHeight
|
||||||
@ -179,6 +182,11 @@ fun Controller.scrollViewWith(
|
|||||||
parent.removeView(fakeToolbarView)
|
parent.removeView(fakeToolbarView)
|
||||||
fakeToolbarView = null
|
fakeToolbarView = null
|
||||||
}
|
}
|
||||||
|
if (fakeBottomNavView?.parent != null) {
|
||||||
|
val parent = fakeBottomNavView?.parent as? ViewGroup ?: return
|
||||||
|
parent.removeView(fakeBottomNavView)
|
||||||
|
fakeBottomNavView = null
|
||||||
|
}
|
||||||
lastY = 0f
|
lastY = 0f
|
||||||
activity!!.toolbar.tag = randomTag
|
activity!!.toolbar.tag = randomTag
|
||||||
activity!!.toolbar.setOnClickListener {
|
activity!!.toolbar.setOnClickListener {
|
||||||
@ -203,6 +211,20 @@ fun Controller.scrollViewWith(
|
|||||||
v.layoutParams = params
|
v.layoutParams = params
|
||||||
onLeavingController?.invoke()
|
onLeavingController?.invoke()
|
||||||
}
|
}
|
||||||
|
if (!customPadding && router.backstackSize == 2) {
|
||||||
|
val parent = recycler.parent as? ViewGroup ?: return
|
||||||
|
val bottomNav = activity!!.bottom_nav ?: return
|
||||||
|
val v = View(activity)
|
||||||
|
fakeBottomNavView = v
|
||||||
|
parent.addView(v, parent.indexOfChild(recycler) + 1)
|
||||||
|
val params = fakeBottomNavView?.layoutParams
|
||||||
|
params?.height = recycler.paddingBottom
|
||||||
|
(params as? FrameLayout.LayoutParams)?.gravity = Gravity.BOTTOM
|
||||||
|
fakeBottomNavView?.translationY = bottomNav.translationY
|
||||||
|
params?.width = MATCH_PARENT
|
||||||
|
v.setBackgroundColor(v.context.getResourceColor(R.attr.colorPrimaryVariant))
|
||||||
|
v.layoutParams = params
|
||||||
|
}
|
||||||
elevationAnim?.cancel()
|
elevationAnim?.cancel()
|
||||||
if (activity!!.toolbar.tag == randomTag) activity!!.toolbar.setOnClickListener(null)
|
if (activity!!.toolbar.tag == randomTag) activity!!.toolbar.setOnClickListener(null)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user