ui: fix broken toolbar anims

This commit is contained in:
Alexander Capehart 2024-10-18 16:19:22 -06:00
parent 9a01fe471e
commit 15121d28f6
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
3 changed files with 6 additions and 4 deletions

View file

@ -63,7 +63,7 @@ class AnimatedMaterialButton : RippleFixMaterialButton {
animator?.cancel()
animator =
anim
.genericFloat(currentCornerRadiusRatio, targetRadius, ::updateCornerRadiusRatio)
.genericFloat(currentCornerRadiusRatio, targetRadius, 0, ::updateCornerRadiusRatio)
.also { it.start() }
}

View file

@ -29,11 +29,13 @@ data class Anim(val interpolator: TimeInterpolator, val duration: Long) {
inline fun genericFloat(
from: Float,
to: Float,
delayMs: Long = 0,
crossinline update: (Float) -> Unit
): ValueAnimator =
ValueAnimator.ofFloat(from, to).apply {
duration = duration
interpolator = interpolator
startDelay = delayMs
duration = this@Anim.duration
interpolator = this@Anim.interpolator
addUpdateListener { update(animatedValue as Float) }
}
}

View file

@ -96,7 +96,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
}
}
val inAnimator =
inAnim.genericFloat(toView.alpha, 1f) {
inAnim.genericFloat(toView.alpha, 1f, outAnim.duration) {
toView.apply {
scaleX = 1 - 0.05f * (1 - it)
scaleY = 1 - 0.05f * (1 - it)