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
Joel Denke
07/21/2024, 8:07 AM
Yes do it with your own modifier. We have our own drop shadow modifier.
❤️ 1
w
wwalkingg
07/21/2024, 9:33 AM
@Joel Denke Thank you! Could you please share a post or repository or code snippet with me?
s
Skaldebane
07/21/2024, 9:53 AM
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.