I'm trying to implement a disabled state for a custom component in compose. The disabled state involves having the entire component set to grayscale with an alpha of 0.8f. I tried drawing a rect on top of the component content with BlendMode.Saturation like so;
Surface(
modifier = modifier.then(Modifier.drawWithCache {
onDrawWithContent {
drawContent()
drawRect(backgroundColor, blendMode = BlendMode.Saturation)
}
}.graphicsLayer { alpha = 0.8f }
While this works perfectly fine, the only issue is BlendMode.Saturation is supported API 29 and above. How can I achieve the same behavior on API<29?