Giter Club home page Giter Club logo

spinwheelcompose's Introduction

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")
    )
}

val state = rememberSpinWheelState()
val scope = rememberCoroutineScope()

SpinWheel(
    state = state,
    onClick = { scope.launch { state.animate {pieIndex -> } } }
){ 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.1.1'
}

Features

val iconList by remember {
    mutableStateOf(
        listOf(
            Icons.Default.Star,
            Icons.Default.Star,
            Icons.Default.Star,
            Icons.Default.Star,
        )
    )
}
repeat(3){
    SpinWheel(
        state = rememberSpinWheelState(
            pieCount = 4,
            durationMillis = 20000,
            delayMillis = 200,
            rotationPerSecond = 2f,
            easing = LinearOutSlowInEasing,
            startDegree = 90f,
            resultDegree = 212f,
            autoSpinDelay = 0
        ),
        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)
            )
        )
    ){ pieIndex ->
        Icon(
            imageVector = iconList[pieIndex],
            tint = Color.White,
            contentDescription = null
        )
    }
    Spacer(modifier = Modifier.height(32.dp))
}

spinwheelcompose's People

Contributors

commandiron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

spinwheelcompose's Issues

Default values

I think some of the default behaviour is not obvious without looking through the code:

  • When not providing resultDegree, the spin should be random
  • When not providing autoResetDelay, the spinner should not reset.

Licenses?

Hi commandiron,

I was wondering if you have any licenses file for this project?

Was not sure how to get to you, so leaving it as an issue.

Result of the spin

Hello , how could I get the result of the spin into a variable to use in a pie counter?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.