@@ -24,6 +24,9 @@ import androidx.compose.ui.unit.Dp
2424import androidx.compose.ui.unit.dp
2525import top.yukonga.miuix.kmp.basic.ProgressIndicatorDefaults.ProgressIndicatorColors
2626import top.yukonga.miuix.kmp.theme.MiuixTheme
27+ import kotlin.math.PI
28+ import kotlin.math.cos
29+ import kotlin.math.sin
2730
2831/* *
2932 * A [LinearProgressIndicator] with Miuix style.
@@ -260,6 +263,62 @@ fun CircularProgressIndicator(
260263 }
261264}
262265
266+ /* *
267+ * A [InfiniteProgressIndicator] with Miuix style.
268+ * The indicator is a circular indicator with an orbiting dot.
269+ *
270+ * @param modifier The modifier to be applied to the indicator.
271+ * @param color The color of the indicator.
272+ * @param size The size (diameter) of the circular indicator.
273+ * @param strokeWidth The width of the circular stroke.
274+ * @param orbitingDotSize The size of the orbiting dot.
275+ */
276+ @Composable
277+ fun InfiniteProgressIndicator (
278+ modifier : Modifier = Modifier ,
279+ color : Color = Color .Gray ,
280+ size : Dp = ProgressIndicatorDefaults .DefaultInfiniteProgressIndicatorSize ,
281+ strokeWidth : Dp = ProgressIndicatorDefaults .DefaultInfiniteProgressIndicatorStrokeWidth ,
282+ orbitingDotSize : Dp = ProgressIndicatorDefaults .DefaultInfiniteProgressIndicatorOrbitingDotSize
283+ ) {
284+ val rotationAnim = remember { Animatable (0f ) }
285+
286+ LaunchedEffect (Unit ) {
287+ rotationAnim.animateTo(
288+ targetValue = 360f ,
289+ animationSpec = infiniteRepeatable(
290+ animation = tween(800 , easing = LinearEasing ),
291+ repeatMode = RepeatMode .Restart
292+ )
293+ )
294+ }
295+
296+ Canvas (modifier = modifier.size(size)) {
297+ val center = Offset (this .size.width / 2 , this .size.height / 2 )
298+ val radius = (size.toPx() - strokeWidth.toPx()) / 2
299+
300+ drawCircle(
301+ color = color,
302+ radius = radius,
303+ center = center,
304+ style = Stroke (strokeWidth.toPx(), cap = StrokeCap .Round )
305+ )
306+
307+ val orbitRadius = radius - 2 * orbitingDotSize.toPx()
308+ val angle = rotationAnim.value * PI .toFloat() / 180f
309+ val dotCenter = center + Offset (
310+ x = orbitRadius * cos(angle),
311+ y = orbitRadius * sin(angle)
312+ )
313+
314+ drawCircle(
315+ color = color,
316+ radius = orbitingDotSize.toPx(),
317+ center = dotCenter
318+ )
319+ }
320+ }
321+
263322object ProgressIndicatorDefaults {
264323 /* * The default height of [LinearProgressIndicator]. */
265324 val DefaultLinearProgressIndicatorHeight = 6 .dp
@@ -270,8 +329,17 @@ object ProgressIndicatorDefaults {
270329 /* * The default size of [CircularProgressIndicator]. */
271330 val DefaultCircularProgressIndicatorSize = 36 .dp
272331
332+ /* * The default stroke width of [InfiniteProgressIndicator]. */
333+ val DefaultInfiniteProgressIndicatorStrokeWidth = 2 .dp
334+
335+ /* * The default radius width of the orbiting dot in [InfiniteProgressIndicator]. */
336+ val DefaultInfiniteProgressIndicatorOrbitingDotSize = 2 .dp
337+
338+ /* * The default size of [InfiniteProgressIndicator]. */
339+ val DefaultInfiniteProgressIndicatorSize = 20 .dp
340+
273341 /* *
274- * The default [ProgressIndicatorColors] used in [LinearProgressIndicator].
342+ * The default [ProgressIndicatorColors] used by [LinearProgressIndicator] and [CircularProgressIndicator ].
275343 */
276344 @Composable
277345 fun progressIndicatorColors (
0 commit comments