@@ -28,7 +28,6 @@ import androidx.compose.ui.graphics.Shape
2828import androidx.compose.ui.graphics.drawscope.clipPath
2929import androidx.compose.ui.graphics.graphicsLayer
3030import androidx.compose.ui.input.pointer.pointerInput
31- import androidx.compose.ui.platform.LocalDensity
3231import androidx.compose.ui.unit.Dp
3332import androidx.compose.ui.unit.dp
3433import to.bitkit.ui.theme.Colors
@@ -101,41 +100,39 @@ fun Modifier.innerShadow(
101100 color : Color ,
102101 blurRadius : Dp = 4.dp,
103102 shape : Shape ,
104- ): Modifier = composed {
105- val density = LocalDensity .current
106- val blurRadiusPx = with (density) { blurRadius.toPx() }
103+ ): Modifier = this .drawWithContent {
104+ // Draw content first (gradient, etc)
105+ drawContent()
107106
108- this .drawWithContent {
109- // Draw content first (gradient, etc)
110- drawContent()
107+ // Convert blur radius to pixels using DrawScope's density
108+ val blurRadiusPx = blurRadius.toPx()
111109
112- // Get shape outline for clipping
113- val outline = shape.createOutline(size, layoutDirection, density )
110+ // Get shape outline for clipping
111+ val outline = shape.createOutline(size, layoutDirection, this )
114112
115- // Convert outline to path
116- val path = when (outline) {
117- is Outline .Rectangle -> Path ().apply { addRect(outline.rect) }
118- is Outline .Rounded -> Path ().apply { addRoundRect(outline.roundRect) }
119- is Outline .Generic -> outline.path
120- }
113+ // Convert outline to path
114+ val path = when (outline) {
115+ is Outline .Rectangle -> Path ().apply { addRect(outline.rect) }
116+ is Outline .Rounded -> Path ().apply { addRoundRect(outline.roundRect) }
117+ is Outline .Generic -> outline.path
118+ }
121119
122- // Clip to shape and draw top edge highlight with soft gradient
123- clipPath(path) {
124- drawRect(
125- brush = Brush .verticalGradient(
126- colors = listOf (
127- color,
128- color.copy(alpha = color.alpha * 0.7f ),
129- color.copy(alpha = color.alpha * 0.3f ),
130- Color .Transparent
131- ),
132- startY = 0f ,
133- endY = blurRadiusPx * 2.5f
120+ // Clip to shape and draw top edge highlight with soft gradient
121+ clipPath(path) {
122+ drawRect(
123+ brush = Brush .verticalGradient(
124+ colors = listOf (
125+ color,
126+ color.copy(alpha = color.alpha * 0.7f ),
127+ color.copy(alpha = color.alpha * 0.3f ),
128+ Color .Transparent
134129 ),
135- topLeft = Offset (0f , 0f ),
136- size = Size (size.width, blurRadiusPx * 2.5f )
137- )
138- }
130+ startY = 0f ,
131+ endY = blurRadiusPx * 2.5f
132+ ),
133+ topLeft = Offset (0f , 0f ),
134+ size = Size (size.width, blurRadiusPx * 2.5f )
135+ )
139136 }
140137}
141138
0 commit comments