A Jetpack Compose countdown timer library that allows you to easily add a customizable countdown timer to your Android app.
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.raipankaj:countdowntimer:1.0.2'
}
CountDownTimer(
actionList = listOf(
Action(45.seconds.inWholeMilliseconds, "Inhale"),
Action(30.seconds.inWholeMilliseconds, "Exhale"),
Action(45.seconds.inWholeMilliseconds, "Inhale"),
Action(30.seconds.inWholeMilliseconds, "Exhale"),
Action(45.seconds.inWholeMilliseconds, "Inhale"),
Action(30.seconds.inWholeMilliseconds, "Exhale"),
),
dialerSize = 240.dp,
dialerBackgroundColor = MaterialTheme.colorScheme.primary,
dialerProgressColor = Color.White,
dialerBorderColor = MaterialTheme.colorScheme.tertiary,
onTimerExpired = {
}
)
This creates a CountDownTimer instance with the following settings:
@Composable
fun ExerciseTimer() {
CountDownTimer(
actionList = listOf(
Action(45.seconds.inWholeMilliseconds, "Inhale"),
Action(30.seconds.inWholeMilliseconds, "Exhale"),
Action(45.seconds.inWholeMilliseconds, "Inhale"),
Action(30.seconds.inWholeMilliseconds, "Exhale"),
Action(45.seconds.inWholeMilliseconds, "Inhale"),
Action(30.seconds.inWholeMilliseconds, "Exhale"),
),
dialerSize = 240.dp,
dialerBackgroundColor = MaterialTheme.colorScheme.primary,
dialerProgressColor = Color.White,
dialerBorderColor = MaterialTheme.colorScheme.tertiary,
onTimerExpired = {
}
)
}
Action with two duration - 10 seconds, inhale and 10 seconds, exhale