Last active
January 26, 2025 17:06
-
-
Save igorescodro/879a55f260a5c11afa805d6e7518cf2a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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