Skip to content

Commit

Permalink
feat: search entry's title in library (#158)
Browse files Browse the repository at this point in the history
* feat: add library title search

* do library search only, won't do source search
  • Loading branch information
cuong-tran authored Jul 7, 2024
1 parent 241c6ff commit 271aa16
Show file tree
Hide file tree
Showing 25 changed files with 92 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fun SourcesScreen(
listState = lazyListState,
searchQuery = state.searchQuery,
onChangeSearchQuery = onChangeSearchQuery,
placeholderText = stringResource(KMR.strings.action_source_search),
placeholderText = stringResource(KMR.strings.action_search_for_source),
)

FastScrollLazyColumn(
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ fun MangaScreen(
onRelatedMangasScreenClick: () -> Unit,
onRelatedMangaClick: (Manga) -> Unit,
onRelatedMangaLongClick: (Manga) -> Unit,
librarySearch: (query: String) -> Unit,
onSourceClick: () -> Unit,
onCoverLoaded: (MangaCover) -> Unit,
onPaletteScreenClick: () -> Unit,
Expand Down Expand Up @@ -255,6 +256,7 @@ fun MangaScreen(
onRelatedMangasScreenClick = onRelatedMangasScreenClick,
onRelatedMangaClick = onRelatedMangaClick,
onRelatedMangaLongClick = onRelatedMangaLongClick,
librarySearch = librarySearch,
onSourceClick = onSourceClick,
onCoverLoaded = onCoverLoaded,
onPaletteScreenClick = onPaletteScreenClick,
Expand Down Expand Up @@ -311,6 +313,7 @@ fun MangaScreen(
onRelatedMangasScreenClick = onRelatedMangasScreenClick,
onRelatedMangaClick = onRelatedMangaClick,
onRelatedMangaLongClick = onRelatedMangaLongClick,
librarySearch = librarySearch,
onSourceClick = onSourceClick,
onCoverLoaded = onCoverLoaded,
onPaletteScreenClick = onPaletteScreenClick,
Expand Down Expand Up @@ -384,6 +387,7 @@ private fun MangaScreenSmallImpl(
onRelatedMangasScreenClick: () -> Unit,
onRelatedMangaClick: (Manga) -> Unit,
onRelatedMangaLongClick: (Manga) -> Unit,
librarySearch: (query: String) -> Unit,
onSourceClick: () -> Unit,
onCoverLoaded: (MangaCover) -> Unit,
onPaletteScreenClick: () -> Unit,
Expand Down Expand Up @@ -556,6 +560,7 @@ private fun MangaScreenSmallImpl(
onCoverClick = onCoverClicked,
doSearch = onSearch,
// KMK -->
librarySearch = librarySearch,
onSourceClick = onSourceClick,
onCoverLoaded = onCoverLoaded,
// KMK <--
Expand Down Expand Up @@ -790,6 +795,7 @@ private fun MangaScreenLargeImpl(
onRelatedMangasScreenClick: () -> Unit,
onRelatedMangaClick: (Manga) -> Unit,
onRelatedMangaLongClick: (Manga) -> Unit,
librarySearch: (query: String) -> Unit,
onSourceClick: () -> Unit,
onCoverLoaded: (MangaCover) -> Unit,
onPaletteScreenClick: () -> Unit,
Expand Down Expand Up @@ -954,6 +960,7 @@ private fun MangaScreenLargeImpl(
onCoverClick = onCoverClicked,
doSearch = onSearch,
// KMK -->
librarySearch = librarySearch,
onSourceClick = onSourceClick,
onCoverLoaded = onCoverLoaded,
// KMK <--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.util.system.copyToClipboard
import tachiyomi.domain.manga.model.Manga
import tachiyomi.i18n.MR
import tachiyomi.i18n.kmk.KMR
import tachiyomi.i18n.sy.SYMR
import tachiyomi.presentation.core.components.material.TextButton
import tachiyomi.presentation.core.components.material.padding
Expand Down Expand Up @@ -111,6 +112,7 @@ fun MangaInfoBox(
doSearch: (query: String, global: Boolean) -> Unit,
modifier: Modifier = Modifier,
// KMK -->
librarySearch: (query: String) -> Unit,
onSourceClick: () -> Unit,
onCoverLoaded: (DomainMangaCover) -> Unit,
// KMK <--
Expand All @@ -134,7 +136,7 @@ fun MangaInfoBox(
colors = backdropGradientColors,
// KMK -->
startY = size.height / 2,
// KMKM <--
// KMK <--
),
)
}
Expand All @@ -161,6 +163,7 @@ fun MangaInfoBox(
sourceName = sourceName,
isStubSource = isStubSource,
// KMK -->
librarySearch = librarySearch,
onSourceClick = onSourceClick,
onCoverLoaded = onCoverLoaded,
// KMK <--
Expand All @@ -178,6 +181,7 @@ fun MangaInfoBox(
sourceName = sourceName,
isStubSource = isStubSource,
// KMK -->
librarySearch = librarySearch,
onSourceClick = onSourceClick,
onCoverLoaded = onCoverLoaded,
// KMK <--
Expand Down Expand Up @@ -429,6 +433,7 @@ private fun MangaAndSourceTitlesLarge(
sourceName: String,
isStubSource: Boolean,
// KMK -->
librarySearch: (query: String) -> Unit,
onSourceClick: () -> Unit,
onCoverLoaded: (DomainMangaCover) -> Unit,
// KMK <--
Expand Down Expand Up @@ -459,6 +464,7 @@ private fun MangaAndSourceTitlesLarge(
isStubSource = isStubSource,
textAlign = TextAlign.Center,
// KMK -->
librarySearch = librarySearch,
onSourceClick = onSourceClick,
// KMK <--
)
Expand All @@ -478,6 +484,7 @@ private fun MangaAndSourceTitlesSmall(
sourceName: String,
isStubSource: Boolean,
// KMK -->
librarySearch: (query: String) -> Unit,
onSourceClick: () -> Unit,
onCoverLoaded: (DomainMangaCover) -> Unit,
// KMK <--
Expand Down Expand Up @@ -512,13 +519,15 @@ private fun MangaAndSourceTitlesSmall(
sourceName = sourceName,
isStubSource = isStubSource,
// KMK -->
librarySearch = librarySearch,
onSourceClick = onSourceClick,
// KMK <--
)
}
}
}

@Suppress("UnusedReceiverParameter")
@Composable
private fun ColumnScope.MangaContentInfo(
title: String,
Expand All @@ -530,20 +539,52 @@ private fun ColumnScope.MangaContentInfo(
isStubSource: Boolean,
textAlign: TextAlign? = LocalTextStyle.current.textAlign,
// KMK -->
librarySearch: (query: String) -> Unit,
onSourceClick: () -> Unit,
// KMK <--
) {
val context = LocalContext.current
// KMK -->
var showMenu by remember { mutableStateOf(false) }
DropdownMenu(
expanded = showMenu,
onDismissRequest = { showMenu = false },
) {
DropdownMenuItem(
text = { Text(text = stringResource(KMR.strings.action_library_search)) },
onClick = {
librarySearch(title)
showMenu = false
},
)
DropdownMenuItem(
text = { Text(text = stringResource(MR.strings.action_global_search)) },
onClick = {
doSearch(title, true)
showMenu = false
},
)
DropdownMenuItem(
text = { Text(text = stringResource(MR.strings.action_copy_to_clipboard)) },
onClick = {
context.copyToClipboard(
title,
title,
)
showMenu = false
},
)
}
// KMK <--
Text(
text = title.ifBlank { stringResource(MR.strings.unknown_title) },
style = MaterialTheme.typography.titleLarge,
modifier = Modifier.clickableNoIndication(
onLongClick = {
if (title.isNotBlank()) {
context.copyToClipboard(
title,
title,
)
// KMK -->
showMenu = true
// KMK <--
}
},
onClick = { if (title.isNotBlank()) doSearch(title, true) },
Expand Down
17 changes: 15 additions & 2 deletions app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ class MangaScreen(
onRefresh = screenModel::fetchAllFromSource,
onContinueReading = { continueReading(context, screenModel.getNextUnreadChapter()) },
onSearch = { query, global -> scope.launch { performSearch(navigator, query, global) } },
// KMK -->
librarySearch = { query ->
scope.launch { performSearch(navigator, query, global = false, library = true) }
},
// KMK <--
onCoverClicked = screenModel::showCoverDialog,
onShareClicked = { shareManga(context, screenModel.manga, screenModel.source) }.takeIf { isHttpSource },
onDownloadActionClicked = screenModel::runDownloadAction.takeIf { !successState.source.isLocalOrStub() },
Expand Down Expand Up @@ -573,7 +578,14 @@ class MangaScreen(
*
* @param query the search query to the parent controller
*/
private suspend fun performSearch(navigator: Navigator, query: String, global: Boolean) {
private suspend fun performSearch(
navigator: Navigator,
query: String,
global: Boolean,
// KMK -->
library: Boolean = false,
// KMK <--
) {
if (global) {
navigator.push(GlobalSearchScreen(query))
return
Expand All @@ -585,7 +597,8 @@ class MangaScreen(

// KMK -->
navigator.popUntil { screen ->
screen is BrowseSourceScreen || screen is HomeScreen || screen is SourceFeedScreen
screen is HomeScreen ||
!library && (screen is BrowseSourceScreen || screen is SourceFeedScreen)
}
// KMK <--

Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string name="theme_matrix">ماتريكس</string>
<string name="theme_mocha">موكا</string>
<string name="theme_sapphire">ياقوت</string>
<string name="action_source_search">البحث عن مصدر</string>
<string name="action_search_for_source">البحث عن مصدر</string>
<string name="action_toggle_nsfw_only">تبديل NSFW فقط</string>
<string name="action_bulk_select">وضع التحديد بالجملة</string>
<string name="action_faq_and_guides">الأسئلة الشائعة والأدلة</string>
Expand Down
4 changes: 3 additions & 1 deletion i18n-kmk/src/commonMain/moko-resources/base/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Actions -->
<string name="action_source_search">Search for source</string>
<string name="action_search_for_source">Search for source</string>
<string name="action_source_search">Source search</string>
<string name="action_library_search">Library search</string>
<string name="action_toggle_nsfw_only">Toggle NSFW only</string>
<string name="action_bulk_select">Bulk selection mode</string>
<string name="action_faq_and_guides">FAQ and Guides</string>
Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/cs/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="action_source_search">Hledat zdroj</string>
<string name="action_search_for_source">Hledat zdroj</string>
<string name="action_toggle_nsfw_only">Přepnout pouze NSFW</string>
<string name="action_bulk_select">Režim hromadného výběru</string>
<string name="action_faq_and_guides">FAQ a návody</string>
Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/da/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="action_source_search">Søg efter kilde</string>
<string name="action_search_for_source">Søg efter kilde</string>
<string name="action_toggle_nsfw_only">Slå kun NSFW til/fra</string>
<string name="action_bulk_select">Masse valg tilstand</string>
<string name="action_faq_and_guides">Ofte stillede spørgsmål og vejledninger</string>
Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string name="theme_matrix">Matrix</string>
<string name="theme_mocha">Mokka</string>
<string name="theme_sapphire">Saphir</string>
<string name="action_source_search">Nach Quelle suchen</string>
<string name="action_search_for_source">Nach Quelle suchen</string>
<string name="action_toggle_nsfw_only">Nur NSFW umschalten</string>
<string name="action_bulk_select">Massenauswahlmodus</string>
<string name="action_faq_and_guides">FAQ und Anleitungen</string>
Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/el/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="action_source_search">Αναζήτηση πηγής</string>
<string name="action_search_for_source">Αναζήτηση πηγής</string>
<string name="action_toggle_nsfw_only">Εναλλαγή μόνο NSFW</string>
<string name="action_bulk_select">Λειτουργία μαζικής επιλογής</string>
<string name="action_faq_and_guides">Συχνές ερωτήσεις και οδηγοί</string>
Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string name="theme_matrix">Matrix</string>
<string name="theme_mocha">Moca</string>
<string name="theme_sapphire">Zafiro</string>
<string name="action_source_search">Buscar fuente</string>
<string name="action_search_for_source">Buscar fuente</string>
<string name="action_toggle_nsfw_only">Alternar sólo NSFW</string>
<string name="action_bulk_select">Modo de selección masiva</string>
<string name="action_faq_and_guides">Preguntas frecuentes y guías</string>
Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/fi/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="action_source_search">Hae lähdekoodia</string>
<string name="action_search_for_source">Hae lähdekoodia</string>
<string name="action_toggle_nsfw_only">Vaihda vain NSFW</string>
<string name="action_bulk_select">Bulk valintatila</string>
<string name="action_faq_and_guides">UKK ja oppaat</string>
Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string name="theme_matrix">Matrix</string>
<string name="theme_mocha">Mocha</string>
<string name="theme_sapphire">Saphir</string>
<string name="action_source_search">Rechercher une source</string>
<string name="action_search_for_source">Rechercher une source</string>
<string name="action_toggle_nsfw_only">Activer/désactiver uniquement NSFW</string>
<string name="action_bulk_select">Mode de sélection en bloc</string>
<string name="action_faq_and_guides">FAQ et tutoriels</string>
Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string name="theme_matrix">Matrix</string>
<string name="theme_mocha">Mocha</string>
<string name="theme_sapphire">Zaffiro</string>
<string name="action_source_search">Cerca la sorgente</string>
<string name="action_search_for_source">Cerca la sorgente</string>
<string name="action_toggle_nsfw_only">Attiva/disattiva solo NSFW</string>
<string name="action_bulk_select">Modalità selezione Bulk</string>
<string name="action_faq_and_guides">FAQ e guide</string>
Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/ja/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="action_source_search">ソースを検索</string>
<string name="action_search_for_source">ソースを検索</string>
<string name="action_toggle_nsfw_only">NSFWのみ切り替え</string>
<string name="action_bulk_select">一括選択モード</string>
<string name="action_faq_and_guides">FAQ とガイド</string>
Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/nl/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="action_source_search">Bron zoeken</string>
<string name="action_search_for_source">Bron zoeken</string>
<string name="action_toggle_nsfw_only">Alleen NSFW in-/uitschakelen</string>
<string name="action_bulk_select">Bulk selectiemodus</string>
<string name="action_faq_and_guides">FAQ en handleidingen</string>
Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/pl/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="action_source_search">Szukaj źródła</string>
<string name="action_search_for_source">Szukaj źródła</string>
<string name="action_toggle_nsfw_only">Przełącz tylko NSFW</string>
<string name="action_bulk_select">Tryb masowego zaznaczenia</string>
<string name="action_faq_and_guides">FAQ i przewodniki</string>
Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string name="theme_matrix">Verde</string>
<string name="theme_mocha">Café</string>
<string name="theme_sapphire">Safira</string>
<string name="action_source_search">Pesquisar fonte</string>
<string name="action_search_for_source">Pesquisar fonte</string>
<string name="action_toggle_nsfw_only">Ativar/desativar somente NSFW</string>
<string name="action_bulk_select">Modo de seleção em massa</string>
<string name="action_faq_and_guides">FAQ e Guias</string>
Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string name="theme_matrix">Verde</string>
<string name="theme_mocha">Café</string>
<string name="theme_sapphire">Safira</string>
<string name="action_source_search">Pesquisar fonte</string>
<string name="action_search_for_source">Pesquisar fonte</string>
<string name="action_toggle_nsfw_only">Ativar/desativar somente NSFW</string>
<string name="action_bulk_select">Modo de seleção em massa</string>
<string name="action_faq_and_guides">FAQ e Guias</string>
Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/ro/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="action_source_search">Caută sursa</string>
<string name="action_search_for_source">Caută sursa</string>
<string name="action_toggle_nsfw_only">Comută numai NSFW</string>
<string name="action_bulk_select">Mod selecţie în masă</string>
<string name="action_faq_and_guides">Întrebări frecvente și ghiduri</string>
Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string name="theme_matrix">Matrix</string>
<string name="theme_mocha">Мокко</string>
<string name="theme_sapphire">Сапфир</string>
<string name="action_source_search">Поиск источника</string>
<string name="action_search_for_source">Поиск источника</string>
<string name="action_toggle_nsfw_only">Переключить только NSFW</string>
<string name="action_bulk_select">Режим массового выбора</string>
<string name="action_faq_and_guides">FAQ и руководства</string>
Expand Down
2 changes: 1 addition & 1 deletion i18n-kmk/src/commonMain/moko-resources/sv/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="action_source_search">Sök efter källa</string>
<string name="action_search_for_source">Sök efter källa</string>
<string name="action_toggle_nsfw_only">Växla endast NSFW</string>
<string name="action_bulk_select">Bulk markeringsläge</string>
<string name="action_faq_and_guides">Vanliga frågor och guider</string>
Expand Down
Loading

0 comments on commit 271aa16

Please sign in to comment.