Add copy tags to clipboard feature (#9063)

This commit is contained in:
0x7673
2023-02-14 09:22:10 +05:30
committed by GitHub
parent 4d607c4aed
commit d02b0ca2db
4 changed files with 65 additions and 11 deletions

View File

@@ -35,6 +35,7 @@ import androidx.compose.material.icons.outlined.Pause
import androidx.compose.material.icons.outlined.Public
import androidx.compose.material.icons.outlined.Schedule
import androidx.compose.material.icons.outlined.Sync
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.LocalMinimumTouchTargetEnforcement
@@ -72,6 +73,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage
import com.google.accompanist.flowlayout.FlowRow
import eu.kanade.presentation.components.DropdownMenu
import eu.kanade.presentation.components.MangaCover
import eu.kanade.presentation.components.TextButton
import eu.kanade.presentation.util.clickableNoIndication
@@ -210,7 +212,8 @@ fun ExpandableMangaDescription(
defaultExpandState: Boolean,
description: String?,
tagsProvider: () -> List<String>?,
onTagClicked: (String) -> Unit,
onTagSearch: (String) -> Unit,
onCopyTagToClipboard: (tag: String) -> Unit,
) {
Column(modifier = modifier) {
val (expanded, onExpanded) = rememberSaveable {
@@ -240,6 +243,27 @@ fun ExpandableMangaDescription(
.padding(vertical = 12.dp)
.animateContentSize(),
) {
var showMenu by remember { mutableStateOf(false) }
var tagSelected by remember { mutableStateOf("") }
DropdownMenu(
expanded = showMenu,
onDismissRequest = { showMenu = false },
) {
DropdownMenuItem(
text = { Text(text = stringResource(R.string.action_search)) },
onClick = {
onTagSearch(tagSelected)
showMenu = false
},
)
DropdownMenuItem(
text = { Text(text = stringResource(R.string.action_copy_to_clipboard)) },
onClick = {
onCopyTagToClipboard(tagSelected)
showMenu = false
},
)
}
if (expanded) {
FlowRow(
modifier = Modifier.padding(horizontal = 16.dp),
@@ -249,7 +273,10 @@ fun ExpandableMangaDescription(
tags.forEach {
TagsChip(
text = it,
onClick = { onTagClicked(it) },
onClick = {
tagSelected = it
showMenu = true
},
)
}
}
@@ -261,7 +288,10 @@ fun ExpandableMangaDescription(
items(items = tags) {
TagsChip(
text = it,
onClick = { onTagClicked(it) },
onClick = {
tagSelected = it
showMenu = true
},
)
}
}