iamthevoid
05/31/2021, 9:37 AMcurrentPage
and currentPageOffset
values. What is the best way in compose to blend colors one with another for current case? It is not an animation, colors must change on drag (recompose), so somehow i must change color based on currentPage
and currentPageOffset
. Would be the good solution is changing the alpha? Or i can somehow blend colors?color.compositeOver(color2)
cb
05/31/2021, 10:16 AMiamthevoid
05/31/2021, 10:19 AMval currentPage = pagerState.currentPage
val nexPage = if (pagerState.currentPageOffset < 0) currentPage - 1 else currentPage + 1
val absoluteOffset = min(abs(pagerState.currentPageOffset), 1f)
….
.background(
when (index) {
currentPage -> activeColor
.copy(alpha = 1f - absoluteOffset)
.compositeOver(inactiveColor)
nexPage -> activeColor
.copy(alpha = absoluteOffset)
.compositeOver(inactiveColor)
else -> inactiveColor
}, shape = RoundedCornerShape(50)
)