Skip to content

Instantly share code, notes, and snippets.

@widiarifki
Last active August 31, 2021 01:23
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 widiarifki/13bfa81f4678071de3298b6fac3b79a1 to your computer and use it in GitHub Desktop.
Save widiarifki/13bfa81f4678071de3298b6fac3b79a1 to your computer and use it in GitHub Desktop.
@Composable
fun ShoppingListScreen(
isLoading: Boolean,
shoppingItems: List<ShoppingItem>,
onAddItem: (ShoppingItem) -> Unit,
onToggleTickItem: (ShoppingItem) -> Unit,
onDeleteItem: (ShoppingItem) -> Unit
) {
// Content Container
Column(modifier = Modifier.fillMaxHeight()) {
val expandHeight = Modifier.weight(1f)
when {
isLoading -> {
LoadingIndicator(expandHeight)
}
!isLoading && shoppingItems.isEmpty() -> {
EmptyState(expandHeight)
}
!isLoading && shoppingItems.isNotEmpty() -> {
ShoppingList(
shoppingItems = shoppingItems,
onToggleTickItem = onToggleTickItem,
onDeleteItem = onDeleteItem,
modifier = expandHeight
)
}
}
if (!isLoading) FormInputContainer(onAddItem)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment