Debug setting to hide cover image showing only color
This commit is contained in:
parent
a67d63a4d8
commit
0e7a4a7066
3 changed files with 127 additions and 39 deletions
|
|
@ -38,6 +38,8 @@ import androidx.compose.ui.unit.Dp
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import eu.kanade.presentation.manga.components.MangaCover
|
||||
import eu.kanade.presentation.manga.components.MangaCoverHide
|
||||
import exh.debug.DebugToggles
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.BadgeGroup
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
|
|
@ -93,19 +95,30 @@ fun MangaCompactGridItem(
|
|||
) {
|
||||
MangaGridCover(
|
||||
cover = {
|
||||
MangaCover.Book(
|
||||
modifier = Modifier
|
||||
// KMK -->
|
||||
// .alpha(if (isSelected) GridSelectedCoverAlpha else coverAlpha)
|
||||
// KMK <--
|
||||
.fillMaxWidth(),
|
||||
data = coverData,
|
||||
// KMK -->
|
||||
alpha = if (isSelected) GridSelectedCoverAlpha else coverAlpha,
|
||||
bgColor = bgColor,
|
||||
tint = onBgColor,
|
||||
// KMK -->
|
||||
if (DebugToggles.HIDE_COVER_IMAGE_ONLY_SHOW_COLOR.enabled) {
|
||||
MangaCoverHide.Book(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(),
|
||||
bgColor = bgColor,
|
||||
tint = onBgColor,
|
||||
)
|
||||
} else {
|
||||
// KMK <--
|
||||
)
|
||||
MangaCover.Book(
|
||||
modifier = Modifier
|
||||
// KMK -->
|
||||
// .alpha(if (isSelected) GridSelectedCoverAlpha else coverAlpha)
|
||||
// KMK <--
|
||||
.fillMaxWidth(),
|
||||
data = coverData,
|
||||
// KMK -->
|
||||
alpha = if (isSelected) GridSelectedCoverAlpha else coverAlpha,
|
||||
bgColor = bgColor,
|
||||
tint = onBgColor,
|
||||
// KMK <--
|
||||
)
|
||||
}
|
||||
},
|
||||
badgesStart = coverBadgeStart,
|
||||
badgesEnd = coverBadgeEnd,
|
||||
|
|
@ -214,19 +227,30 @@ fun MangaComfortableGridItem(
|
|||
Column {
|
||||
MangaGridCover(
|
||||
cover = {
|
||||
MangaCover.Book(
|
||||
modifier = Modifier
|
||||
// KMK -->
|
||||
// .alpha(if (isSelected) GridSelectedCoverAlpha else coverAlpha)
|
||||
// KMK <--
|
||||
.fillMaxWidth(),
|
||||
data = coverData,
|
||||
// KMK -->
|
||||
alpha = if (isSelected) GridSelectedCoverAlpha else coverAlpha,
|
||||
bgColor = bgColor,
|
||||
tint = onBgColor,
|
||||
// KMK -->
|
||||
if (DebugToggles.HIDE_COVER_IMAGE_ONLY_SHOW_COLOR.enabled) {
|
||||
MangaCoverHide.Book(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(),
|
||||
bgColor = bgColor,
|
||||
tint = onBgColor,
|
||||
)
|
||||
} else {
|
||||
// KMK <--
|
||||
)
|
||||
MangaCover.Book(
|
||||
modifier = Modifier
|
||||
// KMK -->
|
||||
// .alpha(if (isSelected) GridSelectedCoverAlpha else coverAlpha)
|
||||
// KMK <--
|
||||
.fillMaxWidth(),
|
||||
data = coverData,
|
||||
// KMK -->
|
||||
alpha = if (isSelected) GridSelectedCoverAlpha else coverAlpha,
|
||||
bgColor = bgColor,
|
||||
tint = onBgColor,
|
||||
// KMK <--
|
||||
)
|
||||
}
|
||||
},
|
||||
badgesStart = coverBadgeStart,
|
||||
badgesEnd = coverBadgeEnd,
|
||||
|
|
@ -384,20 +408,31 @@ fun MangaListItem(
|
|||
.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
MangaCover.Square(
|
||||
modifier = Modifier
|
||||
// KMK -->
|
||||
// .alpha(coverAlpha)
|
||||
// KMK <--
|
||||
.fillMaxHeight(),
|
||||
data = coverData,
|
||||
// KMK -->
|
||||
alpha = coverAlpha,
|
||||
bgColor = bgColor,
|
||||
tint = onBgColor,
|
||||
size = MangaCover.Size.Big,
|
||||
// KMK -->
|
||||
if (DebugToggles.HIDE_COVER_IMAGE_ONLY_SHOW_COLOR.enabled) {
|
||||
MangaCoverHide.Square(
|
||||
modifier = Modifier
|
||||
.fillMaxHeight(),
|
||||
bgColor = bgColor,
|
||||
tint = onBgColor,
|
||||
)
|
||||
} else {
|
||||
// KMK <--
|
||||
)
|
||||
MangaCover.Square(
|
||||
modifier = Modifier
|
||||
// KMK -->
|
||||
// .alpha(coverAlpha)
|
||||
// KMK <--
|
||||
.fillMaxHeight(),
|
||||
data = coverData,
|
||||
// KMK -->
|
||||
alpha = coverAlpha,
|
||||
bgColor = bgColor,
|
||||
tint = onBgColor,
|
||||
size = MangaCover.Size.Big,
|
||||
// KMK <--
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = title,
|
||||
modifier = Modifier
|
||||
|
|
|
|||
|
|
@ -145,5 +145,54 @@ enum class MangaCover(val ratio: Float) {
|
|||
}
|
||||
}
|
||||
|
||||
private val CoverPlaceholderColor = Color(0x1F888888)
|
||||
private val CoverPlaceholderOnBgColor = Color(0x8F888888)
|
||||
enum class MangaCoverHide(private val ratio: Float) {
|
||||
Square(1f / 1f),
|
||||
Book(2f / 3f),
|
||||
;
|
||||
|
||||
@Composable
|
||||
operator fun invoke(
|
||||
modifier: Modifier = Modifier,
|
||||
contentDescription: String = "",
|
||||
shape: Shape = MaterialTheme.shapes.extraSmall,
|
||||
onClick: (() -> Unit)? = null,
|
||||
// KMK -->
|
||||
/** background color, which used for loading/error indicator */
|
||||
bgColor: Color? = CoverPlaceholderColor,
|
||||
/** onBackground color, which used for loading/error indicator */
|
||||
@ColorInt tint: Int? = null,
|
||||
) {
|
||||
val modifierColored = modifier
|
||||
.aspectRatio(ratio)
|
||||
.clip(shape)
|
||||
.background(bgColor ?: CoverPlaceholderColor)
|
||||
.then(
|
||||
if (onClick != null) {
|
||||
Modifier.clickable(
|
||||
role = Role.Button,
|
||||
onClick = onClick,
|
||||
)
|
||||
} else {
|
||||
Modifier
|
||||
},
|
||||
)
|
||||
|
||||
Box(
|
||||
modifier = modifierColored
|
||||
) {
|
||||
Image(
|
||||
imageVector = ImageVector.vectorResource(R.drawable.ic_baseline_menu_book_24),
|
||||
contentDescription = contentDescription,
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.align(Alignment.Center),
|
||||
colorFilter = ColorFilter.tint(
|
||||
tint?.let { Color(it) } ?: CoverPlaceholderOnBgColor
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal val CoverPlaceholderColor = Color(0x1F888888)
|
||||
internal val CoverPlaceholderOnBgColor = Color(0x8F888888)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@ enum class DebugToggles(val default: Boolean) {
|
|||
|
||||
// Pretend that all galleries only have a single version
|
||||
INCLUDE_ONLY_ROOT_WHEN_LOADING_EXH_VERSIONS(false),
|
||||
|
||||
// KMK -->
|
||||
HIDE_COVER_IMAGE_ONLY_SHOW_COLOR(false),
|
||||
// KMK <--
|
||||
;
|
||||
|
||||
private val prefKey = "eh_debug_toggle_${name.lowercase(Locale.US)}"
|
||||
|
|
|
|||
Loading…
Reference in a new issue