More improvements on the pop controller animation

also a slight faster push animation too
This commit is contained in:
Jays2Kings 2023-10-19 23:21:13 -07:00
parent 473ee9f709
commit de0f57e86f
3 changed files with 31 additions and 28 deletions

View file

@ -533,13 +533,19 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
from?.view?.let { view ->
bA.addUpdateListener {
binding.backShadow.x = view.x - binding.backShadow.width
if (router.backstackSize == 1) {
to?.view?.let { toView ->
nav.x = toView.x
}
}
}
}
bA.doOnEnd {
binding.backShadow.alpha = 0.25f
binding.backShadow.isVisible = false
nav.x = 0f
}
bA.duration = 150
bA.duration = 175
bA.start()
}
if (!isPush || router.backstackSize == 1) {
@ -1339,8 +1345,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
?: View.GONE
}
}
alphaAnimation.duration = 200
alphaAnimation.startDelay = 50
alphaAnimation.duration = 150
animationSet?.playTogether(alphaAnimation)
animationSet?.start()
}

View file

@ -21,8 +21,6 @@ import androidx.core.view.updatePaddingRelative
import androidx.recyclerview.widget.RecyclerView
import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.ControllerChangeType
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.snackbar.Snackbar
import eu.davidea.flexibleadapter.FlexibleAdapter
@ -355,12 +353,7 @@ class BrowseController :
when (item.itemId) {
// Initialize option to open catalogue settings.
R.id.action_filter -> {
val controller = ExtensionFilterController()
router.pushController(
RouterTransaction.with(controller)
.popChangeHandler(FadeChangeHandler())
.pushChangeHandler(FadeChangeHandler()),
)
router.pushController(ExtensionFilterController().withFadeTransaction())
}
R.id.action_migration_guide -> {
activity?.openInBrowser(HELP_URL)
@ -697,12 +690,7 @@ class BrowseController :
when (item.itemId) {
// Initialize option to open catalogue settings.
R.id.action_filter -> {
val controller = SettingsSourcesController()
router.pushController(
RouterTransaction.with(controller)
.popChangeHandler(FadeChangeHandler())
.pushChangeHandler(FadeChangeHandler()),
)
router.pushController(SettingsSourcesController().withFadeTransaction())
}
R.id.action_migration_guide -> {
activity?.openInBrowser(HELP_URL)

View file

@ -373,6 +373,26 @@ fun Controller.scrollViewWith(
}
addLifecycleListener(
object : Controller.LifecycleListener() {
override fun onChangeEnd(
controller: Controller,
changeHandler: ControllerChangeHandler,
changeType: ControllerChangeType,
) {
super.onChangeEnd(controller, changeHandler, changeType)
if (changeType.isEnter) {
if (fakeToolbarView?.parent != null) {
val parent = fakeToolbarView?.parent as? ViewGroup ?: return
parent.removeView(fakeToolbarView)
fakeToolbarView = null
}
if (fakeBottomNavView?.parent != null) {
val parent = fakeBottomNavView?.parent as? ViewGroup ?: return
parent.removeView(fakeBottomNavView)
fakeBottomNavView = null
}
}
}
override fun onChangeStart(
controller: Controller,
changeHandler: ControllerChangeHandler,
@ -388,16 +408,6 @@ fun Controller.scrollViewWith(
activityBinding?.appBar?.setToolbarModeBy(this@scrollViewWith)
activityBinding?.appBar?.useTabsInPreLayout = includeTabView
colorToolbar(isToolbarColor)
if (fakeToolbarView?.parent != null) {
val parent = fakeToolbarView?.parent as? ViewGroup ?: return
parent.removeView(fakeToolbarView)
fakeToolbarView = null
}
if (fakeBottomNavView?.parent != null) {
val parent = fakeBottomNavView?.parent as? ViewGroup ?: return
parent.removeView(fakeBottomNavView)
fakeBottomNavView = null
}
lastY = 0f
activityBinding?.appBar?.updateAppBarAfterY(recycler)
activityBinding?.toolbar?.tag = randomTag
@ -802,7 +812,7 @@ fun Controller.withFadeTransaction(): RouterTransaction {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
FadeChangeHandler()
} else {
CrossFadeChangeHandler(duration = 250, removesFromViewOnPush = isLowRam)
CrossFadeChangeHandler(duration = 200, removesFromViewOnPush = isLowRam)
},
)
.popChangeHandler(