Hey, everyone, is there a way to draw shadow with x, y, spread, blur and color? I just find a api *`...
w
Hey, everyone, is there a way to draw shadow with x, y, spread, blur and color? I just find a api
Modifier.shadow
, but it don't have enough parameters.
Copy code
fun Modifier.shadow(
    elevation: Dp,
    shape: Shape = RectangleShape,
    clip: Boolean = elevation > 0.dp,
    ambientColor: Color = DefaultShadowColor,
    spotColor: Color = DefaultShadowColor,
)
The image is Figma config.
j
Yes do it with your own modifier. We have our own drop shadow modifier.
❤️ 1
w
@Joel Denke Thank you! Could you please share a post or repository or code snippet with me?
s
Unfortunately the Compose
shadow
Modifier is in reality just an implementation of Material elevation, not regular box-shadow. You'll need to use a custom Modifier for that. Here's an implementation that works on Android: https://github.com/GIGAMOLE/ComposeShadowsPlus/. The developer doesn't seem to be interested in supporting KMP for now, but it shouldn't be too hard to implement this on other platforms.
❤️ 1
j
@wwalkingg This helped me a lot: https://stackoverflow.com/a/76979309 It also solves how drawing inner and multiplr shadows as well.
❤️ 1