Skip to content

Instantly share code, notes, and snippets.

@igorescodro
Last active January 26, 2025 17:06
Show Gist options
  • Save igorescodro/879a55f260a5c11afa805d6e7518cf2a to your computer and use it in GitHub Desktop.
Save igorescodro/879a55f260a5c11afa805d6e7518cf2a to your computer and use it in GitHub Desktop.
// [...] Composable screen code
when (state) {
MainState.Loading -> {
ItemCard(
item = fakeData,
isLoading = true,
)
}
is MainState.Success -> {
ItemCard(
item = state.itemData,
isLoading = false,
)
}
}
// Fake data to be used while loading and in the preview
private val fakeData = ItemData(
imageResId = android.R.drawable.ic_dialog_info,
title = LoremIpsum(4).values.toList().first(),
description = LoremIpsum(8).values.toList().first(),
)
@PreviewLightDark
@Composable
fun ItemDataPreview() {
ExampleTheme {
ItemCard(item = fakeData)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment