Show empty screen when a category is empty (#8690)
* Show empty screen when a category is empty * Review changes * Review changes #2 Co-authored-by: arkon <arkon@users.noreply.github.com>
This commit is contained in:
@@ -742,17 +742,19 @@ class LibraryScreenModel(
|
||||
val showMangaContinueButton: Boolean = false,
|
||||
val dialog: Dialog? = null,
|
||||
) {
|
||||
val selectionMode = selection.isNotEmpty()
|
||||
|
||||
val categories = library.keys.toList()
|
||||
|
||||
val libraryCount by lazy {
|
||||
private val libraryCount by lazy {
|
||||
library.values
|
||||
.flatten()
|
||||
.fastDistinctBy { it.libraryManga.manga.id }
|
||||
.size
|
||||
}
|
||||
|
||||
val isLibraryEmpty by lazy { libraryCount == 0 }
|
||||
|
||||
val selectionMode = selection.isNotEmpty()
|
||||
|
||||
val categories = library.keys.toList()
|
||||
|
||||
fun getLibraryItemsByCategoryId(categoryId: Long): List<LibraryItem>? {
|
||||
return library.firstNotNullOfOrNull { (k, v) -> v.takeIf { k.id == categoryId } }
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ object LibraryTab : Tab {
|
||||
) { contentPadding ->
|
||||
when {
|
||||
state.isLoading -> LoadingScreen(modifier = Modifier.padding(contentPadding))
|
||||
state.searchQuery.isNullOrEmpty() && !state.hasActiveFilters && state.libraryCount == 0 -> {
|
||||
state.searchQuery.isNullOrEmpty() && !state.hasActiveFilters && state.isLibraryEmpty -> {
|
||||
val handler = LocalUriHandler.current
|
||||
EmptyScreen(
|
||||
textResource = R.string.information_empty_library,
|
||||
@@ -170,6 +170,7 @@ object LibraryTab : Tab {
|
||||
selection = state.selection,
|
||||
contentPadding = contentPadding,
|
||||
currentPage = { screenModel.activeCategoryIndex },
|
||||
hasActiveFilters = state.hasActiveFilters,
|
||||
showPageTabs = state.showCategoryTabs || !state.searchQuery.isNullOrEmpty(),
|
||||
onChangeCurrentPage = { screenModel.activeCategoryIndex = it },
|
||||
onMangaClicked = { navigator.push(MangaScreen(it)) },
|
||||
|
||||
Reference in New Issue
Block a user