hide Pinned chip in Global/Migrate Search if no pinned sources available
This commit is contained in:
parent
6bb8535af4
commit
8895015388
8 changed files with 44 additions and 15 deletions
|
|
@ -39,6 +39,7 @@ fun GlobalSearchScreen(
|
|||
onLongClickItem: (Manga) -> Unit,
|
||||
// KMK -->
|
||||
bulkFavoriteScreenModel: BulkFavoriteScreenModel,
|
||||
hasPinnedSources: Boolean,
|
||||
// KMK <--
|
||||
) {
|
||||
// KMK -->
|
||||
|
|
@ -91,6 +92,7 @@ fun GlobalSearchScreen(
|
|||
// KMK -->
|
||||
toggleSelectionMode = bulkFavoriteScreenModel::toggleSelectionMode,
|
||||
isRunning = bulkFavoriteState.isRunning,
|
||||
hasPinnedSources = hasPinnedSources,
|
||||
// KMK <--
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ fun MigrateSearchScreen(
|
|||
onLongClickItem: (Manga) -> Unit,
|
||||
// KMK -->
|
||||
bulkFavoriteScreenModel: BulkFavoriteScreenModel,
|
||||
hasPinnedSources: Boolean,
|
||||
// KMK <--
|
||||
) {
|
||||
// KMK -->
|
||||
|
|
@ -81,6 +82,7 @@ fun MigrateSearchScreen(
|
|||
// KMK -->
|
||||
toggleSelectionMode = bulkFavoriteScreenModel::toggleSelectionMode,
|
||||
isRunning = bulkFavoriteState.isRunning,
|
||||
hasPinnedSources = hasPinnedSources,
|
||||
// KMK <--
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ fun GlobalSearchToolbar(
|
|||
// KMK -->
|
||||
toggleSelectionMode: () -> Unit,
|
||||
isRunning: Boolean,
|
||||
hasPinnedSources: Boolean,
|
||||
// KMK <--
|
||||
) {
|
||||
Column(modifier = Modifier.background(MaterialTheme.colorScheme.surface)) {
|
||||
|
|
@ -89,6 +90,9 @@ fun GlobalSearchToolbar(
|
|||
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
||||
) {
|
||||
// TODO: make this UX better; it only applies when triggering a new search
|
||||
// KMK -->
|
||||
if (hasPinnedSources) {
|
||||
// KMK <--
|
||||
FilterChip(
|
||||
selected = sourceFilter == SourceFilter.PinnedOnly,
|
||||
onClick = { onChangeSearchFilter(SourceFilter.PinnedOnly) },
|
||||
|
|
@ -104,6 +108,7 @@ fun GlobalSearchToolbar(
|
|||
Text(text = stringResource(MR.strings.pinned_sources))
|
||||
},
|
||||
)
|
||||
}
|
||||
FilterChip(
|
||||
selected = sourceFilter == SourceFilter.All,
|
||||
onClick = { onChangeSearchFilter(SourceFilter.All) },
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ class MigrateSearchScreen(private val mangaId: Long, private val validSources: L
|
|||
onLongClickItem = { navigator.push(MangaScreen(it.id, true)) },
|
||||
// KMK -->
|
||||
bulkFavoriteScreenModel = bulkFavoriteScreenModel,
|
||||
hasPinnedSources = screenModel.hasPinnedSources(),
|
||||
// KMK <--
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@ class MigrateSearchScreenModel(
|
|||
}
|
||||
search()
|
||||
}
|
||||
|
||||
// KMK -->
|
||||
shouldPinnedSourcesHidden()
|
||||
// KMK <--
|
||||
}
|
||||
|
||||
override fun getEnabledSources(): List<CatalogueSource> {
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ class GlobalSearchScreen(
|
|||
},
|
||||
// KMK -->
|
||||
bulkFavoriteScreenModel = bulkFavoriteScreenModel,
|
||||
hasPinnedSources = screenModel.hasPinnedSources(),
|
||||
// KMK <--
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@ class GlobalSearchScreenModel(
|
|||
}
|
||||
search()
|
||||
}
|
||||
|
||||
// KMK -->
|
||||
shouldPinnedSourcesHidden()
|
||||
// KMK <--
|
||||
}
|
||||
|
||||
override fun getEnabledSources(): List<CatalogueSource> {
|
||||
|
|
|
|||
|
|
@ -101,6 +101,16 @@ abstract class SearchScreenModel(
|
|||
)
|
||||
}
|
||||
|
||||
// KMK -->
|
||||
fun hasPinnedSources(): Boolean = getEnabledSources().any { "${it.id}" in pinnedSources }
|
||||
|
||||
fun shouldPinnedSourcesHidden() {
|
||||
if (!hasPinnedSources()) {
|
||||
preferences.globalSearchPinnedState().set(SourceFilter.All)
|
||||
}
|
||||
}
|
||||
// KMK <--
|
||||
|
||||
private fun getSelectedSources(): List<CatalogueSource> {
|
||||
val enabledSources = getEnabledSources()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue