@@ -8,12 +8,14 @@ import androidx.compose.animation.core.tween
88import androidx.compose.foundation.Canvas
99import androidx.compose.runtime.Composable
1010import androidx.compose.runtime.getValue
11+ import androidx.compose.runtime.remember
1112import androidx.compose.ui.Modifier
1213import androidx.compose.ui.graphics.Brush
1314import androidx.compose.ui.graphics.Color
1415import androidx.compose.ui.graphics.StrokeCap
1516import androidx.compose.ui.graphics.drawscope.Stroke
1617import androidx.compose.ui.graphics.graphicsLayer
18+ import androidx.compose.ui.platform.LocalDensity
1719import androidx.compose.ui.unit.Dp
1820import androidx.compose.ui.unit.dp
1921import to.bitkit.ui.theme.Colors
@@ -28,23 +30,24 @@ fun GradientCircularProgressIndicator(
2830 initialValue = 0f ,
2931 targetValue = 360f ,
3032 animationSpec = infiniteRepeatable(
31- animation = tween(durationMillis = 1100 , easing = LinearEasing )
33+ animation = tween(durationMillis = 2000 , easing = LinearEasing )
3234 ),
3335 label = " rotation"
3436 )
3537
38+ val brush = remember { Brush .sweepGradient(listOf (Color .Transparent , Colors .White )) }
39+ val strokeWidthPx = with (LocalDensity .current) { strokeWidth.toPx() }
40+ val stroke = remember(strokeWidthPx) { Stroke (width = strokeWidthPx, cap = StrokeCap .Round ) }
41+
3642 Canvas (
3743 modifier = modifier.graphicsLayer { rotationZ = angle }
3844 ) {
39- val strokeWidthPx = strokeWidth.toPx()
4045 drawArc(
41- brush = Brush .sweepGradient(
42- colors = listOf (Color .Transparent , Colors .White )
43- ),
46+ brush = brush,
4447 startAngle = 0f ,
4548 sweepAngle = 360f ,
4649 useCenter = false ,
47- style = Stroke (width = strokeWidthPx, cap = StrokeCap . Round )
50+ style = stroke
4851 )
4952 }
5053}
0 commit comments