feat: update E-Hentai to support libraryColored, bulk-selection overlay & hide-cover
also update in-library badge
This commit is contained in:
parent
afbb4b70b1
commit
1d9ed72f93
3 changed files with 52 additions and 17 deletions
|
|
@ -161,6 +161,9 @@ fun BrowseSourceContent(
|
||||||
contentPadding = contentPadding,
|
contentPadding = contentPadding,
|
||||||
onMangaClick = onMangaClick,
|
onMangaClick = onMangaClick,
|
||||||
onMangaLongClick = onMangaLongClick,
|
onMangaLongClick = onMangaLongClick,
|
||||||
|
// KMK -->
|
||||||
|
selection = selection,
|
||||||
|
// KMK <--
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,18 +22,22 @@ import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.produceState
|
import androidx.compose.runtime.produceState
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.drawWithContent
|
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
|
import androidx.compose.ui.util.fastAny
|
||||||
import androidx.paging.LoadState
|
import androidx.paging.LoadState
|
||||||
import androidx.paging.compose.LazyPagingItems
|
import androidx.paging.compose.LazyPagingItems
|
||||||
import com.gowtham.ratingbar.RatingBar
|
import com.gowtham.ratingbar.RatingBar
|
||||||
import com.gowtham.ratingbar.RatingBarStyle
|
import com.gowtham.ratingbar.RatingBarStyle
|
||||||
import dev.icerock.moko.resources.StringResource
|
import dev.icerock.moko.resources.StringResource
|
||||||
|
import eu.kanade.presentation.library.components.CommonMangaItemDefaults
|
||||||
|
import eu.kanade.presentation.library.components.GridSelectedCoverAlpha
|
||||||
import eu.kanade.presentation.manga.components.MangaCover
|
import eu.kanade.presentation.manga.components.MangaCover
|
||||||
|
import eu.kanade.presentation.manga.components.MangaCoverHide
|
||||||
|
import exh.debug.DebugToggles
|
||||||
import exh.metadata.MetadataUtil
|
import exh.metadata.MetadataUtil
|
||||||
import exh.metadata.metadata.EHentaiSearchMetadata
|
import exh.metadata.metadata.EHentaiSearchMetadata
|
||||||
import exh.metadata.metadata.RaisedSearchMetadata
|
import exh.metadata.metadata.RaisedSearchMetadata
|
||||||
|
|
@ -44,12 +48,12 @@ import kotlinx.coroutines.flow.StateFlow
|
||||||
import tachiyomi.core.common.i18n.pluralStringResource
|
import tachiyomi.core.common.i18n.pluralStringResource
|
||||||
import tachiyomi.core.common.util.lang.withIOContext
|
import tachiyomi.core.common.util.lang.withIOContext
|
||||||
import tachiyomi.domain.manga.model.Manga
|
import tachiyomi.domain.manga.model.Manga
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.domain.manga.model.asMangaCover
|
||||||
import tachiyomi.i18n.sy.SYMR
|
import tachiyomi.i18n.sy.SYMR
|
||||||
import tachiyomi.presentation.core.components.Badge
|
|
||||||
import tachiyomi.presentation.core.components.BadgeGroup
|
import tachiyomi.presentation.core.components.BadgeGroup
|
||||||
import tachiyomi.presentation.core.components.material.padding
|
import tachiyomi.presentation.core.components.material.padding
|
||||||
import tachiyomi.presentation.core.i18n.stringResource
|
import tachiyomi.presentation.core.i18n.stringResource
|
||||||
|
import tachiyomi.presentation.core.util.selectedBackground
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.time.ZoneId
|
import java.time.ZoneId
|
||||||
|
|
||||||
|
|
@ -59,6 +63,9 @@ fun BrowseSourceEHentaiList(
|
||||||
contentPadding: PaddingValues,
|
contentPadding: PaddingValues,
|
||||||
onMangaClick: (Manga) -> Unit,
|
onMangaClick: (Manga) -> Unit,
|
||||||
onMangaLongClick: (Manga) -> Unit,
|
onMangaLongClick: (Manga) -> Unit,
|
||||||
|
// KMK -->
|
||||||
|
selection: List<Manga>,
|
||||||
|
// KMK <--
|
||||||
) {
|
) {
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
contentPadding = contentPadding,
|
contentPadding = contentPadding,
|
||||||
|
|
@ -81,6 +88,9 @@ fun BrowseSourceEHentaiList(
|
||||||
// SY <--
|
// SY <--
|
||||||
onClick = { onMangaClick(manga) },
|
onClick = { onMangaClick(manga) },
|
||||||
onLongClick = { onMangaLongClick(manga) },
|
onLongClick = { onMangaLongClick(manga) },
|
||||||
|
// KMK -->
|
||||||
|
isSelected = selection.fastAny { selected -> selected.id == manga.id },
|
||||||
|
// KMK <--
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,9 +110,18 @@ fun BrowseSourceEHentaiListItem(
|
||||||
// SY <--
|
// SY <--
|
||||||
onClick: () -> Unit = {},
|
onClick: () -> Unit = {},
|
||||||
onLongClick: () -> Unit = onClick,
|
onLongClick: () -> Unit = onClick,
|
||||||
|
// KMK -->
|
||||||
|
isSelected: Boolean = false,
|
||||||
|
libraryColored: Boolean = true,
|
||||||
|
// KMK <--
|
||||||
) {
|
) {
|
||||||
if (metadata !is EHentaiSearchMetadata) return
|
if (metadata !is EHentaiSearchMetadata) return
|
||||||
val overlayColor = MaterialTheme.colorScheme.background.copy(alpha = 0.66f)
|
// KMK -->
|
||||||
|
val coverData = manga.asMangaCover()
|
||||||
|
val bgColor = coverData.dominantCoverColors?.first?.let { Color(it) }.takeIf { libraryColored }
|
||||||
|
val onBgColor = coverData.dominantCoverColors?.second.takeIf { libraryColored }
|
||||||
|
val coverAlpha = if (manga.favorite) CommonMangaItemDefaults.BrowseFavoriteCoverAlpha else 1f
|
||||||
|
// KMK <--
|
||||||
|
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val languageText by produceState("", metadata) {
|
val languageText by produceState("", metadata) {
|
||||||
|
|
@ -162,6 +181,7 @@ fun BrowseSourceEHentaiListItem(
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
.selectedBackground(isSelected)
|
||||||
.height(148.dp)
|
.height(148.dp)
|
||||||
.combinedClickable(
|
.combinedClickable(
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
|
|
@ -171,24 +191,36 @@ fun BrowseSourceEHentaiListItem(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
Box {
|
Box {
|
||||||
MangaCover.Book(
|
// KMK -->
|
||||||
modifier = Modifier
|
if (DebugToggles.HIDE_COVER_IMAGE_ONLY_SHOW_COLOR.enabled) {
|
||||||
.fillMaxHeight()
|
MangaCoverHide.Book(
|
||||||
.drawWithContent {
|
modifier = Modifier
|
||||||
drawContent()
|
.fillMaxHeight(),
|
||||||
if (manga.favorite) {
|
bgColor = bgColor ?: (MaterialTheme.colorScheme.surface.takeIf { isSelected }),
|
||||||
drawRect(overlayColor)
|
tint = onBgColor,
|
||||||
}
|
)
|
||||||
},
|
} else {
|
||||||
data = manga,
|
// KMK <--
|
||||||
)
|
MangaCover.Book(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxHeight(),
|
||||||
|
// KMK -->
|
||||||
|
alpha = if (isSelected) GridSelectedCoverAlpha else coverAlpha,
|
||||||
|
bgColor = bgColor ?: (MaterialTheme.colorScheme.surface.takeIf { isSelected }),
|
||||||
|
tint = onBgColor,
|
||||||
|
// KMK <--
|
||||||
|
data = coverData,
|
||||||
|
)
|
||||||
|
}
|
||||||
if (manga.favorite) {
|
if (manga.favorite) {
|
||||||
BadgeGroup(
|
BadgeGroup(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(4.dp)
|
.padding(4.dp)
|
||||||
.align(Alignment.TopStart),
|
.align(Alignment.TopStart),
|
||||||
) {
|
) {
|
||||||
Badge(stringResource(MR.strings.in_library))
|
// KMK -->
|
||||||
|
InLibraryBadge(enabled = true)
|
||||||
|
// KMK <--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ private val ContinueReadingButtonIconSizeLarge = 20.dp
|
||||||
private val ContinueReadingButtonGridPadding = 6.dp
|
private val ContinueReadingButtonGridPadding = 6.dp
|
||||||
private val ContinueReadingButtonListSpacing = 8.dp
|
private val ContinueReadingButtonListSpacing = 8.dp
|
||||||
|
|
||||||
private const val GridSelectedCoverAlpha = 0.76f
|
internal const val GridSelectedCoverAlpha = 0.76f
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layout of grid list item with title overlaying the cover.
|
* Layout of grid list item with title overlaying the cover.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue