Skip to content

Instantly share code, notes, and snippets.

@fvilarino
Created March 5, 2023 00:30
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/de016cde9788be3e61f3a1f82744e8d5 to your computer and use it in GitHub Desktop.
Save fvilarino/de016cde9788be3e61f3a1f82744e8d5 to your computer and use it in GitHub Desktop.
Ticker - Ticker Board
@Composable
fun TickerBoard(
// 1
text: String,
// 2
numColumns: Int,
// 3
numRows: Int,
modifier: Modifier = Modifier,
textColor: Color = Color.White,
backgroundColor: Color = Color.Black,
fontSize: TextUnit = 96.sp,
horizontalArrangement: Arrangement.Horizontal = Arrangement.spacedBy(8.dp),
verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(8.dp),
) {
// 4
val padded = text.padEnd(numColumns * numRows, ' ')
// 5
Column(
modifier = modifier,
verticalArrangement = verticalArrangement,
) {
// 6
repeat(numRows) { row ->
TickerRow(
text = padded.substring(startIndex = row * numColumns),
numCells = numColumns,
horizontalArrangement = horizontalArrangement,
textColor = textColor,
backgroundColor = backgroundColor,
fontSize = fontSize,
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment