diff --git a/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt index 527608aa0..a7aba1aa6 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/ExtensionsScreen.kt @@ -58,6 +58,7 @@ import eu.kanade.tachiyomi.util.system.LocaleHelper fun ExtensionScreen( state: ExtensionsState, contentPadding: PaddingValues, + searchQuery: String? = null, onLongClickItem: (Extension) -> Unit, onClickItemCancel: (Extension) -> Unit, onInstallExtension: (Extension.Available) -> Unit, @@ -75,10 +76,17 @@ fun ExtensionScreen( ) { when { state.isLoading -> LoadingScreen(modifier = Modifier.padding(contentPadding)) - state.isEmpty -> EmptyScreen( - textResource = R.string.empty_screen, - modifier = Modifier.padding(contentPadding), - ) + state.isEmpty -> { + val msg = if (!searchQuery.isNullOrEmpty()) { + R.string.no_results_found + } else { + R.string.empty_screen + } + EmptyScreen( + textResource = msg, + modifier = Modifier.padding(contentPadding), + ) + } else -> { ExtensionContent( state = state, diff --git a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt index 17ac024c9..0bb873bc8 100644 --- a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt @@ -58,8 +58,13 @@ fun HistoryScreen( if (it == null) { LoadingScreen(modifier = Modifier.padding(contentPadding)) } else if (it.isEmpty()) { + val msg = if (!state.searchQuery.isNullOrEmpty()) { + R.string.no_results_found + } else { + R.string.information_no_recent_manga + } EmptyScreen( - textResource = R.string.information_no_recent_manga, + textResource = msg, modifier = Modifier.padding(contentPadding), ) } else { diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LibraryContent.kt b/app/src/main/java/eu/kanade/presentation/library/components/LibraryContent.kt index 62d7b6857..a5d80d6a7 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LibraryContent.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/LibraryContent.kt @@ -32,6 +32,7 @@ fun LibraryContent( selection: List, contentPadding: PaddingValues, currentPage: () -> Int, + hasActiveFilters: Boolean, showPageTabs: Boolean, onChangeCurrentPage: (Int) -> Unit, onMangaClicked: (Long) -> Unit, @@ -97,6 +98,7 @@ fun LibraryContent( state = pagerState, contentPadding = PaddingValues(bottom = contentPadding.calculateBottomPadding()), pageCount = categories.size, + hasActiveFilters = hasActiveFilters, selectedManga = selection, searchQuery = searchQuery, onGlobalSearchClicked = onGlobalSearchClicked, diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LibraryPager.kt b/app/src/main/java/eu/kanade/presentation/library/components/LibraryPager.kt index 7c5be66ac..6fec3b4ad 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LibraryPager.kt +++ b/app/src/main/java/eu/kanade/presentation/library/components/LibraryPager.kt @@ -3,6 +3,7 @@ package eu.kanade.presentation.library.components import android.content.res.Configuration import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -13,8 +14,10 @@ import androidx.compose.ui.platform.LocalConfiguration import eu.kanade.core.prefs.PreferenceMutableState import eu.kanade.domain.library.model.LibraryDisplayMode import eu.kanade.domain.library.model.LibraryManga +import eu.kanade.presentation.components.EmptyScreen import eu.kanade.presentation.components.HorizontalPager import eu.kanade.presentation.components.PagerState +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.library.LibraryItem @Composable @@ -22,6 +25,7 @@ fun LibraryPager( state: PagerState, contentPadding: PaddingValues, pageCount: Int, + hasActiveFilters: Boolean, selectedManga: List, searchQuery: String?, onGlobalSearchClicked: () -> Unit, @@ -43,6 +47,12 @@ fun LibraryPager( return@HorizontalPager } val library = getLibraryForPage(page) + + if (library.isEmpty()) { + LibraryPagerEmptyScreen(searchQuery, hasActiveFilters, contentPadding) + return@HorizontalPager + } + val displayMode = getDisplayModeForPage(page) val columns by if (displayMode != LibraryDisplayMode.List) { val configuration = LocalConfiguration.current @@ -96,3 +106,21 @@ fun LibraryPager( } } } + +@Composable +private fun LibraryPagerEmptyScreen( + searchQuery: String?, + hasActiveFilters: Boolean, + contentPadding: PaddingValues, +) { + val msg = when { + !searchQuery.isNullOrEmpty() -> R.string.no_results_found + hasActiveFilters -> R.string.error_no_match + else -> R.string.information_no_manga_category + } + + EmptyScreen( + textResource = msg, + modifier = Modifier.padding(contentPadding), + ) +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsTab.kt index 7c98756a7..358eb114e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsTab.kt @@ -21,6 +21,7 @@ fun extensionsTab( ): TabContent { val navigator = LocalNavigator.currentOrThrow val state by extensionsScreenModel.state.collectAsState() + val searchQuery by extensionsScreenModel.query.collectAsState() return TabContent( titleRes = R.string.label_extensions, @@ -37,6 +38,7 @@ fun extensionsTab( ExtensionScreen( state = state, contentPadding = contentPadding, + searchQuery = searchQuery, onLongClickItem = { extension -> when (extension) { is Extension.Available -> extensionsScreenModel.installExtension(extension) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt index 02f12ecd3..27f2ccc3e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt @@ -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? { return library.firstNotNullOfOrNull { (k, v) -> v.takeIf { k.id == categoryId } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt index 78e38915a..b7c37c9bb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt @@ -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)) }, diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index 5f926ae22..19dd016c1 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -870,6 +870,7 @@ No recent updates Nothing read recently Your library is empty + Category is empty No entries found in this category Getting started guide You have no categories. Tap the plus button to create one for organizing your library.