Created
September 10, 2021 22:42
-
-
Save josefdolezal/5583dec554e4341cbf39ddc133010545 to your computer and use it in GitHub Desktop.
Loader
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
@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) | |
} | |
} |
Author
josefdolezal
commented
Sep 10, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment