Created
December 4, 2022 01:26
-
-
Save fvilarino/28aee727e645df6657a7ad4fc255525e to your computer and use it in GitHub Desktop.
Segmented Progress - Usage Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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