Udi Oshi
01/01/2023, 5:54 PM@Composable
fun Shadow.simpleDropShadow(color: Color? = null, offset: Offset?, blurRadius: Float?) = Shadow(
color = color ?: colorResource(id = R.color.black_75),
offset = offset ?: Offset(x = 2f, y = 4f),
blurRadius = blurRadius ?: 0.1f
)
But no luck when trying to use in at all.
Appreciate your assitance 🙏Kirill Grouchnikov
01/01/2023, 8:16 PMandrew
01/02/2023, 1:32 AMfun Modifier.coloredShadow(
color: Color,
shape: Shape,
alpha: Float = 0.2F,
shadowRadius: Dp = 0.dp,
offsetY: Dp = 0.dp,
offsetX: Dp = 0.dp,
) = coloredShadow(color, shape, alpha, shadowRadius, DpOffset(offsetX, offsetY))
fun Modifier.coloredShadow(
color: Color,
shape: Shape,
alpha: Float = 0.2F,
shadowRadius: Dp = 0.dp,
offset: DpOffset = DpOffset(0.dp, 0.dp),
) = composed {
val density = LocalDensity.current
val shadowColor = remember(color, alpha) { color.copy(alpha).toArgb() }
val paint = remember(shadowRadius, offset.x, offset.y, shadowColor, density) { Paint().apply {
val frameworkPaint = asFrameworkPaint()
with(density) {
frameworkPaint.color = Color.Transparent.toArgb()
frameworkPaint.setShadowLayer(
shadowRadius.toPx(),
offset.x.toPx(),
offset.y.toPx(),
shadowColor
)
}
}}
drawBehind {
drawIntoCanvas {
it.drawOutline(
shape.createOutline(size, layoutDirection, this),
paint
)
}
}
}
Chris Sinco [G]
01/09/2023, 10:06 PMandrew
01/09/2023, 10:07 PMromainguy
01/09/2023, 10:08 PMandrew
01/09/2023, 10:09 PMromainguy
01/09/2023, 10:09 PMandrew
01/09/2023, 10:11 PMNader Jawad
01/09/2023, 10:35 PM