From 66545dfcf647f78dbdad8bd4cebc98d77ea9f0d2 Mon Sep 17 00:00:00 2001 From: T8RIN Date: Thu, 25 Apr 2024 11:33:47 +0300 Subject: [PATCH] shadows improved --- .../core/ui/widget/modifier/MaterialShadow.kt | 58 +++++++++++-------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/modifier/MaterialShadow.kt b/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/modifier/MaterialShadow.kt index b96c452eee..2ee9875d58 100644 --- a/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/modifier/MaterialShadow.kt +++ b/core/ui/src/main/kotlin/ru/tech/imageresizershrinker/core/ui/widget/modifier/MaterialShadow.kt @@ -56,30 +56,38 @@ fun Modifier.materialShadow( } val elev = animateDpAsState(if (enabled) elevation else 0.dp).value - val api29Shadow = if (isClipped) { - Modifier.clippedShadow( - shape = shape, - elevation = elev, - ambientColor = color, - spotColor = color - ) - } else { - Modifier.shadow( - shape = shape, - elevation = elev, - ambientColor = color, - spotColor = color - ) - } + if (elev > 0.dp) { + when { + isConcavePath && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q -> { + val api21Shadow = Modifier.rsBlurShadow( + shape = shape, + radius = elev, + isAlphaContentClip = isClipped, + color = color + ) - val api21shadow = Modifier.rsBlurShadow( - shape = shape, - radius = elev, - isAlphaContentClip = isClipped, - color = color - ) - when { - isConcavePath && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q -> api21shadow - else -> api29Shadow - } + api21Shadow + } + + else -> { + val api29Shadow = if (isClipped) { + Modifier.clippedShadow( + shape = shape, + elevation = elev, + ambientColor = color, + spotColor = color + ) + } else { + Modifier.shadow( + shape = shape, + elevation = elev, + ambientColor = color, + spotColor = color + ) + } + + api29Shadow + } + } + } else Modifier } \ No newline at end of file