shade for selected items

This commit is contained in:
Cuong M. Tran 2024-03-01 16:09:00 +07:00 committed by Cuong Tran
parent 5c5a0f5fcf
commit 459bbcc9bd
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2
4 changed files with 25 additions and 3 deletions

View file

@ -126,6 +126,7 @@ fun FeedScreen(
onClickManga = onClickManga,
// KMK -->
onLongClickManga = onLongClickManga,
selection = state.selection,
// KMK <--
)
}
@ -143,6 +144,7 @@ fun FeedItem(
onClickManga: (Manga) -> Unit,
// KMK -->
onLongClickManga: (Manga) -> Unit,
selection: List<Manga>,
// KMK <--
) {
when {
@ -161,6 +163,7 @@ fun FeedItem(
onLongClick = onClickManga,
*/
onLongClick = onLongClickManga,
selection = selection,
// KMK <--
)
}

View file

@ -14,6 +14,7 @@ import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.fastAny
import eu.kanade.presentation.library.components.CommonMangaItemDefaults
import eu.kanade.presentation.library.components.MangaComfortableGridItem
import tachiyomi.domain.manga.model.Manga
@ -29,6 +30,9 @@ fun GlobalSearchCardRow(
getManga: @Composable (Manga) -> State<Manga>,
onClick: (Manga) -> Unit,
onLongClick: (Manga) -> Unit,
// KMK -->
selection: List<Manga>? = null,
// KMK <--
) {
if (titles.isEmpty()) {
EmptyResultItem()
@ -47,6 +51,9 @@ fun GlobalSearchCardRow(
isFavorite = title.favorite,
onClick = { onClick(title) },
onLongClick = { onLongClick(title) },
// KMK -->
isSelected = selection?.fastAny { selected -> selected.id == title.id } ?: false,
// KMK <--
)
}
}
@ -59,6 +66,9 @@ private fun MangaItem(
isFavorite: Boolean,
onClick: () -> Unit,
onLongClick: () -> Unit,
// KMK -->
isSelected: Boolean = false,
// KMK <--
) {
Box(modifier = Modifier.width(96.dp)) {
MangaComfortableGridItem(
@ -68,7 +78,13 @@ private fun MangaItem(
coverBadgeStart = {
InLibraryBadge(enabled = isFavorite)
},
coverAlpha = if (isFavorite) CommonMangaItemDefaults.BrowseFavoriteCoverAlpha else 1f,
coverAlpha = when {
// KMK -->
isSelected -> CommonMangaItemDefaults.BrowseSelectedCoverAlpha
// KMK <--
isFavorite -> CommonMangaItemDefaults.BrowseFavoriteCoverAlpha
else -> 1f
},
onClick = onClick,
onLongClick = onLongClick,
)

View file

@ -10,7 +10,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Bookmark
import androidx.compose.material.icons.outlined.BookmarkAdd
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.PrimaryTabRow
import androidx.compose.material3.SnackbarHost
@ -139,7 +139,7 @@ private fun FeedSelectionToolbar(
persistentListOf(
AppBar.Action(
title = stringResource(MR.strings.action_bookmark),
icon = Icons.Outlined.Bookmark,
icon = Icons.Outlined.BookmarkAdd,
// TODO: method to add bookmark goes here
onClick = { },
),

View file

@ -48,6 +48,9 @@ object CommonMangaItemDefaults {
val GridVerticalSpacer = 4.dp
const val BrowseFavoriteCoverAlpha = 0.34f
// KMK -->
const val BrowseSelectedCoverAlpha = 0.17f
// KMK <--
}
private val ContinueReadingButtonSize = 28.dp