SpinwheelCompose

SpinWheel in Android using Jetpack Compose.

How it looks

Usage

val textList by remember { 
    mutableStateOf(
        listOf("Pie 1", "Pie 2", "Pie 3", "Pie 4", "Pie 5", "Pie 6", "Pie 7", "Pie 8")
    )
}
DefaultSpinWheel(isSpinning = true){ pieIndex ->
    Text(text = textList[pieIndex])
}

Setup

  1. Open the file settings.gradle (it looks like that)

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        // add jitpack here ??
        maven { url 'https://jitpack.io' }
       ...
    }
} 
...
  1. Sync the project
  2. Add dependency

dependencies {
        implementation 'com.github.commandiron:SpinWheelCompose:1.0.3'
}

Features

val iconList by remember {
    mutableStateOf(
        listOf(
            Icons.Default.Star,
            Icons.Default.Star,
            Icons.Default.Star,
            Icons.Default.Star,
        )
    )
}
var isSpinning by remember { mutableStateOf(false)}
repeat(3){
    DefaultSpinWheel(
        dimensions = SpinWheelDefaults.spinWheelDimensions(
            spinWheelSize = 180.dp,
            frameWidth = 20.dp,
            selectorWidth = 10.dp
        ),
        colors = SpinWheelDefaults.spinWheelColors(
            frameColor = Color(0xFF403d39),
            dividerColor = Color(0xFFfffcf2),
            selectorColor = Color(0xFFdc0073),
            pieColors = listOf(
                Color(0xFFdabfff),
                Color(0xFF907ad6),
                Color(0xFF4f518c),
                Color(0xFF2c2a4a)
            )
        ),
        animationAttr = SpinWheelDefaults.spinWheelAnimationAttr(
            pieCount = 4,
            durationMillis = 4000,
            delayMillis = 200,
            rotationPerSecond = 2f,
            easing = LinearOutSlowInEasing,
            startDegree = 90f
        ),
        isSpinning = isSpinning,
        onClick = { isSpinning = !isSpinning },
        onFinish = { isSpinning = false }
    ){ pieIndex ->
        Icon(
            imageVector = iconList[pieIndex],
            tint = Color.White,
            contentDescription = null
        )
    }
    Spacer(modifier = Modifier.height(32.dp))
}

GitHub

View Github