Skip to content

team2681/SwiftSpinProgress

Repository files navigation

🌀 SwiftSpinProgress

A lightweight, customizable iOS-style circular progress indicator for Android built with Jetpack Compose.

Maven Central License Stars


✨ Overview

SwiftSpinProgress is a modern, Jetpack Compose–based loading indicator inspired by iOS spinners.
It offers smooth animations, easy customization, and a clean Material look — perfect for any Android app.


🎨 Features

  • 🧩 Composable-first — plug directly into your Compose UI
  • Lightweight — minimal setup and no external dependencies
  • 💫 Smooth animations with adjustable duration
  • 🎨 Fully customizable colors, shapes, and item counts
  • 🌗 Dark/Light mode ready

Library Dependency

The swiftspinprogress library is published on Maven Central.

Requirements

Kotlin AGP Min SDK

Add this dependency to your module-level build.gradle file:

dependencies {
    implementation("io.github.team2681:swiftspinprogress:1.0.0")
}

Using Version Catalog (libs.versions.toml)

  • Add this in your libs.versions.toml:
  [versions]
  swiftspinprogress = "1.0.0"

  [libraries]
  swiftspinprogressview = { group = "io.github.team2681", name = "swiftspinprogress", version.ref = "swiftspinprogress" }
  • Then in your module build.gradle.kts:

    dependencies {
         implementation(libs.swiftspinprogressview)
    }
    
  • Make sure mavenCentral() is included in your repositories:

    repositories {
         google()
         mavenCentral()
    }
    

🖼️ Preview

Light State Dark State
Light Dark

🖼️ Gif-Preview

Light State Dark State
Light Dark

Usage

  1. Clone this repo:

    git https://github.com/team2681/SwiftSpinProgress.git
  2. Open in Android Studio.

  3. Run on your device or emulator.

Usage Example

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SwiftSpinDemoScreen() {
    var showProgress by remember { mutableStateOf(false) }

    Scaffold(
        topBar = {
            TopAppBar(title = { Text("SwiftSpin Progress") })
        }
    ) { padding ->
        Box(
            modifier = Modifier
                .fillMaxSize()
                .padding(padding)
        ) {
            // Button at bottom center
            Box(
                modifier = Modifier
                    .fillMaxSize()
                    .padding(bottom = 24.dp),
                contentAlignment = Alignment.BottomCenter
            ) {
                Button(onClick = { showProgress = true }) {
                    Text("Show Progress")
                }
            }

            // SwiftSpin progress indicator
            SwiftSpinProgressView(
                isVisible = showProgress,
                spinnerBackgroundColor = MaterialTheme.colorScheme.surface,
                staticItemColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.4f),
                dynamicItemColor = MaterialTheme.colorScheme.primary
            )

            // Auto-hide after 4 seconds
            LaunchedEffect(showProgress) {
                if (showProgress) {
                    delay(4000)
                    showProgress = false
                }
            }
        }
    }
}

Parameters

Parameter Type Default Description
modifier Modifier Modifier Used to modify the layout or behavior of the progress view. Commonly used to add padding, size, or alignment.
isVisible Boolean Controls the visibility of the progress view. When true, the spinner is shown; when false, it’s hidden.
staticItemCount Int 8 Defines the total number of static items (spokes) in the spinner. Increasing this creates a denser spinner.
dynamicItemCount Int staticItemCount / 2 Defines how many of the spinner items are active (animated).
spinnerBackgroundColor Color Color.Transparent Background color of the spinner’s inner area. Typically kept transparent.
staticItemColor Color StaticItemColor Color of the non-animated (static) spinner items.
dynamicItemColor Color DynamicItemColor Color of the animated spinner items that rotate.
spinnerShape SwiftSpinShape SwiftSpinShape.RoundedRect Defines the shape of spinner items (e.g., RoundedRect, Circle).
durationMillis Int 1500 Duration of one full spinner animation cycle, in milliseconds.
backgroundOverlayColor Color Color.Black.copy(alpha = 0.3f) Semi-transparent overlay color shown behind the spinner (used to dim background).
cornerRadius Dp 12.dp Corner radius of the spinner’s card container. Controls roundness.
spinnerContainerSize Dp 100.dp Size of the spinner container card (width and height).
spinnerCardElevation Dp 4.dp Elevation (shadow depth) of the spinner card for visual depth.

WhatsApp Channel

Get Kotlin & Android Jetpack Compose tips on What's App Join My Channel : 📚 Kotlin & Android Learning📚

License

License

This project is licensed under the Apache License 2.0.

See the full license here.