fun Color.Companion.blend(
color1: Color,
color2: Color,
progress: Float
): Color{
val r1 = color1.red
val g1 = color1.green
val b1 = color1.blue

val r2 = color2.red
val g2 = color2.green
val b2 = color2.blue

val p = progress
val q = 1f - progress
return Color(
red = q*r1 + p*r2,
green = q*g1 + p*g2,
blue = q*b1 + p*b2,
)
}

--

--

The Code

fun Modifier.clickable(
rippleColor: Color,
rippleRadius: Dp = Dp.Unspecified,
enabled: Boolean = true,
onClickLabel: String? = null,
role: Role? = null,
onClick: () -> Unit
) = composed(
factory = {
val interactionSource = remember { MutableInteractionSource() }
Modifier
.clickable(
interactionSource = interactionSource,
indication = rememberRipple(
color = rippleColor,
radius = rippleRadius,
),
enabled = enabled,
onClickLabel = onClickLabel,
role = role,
onClick = onClick
)
}
)

Usage

Icon(
painter = painterResource(id = R.drawable.my_icon),
contentDescription = "my_content_desc",
tint = Color.Unspecified,
modifier = Modifier
.size(26.dep())
.clip(CircleShape)
.clickable(
rippleColor = Color.Red//lovely
) {
//I am clicked
}
)

--

--

Often we need fading edge effect mostly in lists.

So, I made one.

Enjoy fading edge.

fun Modifier.fadingEdge(
startingColor: Color = Color.White,
endingColor: Color = Color.Transparent,
length: Float = 60f,
horizontal: Boolean = false,
starting1Color…

--

--