Skip to content

Instantly share code, notes, and snippets.

@josefdolezal
Created September 10, 2021 22:42
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 josefdolezal/5583dec554e4341cbf39ddc133010545 to your computer and use it in GitHub Desktop.
Save josefdolezal/5583dec554e4341cbf39ddc133010545 to your computer and use it in GitHub Desktop.
Loader
@Composable
fun Loader(isLoading: Boolean) {
Column(Modifier.fillMaxSize()) {
Column(modifier = Modifier
.fillMaxWidth()
.weight(1f), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center) {
val transition = rememberInfiniteTransition()
val rotation by transition.animateFloat(
initialValue = 0f,
targetValue = 360f,
animationSpec = infiniteRepeatable(
animation = tween(800, easing = LinearEasing)
)
)
Box(
Modifier
.rotate(rotation)
.background(Color.Red)
.size(40.dp))
}
// Should stick to bottom when loading, otherwise center itself in empty space
Crossfade(targetState = isLoading) {
Text(if (it) "Loading" else "Done")
}
// Should "stick" to bottom
Text(modifier = Modifier
.background(Color.Blue)
.fillMaxWidth()
.padding(), text = "Footer placeholder", textAlign = TextAlign.Center)
}
}
@josefdolezal
Copy link
Author

Loader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment