ui: fix broken toolbar anims
This commit is contained in:
parent
9a01fe471e
commit
15121d28f6
3 changed files with 6 additions and 4 deletions
|
|
@ -63,7 +63,7 @@ class AnimatedMaterialButton : RippleFixMaterialButton {
|
||||||
animator?.cancel()
|
animator?.cancel()
|
||||||
animator =
|
animator =
|
||||||
anim
|
anim
|
||||||
.genericFloat(currentCornerRadiusRatio, targetRadius, ::updateCornerRadiusRatio)
|
.genericFloat(currentCornerRadiusRatio, targetRadius, 0, ::updateCornerRadiusRatio)
|
||||||
.also { it.start() }
|
.also { it.start() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,13 @@ data class Anim(val interpolator: TimeInterpolator, val duration: Long) {
|
||||||
inline fun genericFloat(
|
inline fun genericFloat(
|
||||||
from: Float,
|
from: Float,
|
||||||
to: Float,
|
to: Float,
|
||||||
|
delayMs: Long = 0,
|
||||||
crossinline update: (Float) -> Unit
|
crossinline update: (Float) -> Unit
|
||||||
): ValueAnimator =
|
): ValueAnimator =
|
||||||
ValueAnimator.ofFloat(from, to).apply {
|
ValueAnimator.ofFloat(from, to).apply {
|
||||||
duration = duration
|
startDelay = delayMs
|
||||||
interpolator = interpolator
|
duration = this@Anim.duration
|
||||||
|
interpolator = this@Anim.interpolator
|
||||||
addUpdateListener { update(animatedValue as Float) }
|
addUpdateListener { update(animatedValue as Float) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val inAnimator =
|
val inAnimator =
|
||||||
inAnim.genericFloat(toView.alpha, 1f) {
|
inAnim.genericFloat(toView.alpha, 1f, outAnim.duration) {
|
||||||
toView.apply {
|
toView.apply {
|
||||||
scaleX = 1 - 0.05f * (1 - it)
|
scaleX = 1 - 0.05f * (1 - it)
|
||||||
scaleY = 1 - 0.05f * (1 - it)
|
scaleY = 1 - 0.05f * (1 - it)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue