diff --git a/app/src/main/java/eu/kanade/presentation/browse/GlobalSearchScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/GlobalSearchScreen.kt index f033b17b9..5d240471a 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/GlobalSearchScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/GlobalSearchScreen.kt @@ -14,6 +14,7 @@ import eu.kanade.presentation.browse.components.GlobalSearchErrorResultItem import eu.kanade.presentation.browse.components.GlobalSearchLoadingResultItem import eu.kanade.presentation.browse.components.GlobalSearchResultItem import eu.kanade.presentation.browse.components.GlobalSearchToolbar +import eu.kanade.presentation.components.EmptyScreen import eu.kanade.presentation.components.LazyColumn import eu.kanade.presentation.components.Scaffold import eu.kanade.presentation.util.padding @@ -49,6 +50,7 @@ fun GlobalSearchScreen( ) { paddingValues -> GlobalSearchContent( items = state.items, + isPinnedOnly = state.isPinnedOnly, contentPadding = paddingValues, getManga = getManga, onClickSource = onClickSource, @@ -61,12 +63,20 @@ fun GlobalSearchScreen( @Composable fun GlobalSearchContent( items: Map, + isPinnedOnly: Boolean, contentPadding: PaddingValues, getManga: @Composable (CatalogueSource, Manga) -> State, onClickSource: (CatalogueSource) -> Unit, onClickItem: (Manga) -> Unit, onLongClickItem: (Manga) -> Unit, ) { + if (items.isEmpty() && isPinnedOnly) { + EmptyScreen( + message = stringResource(R.string.no_pinned_sources), + ) + return + } + LazyColumn( contentPadding = contentPadding, ) { diff --git a/app/src/main/java/eu/kanade/presentation/browse/MigrateSearchScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/MigrateSearchScreen.kt index c370480c8..069594e93 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/MigrateSearchScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/MigrateSearchScreen.kt @@ -3,6 +3,7 @@ package eu.kanade.presentation.browse import androidx.compose.foundation.layout.PaddingValues import androidx.compose.runtime.Composable import androidx.compose.runtime.State +import androidx.compose.ui.res.stringResource import eu.kanade.domain.manga.model.Manga import eu.kanade.presentation.browse.components.GlobalSearchCardRow import eu.kanade.presentation.browse.components.GlobalSearchEmptyResultItem @@ -10,8 +11,10 @@ import eu.kanade.presentation.browse.components.GlobalSearchErrorResultItem import eu.kanade.presentation.browse.components.GlobalSearchLoadingResultItem import eu.kanade.presentation.browse.components.GlobalSearchResultItem import eu.kanade.presentation.browse.components.GlobalSearchToolbar +import eu.kanade.presentation.components.EmptyScreen import eu.kanade.presentation.components.LazyColumn import eu.kanade.presentation.components.Scaffold +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.ui.browse.migration.search.MigrateSearchState import eu.kanade.tachiyomi.ui.browse.source.globalsearch.SearchItemResult @@ -44,6 +47,7 @@ fun MigrateSearchScreen( MigrateSearchContent( sourceId = state.manga?.source ?: -1, items = state.items, + isPinnedOnly = state.isPinnedOnly, contentPadding = paddingValues, getManga = getManga, onClickSource = onClickSource, @@ -57,12 +61,20 @@ fun MigrateSearchScreen( fun MigrateSearchContent( sourceId: Long, items: Map, + isPinnedOnly: Boolean, contentPadding: PaddingValues, getManga: @Composable (CatalogueSource, Manga) -> State, onClickSource: (CatalogueSource) -> Unit, onClickItem: (Manga) -> Unit, onLongClickItem: (Manga) -> Unit, ) { + if (items.isEmpty() && isPinnedOnly) { + EmptyScreen( + message = stringResource(R.string.no_pinned_sources), + ) + return + } + LazyColumn( contentPadding = contentPadding, ) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreenModel.kt index 30b0dc28b..c9339c5a3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/MigrateSearchScreenModel.kt @@ -22,7 +22,11 @@ class MigrateSearchScreenModel( private val sourcePreferences: SourcePreferences = Injekt.get(), private val sourceManager: SourceManager = Injekt.get(), private val getManga: GetManga = Injekt.get(), -) : SearchScreenModel(MigrateSearchState()) { +) : SearchScreenModel( + MigrateSearchState( + isPinnedOnly = sourcePreferences.searchPinnedSourcesOnly().get(), + ), +) { init { extensionFilter = initialExtensionFilter @@ -84,6 +88,7 @@ data class MigrateSearchState( val manga: Manga? = null, val searchQuery: String? = null, val items: Map = emptyMap(), + val isPinnedOnly: Boolean, val dialog: MigrateSearchDialog? = null, ) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchScreenModel.kt index 6049965f1..590b405ab 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchScreenModel.kt @@ -15,7 +15,12 @@ class GlobalSearchScreenModel( preferences: BasePreferences = Injekt.get(), private val sourcePreferences: SourcePreferences = Injekt.get(), private val sourceManager: SourceManager = Injekt.get(), -) : SearchScreenModel(GlobalSearchState(searchQuery = initialQuery)) { +) : SearchScreenModel( + GlobalSearchState( + searchQuery = initialQuery, + isPinnedOnly = sourcePreferences.searchPinnedSourcesOnly().get(), + ), +) { val incognitoMode = preferences.incognitoMode() val lastUsedSourceId = sourcePreferences.lastUsedSource() @@ -59,6 +64,7 @@ class GlobalSearchScreenModel( data class GlobalSearchState( val searchQuery: String? = null, val items: Map = emptyMap(), + val isPinnedOnly: Boolean, ) { val progress: Int = items.count { it.value !is SearchItemResult.Loading }