Add: Loading indicator for vertical lists

This commit is contained in:
machiav3lli 2022-07-06 02:43:24 +02:00
parent ce1cfeb79a
commit c9637fa647
2 changed files with 15 additions and 7 deletions

View File

@ -101,13 +101,20 @@ fun <T> VerticalItemList(
.background(backgroundColor), .background(backgroundColor),
contentAlignment = if (list.isNullOrEmpty()) Alignment.Center else Alignment.TopStart contentAlignment = if (list.isNullOrEmpty()) Alignment.Center else Alignment.TopStart
) { ) {
if (!list.isNullOrEmpty()) { when {
list == null -> Text(
text = stringResource(id = R.string.loading_list),
color = MaterialTheme.colorScheme.onBackground
)
!list.isNullOrEmpty() -> {
LazyColumn(verticalArrangement = spacedBy(4.dp)) { LazyColumn(verticalArrangement = spacedBy(4.dp)) {
items(items = list, key = itemKey, itemContent = itemContent) items(items = list, key = itemKey, itemContent = itemContent)
} }
} else Text( }
else -> Text(
text = stringResource(id = R.string.no_applications_available), text = stringResource(id = R.string.no_applications_available),
color = MaterialTheme.colorScheme.onBackground color = MaterialTheme.colorScheme.onBackground
) )
} }
}
} }

View File

@ -204,4 +204,5 @@
<string name="favorite_remove">Remove from favorites</string> <string name="favorite_remove">Remove from favorites</string>
<string name="favorite_add">Add to favorites</string> <string name="favorite_add">Add to favorites</string>
<string name="open">Open</string> <string name="open">Open</string>
<string name="loading_list">Loading list…</string>
</resources> </resources>