Skip to content

Instantly share code, notes, and snippets.

@fvilarino
Created March 4, 2023 23:53
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/beb7ade5ad31bb0470adb59487cde491 to your computer and use it in GitHub Desktop.
Save fvilarino/beb7ade5ad31bb0470adb59487cde491 to your computer and use it in GitHub Desktop.
Ticker - Basic Layout
@Composable
fun Ticker(
letter: Char,
modifier: Modifier = Modifier,
textColor: Color = Color.White,
backgroundColor: Color = Color.Black,
fontSize: TextUnit = 96.sp,
) {
// 1
val currentLetter = /* TODO */
val nextLetter = /* TODO */
// 2
Box(
modifier = modifier
) {
// 3
CenteredText(
letter = nextLetter,
textColor = textColor,
backgroundColor = backgroundColor,
fontSize = fontSize,
)
// 4
Column {
// 5
Box(
// 6
modifier = Modifier.zIndex(1f)
) {
// 7
if (/* 1/2 half of animation */ ) {
TopHalf {
CenteredText(
letter = currentLetter,
textColor = textColor,
backgroundColor = backgroundColor,
fontSize = fontSize,
)
}
} else {
BottomHalf(
modifier = Modifier.graphicsLayer {
rotationX = 180f
}
) {
CenteredText(
letter = nextLetter,
textColor = textColor,
backgroundColor = backgroundColor,
fontSize = fontSize,
)
}
}
}
// 8
BottomHalf {
CenteredText(
letter = currentLetter,
textColor = textColor,
backgroundColor = backgroundColor,
fontSize = fontSize,
)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment