feat: add search drop-down menu for entry's author/artist/source

This commit is contained in:
Cuong-Tran 2024-07-08 00:57:02 +07:00
parent 271aa166aa
commit 1e34b95b51
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2

View file

@ -546,6 +546,7 @@ private fun ColumnScope.MangaContentInfo(
val context = LocalContext.current val context = LocalContext.current
// KMK --> // KMK -->
var showMenu by remember { mutableStateOf(false) } var showMenu by remember { mutableStateOf(false) }
var tagSelected by remember { mutableStateOf("") }
DropdownMenu( DropdownMenu(
expanded = showMenu, expanded = showMenu,
onDismissRequest = { showMenu = false }, onDismissRequest = { showMenu = false },
@ -553,14 +554,14 @@ private fun ColumnScope.MangaContentInfo(
DropdownMenuItem( DropdownMenuItem(
text = { Text(text = stringResource(KMR.strings.action_library_search)) }, text = { Text(text = stringResource(KMR.strings.action_library_search)) },
onClick = { onClick = {
librarySearch(title) librarySearch(tagSelected)
showMenu = false showMenu = false
}, },
) )
DropdownMenuItem( DropdownMenuItem(
text = { Text(text = stringResource(MR.strings.action_global_search)) }, text = { Text(text = stringResource(MR.strings.action_global_search)) },
onClick = { onClick = {
doSearch(title, true) doSearch(tagSelected, true)
showMenu = false showMenu = false
}, },
) )
@ -568,8 +569,8 @@ private fun ColumnScope.MangaContentInfo(
text = { Text(text = stringResource(MR.strings.action_copy_to_clipboard)) }, text = { Text(text = stringResource(MR.strings.action_copy_to_clipboard)) },
onClick = { onClick = {
context.copyToClipboard( context.copyToClipboard(
title, tagSelected,
title, tagSelected,
) )
showMenu = false showMenu = false
}, },
@ -583,6 +584,7 @@ private fun ColumnScope.MangaContentInfo(
onLongClick = { onLongClick = {
if (title.isNotBlank()) { if (title.isNotBlank()) {
// KMK --> // KMK -->
tagSelected = title
showMenu = true showMenu = true
// KMK <-- // KMK <--
} }
@ -612,10 +614,10 @@ private fun ColumnScope.MangaContentInfo(
.clickableNoIndication( .clickableNoIndication(
onLongClick = { onLongClick = {
if (!author.isNullOrBlank()) { if (!author.isNullOrBlank()) {
context.copyToClipboard( // KMK -->
author, tagSelected = author
author, showMenu = true
) // KMK <--
} }
}, },
onClick = { if (!author.isNullOrBlank()) doSearch(author, true) }, onClick = { if (!author.isNullOrBlank()) doSearch(author, true) },
@ -640,7 +642,12 @@ private fun ColumnScope.MangaContentInfo(
style = MaterialTheme.typography.titleSmall, style = MaterialTheme.typography.titleSmall,
modifier = Modifier modifier = Modifier
.clickableNoIndication( .clickableNoIndication(
onLongClick = { context.copyToClipboard(artist, artist) }, onLongClick = {
// KMK -->
tagSelected = artist
showMenu = true
// KMK <--
},
onClick = { doSearch(artist, true) }, onClick = { doSearch(artist, true) },
), ),
textAlign = textAlign, textAlign = textAlign,
@ -696,12 +703,17 @@ private fun ColumnScope.MangaContentInfo(
} }
Text( Text(
text = sourceName, text = sourceName,
modifier = Modifier.clickableNoIndication { modifier = Modifier.clickableNoIndication(
// KMK --> // KMK -->
// doSearch(sourceName, false) onLongClick = {
onSourceClick() tagSelected = sourceName
showMenu = true
},
onClick = {
onSourceClick()
},
// KMK <-- // KMK <--
}, ),
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
maxLines = 1, maxLines = 1,
) )