Skip to content

Instantly share code, notes, and snippets.

@fvilarino
Created December 4, 2022 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fvilarino/28aee727e645df6657a7ad4fc255525e to your computer and use it in GitHub Desktop.
Save fvilarino/28aee727e645df6657a7ad4fc255525e to your computer and use it in GitHub Desktop.
Segmented Progress - Usage Sample
var runForwards by remember { mutableStateOf(false) }
val progress: Float by animateFloatAsState(
if (runForwards) 1f else 0f,
animationSpec = tween(
durationMillis = 10_000,
easing = LinearEasing
)
)
Surface(color = MaterialTheme.colors.background) {
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally
) {
SegmentedProgressIndicator(
progress = progress,
modifier = Modifier
.padding(top = 64.dp, start = 32.dp, end = 32.dp)
.fillMaxWidth(),
)
Button(
onClick = { runForwards = !runForwards },
modifier = Modifier.padding(top = 32.dp)
) {
Text(
text = if (runForwards) "Reverse Animation" else "Forward Animation"
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment