Skip to content

Commit c59b4b4

Browse files
committed
fix: stage management
1 parent e22d4ca commit c59b4b4

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

app/src/main/java/to/bitkit/ui/components/GradientCircularProgressIndicator.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import androidx.compose.animation.core.tween
88
import androidx.compose.foundation.Canvas
99
import androidx.compose.runtime.Composable
1010
import androidx.compose.runtime.getValue
11+
import androidx.compose.runtime.remember
1112
import androidx.compose.ui.Modifier
1213
import androidx.compose.ui.graphics.Brush
1314
import androidx.compose.ui.graphics.Color
1415
import androidx.compose.ui.graphics.StrokeCap
1516
import androidx.compose.ui.graphics.drawscope.Stroke
1617
import androidx.compose.ui.graphics.graphicsLayer
18+
import androidx.compose.ui.platform.LocalDensity
1719
import androidx.compose.ui.unit.Dp
1820
import androidx.compose.ui.unit.dp
1921
import 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

Comments
 (0)