Skip to content

Instantly share code, notes, and snippets.

@KatieBarnett
Last active May 9, 2023 11:07
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 KatieBarnett/44b8a98e8f8886bc10dee602ab104375 to your computer and use it in GitHub Desktop.
Save KatieBarnett/44b8a98e8f8886bc10dee602ab104375 to your computer and use it in GitHub Desktop.
TextWithColorConfigProvider - Static colors
class TextWithColorConfigProvider : PreviewParameterProvider<TextConfig> {
override val values: Sequence<TextConfig> = sequenceOf(
TextConfig(color = Color.Red, text = "Primary text"),
TextConfig(color = Color.Blue, text = "Secondary text")
)
}
@Preview
@Composable
fun TextColoredComponentPreview(
@PreviewParameter(TextWithColorConfigProvider::class) data: TextConfig
) {
MaterialTheme {
Text(data.text, color = data.color)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment