@@ -22,18 +22,22 @@ import androidx.compose.runtime.getValue
22
22
import androidx.compose.runtime.produceState
23
23
import androidx.compose.ui.Alignment
24
24
import androidx.compose.ui.Modifier
25
- import androidx.compose.ui.draw.drawWithContent
26
25
import androidx.compose.ui.graphics.Color
27
26
import androidx.compose.ui.platform.LocalContext
28
27
import androidx.compose.ui.text.style.TextOverflow
29
28
import androidx.compose.ui.unit.dp
30
29
import androidx.compose.ui.unit.sp
30
+ import androidx.compose.ui.util.fastAny
31
31
import androidx.paging.LoadState
32
32
import androidx.paging.compose.LazyPagingItems
33
33
import com.gowtham.ratingbar.RatingBar
34
34
import com.gowtham.ratingbar.RatingBarStyle
35
35
import dev.icerock.moko.resources.StringResource
36
+ import eu.kanade.presentation.library.components.CommonMangaItemDefaults
37
+ import eu.kanade.presentation.library.components.GridSelectedCoverAlpha
36
38
import eu.kanade.presentation.manga.components.MangaCover
39
+ import eu.kanade.presentation.manga.components.MangaCoverHide
40
+ import exh.debug.DebugToggles
37
41
import exh.metadata.MetadataUtil
38
42
import exh.metadata.metadata.EHentaiSearchMetadata
39
43
import exh.metadata.metadata.RaisedSearchMetadata
@@ -44,12 +48,12 @@ import kotlinx.coroutines.flow.StateFlow
44
48
import tachiyomi.core.common.i18n.pluralStringResource
45
49
import tachiyomi.core.common.util.lang.withIOContext
46
50
import tachiyomi.domain.manga.model.Manga
47
- import tachiyomi.i18n.MR
51
+ import tachiyomi.domain.manga.model.asMangaCover
48
52
import tachiyomi.i18n.sy.SYMR
49
- import tachiyomi.presentation.core.components.Badge
50
53
import tachiyomi.presentation.core.components.BadgeGroup
51
54
import tachiyomi.presentation.core.components.material.padding
52
55
import tachiyomi.presentation.core.i18n.stringResource
56
+ import tachiyomi.presentation.core.util.selectedBackground
53
57
import java.time.Instant
54
58
import java.time.ZoneId
55
59
@@ -59,6 +63,9 @@ fun BrowseSourceEHentaiList(
59
63
contentPadding : PaddingValues ,
60
64
onMangaClick : (Manga ) -> Unit ,
61
65
onMangaLongClick : (Manga ) -> Unit ,
66
+ // KMK -->
67
+ selection : List <Manga >,
68
+ // KMK <--
62
69
) {
63
70
LazyColumn (
64
71
contentPadding = contentPadding,
@@ -81,6 +88,9 @@ fun BrowseSourceEHentaiList(
81
88
// SY <--
82
89
onClick = { onMangaClick(manga) },
83
90
onLongClick = { onMangaLongClick(manga) },
91
+ // KMK -->
92
+ isSelected = selection.fastAny { selected -> selected.id == manga.id },
93
+ // KMK <--
84
94
)
85
95
}
86
96
@@ -100,9 +110,18 @@ fun BrowseSourceEHentaiListItem(
100
110
// SY <--
101
111
onClick : () -> Unit = {},
102
112
onLongClick : () -> Unit = onClick,
113
+ // KMK -->
114
+ isSelected : Boolean = false,
115
+ libraryColored : Boolean = true,
116
+ // KMK <--
103
117
) {
104
118
if (metadata !is EHentaiSearchMetadata ) return
105
- val overlayColor = MaterialTheme .colorScheme.background.copy(alpha = 0.66f )
119
+ // KMK -->
120
+ val coverData = manga.asMangaCover()
121
+ val bgColor = coverData.dominantCoverColors?.first?.let { Color (it) }.takeIf { libraryColored }
122
+ val onBgColor = coverData.dominantCoverColors?.second.takeIf { libraryColored }
123
+ val coverAlpha = if (manga.favorite) CommonMangaItemDefaults .BrowseFavoriteCoverAlpha else 1f
124
+ // KMK <--
106
125
107
126
val context = LocalContext .current
108
127
val languageText by produceState(" " , metadata) {
@@ -162,6 +181,7 @@ fun BrowseSourceEHentaiListItem(
162
181
163
182
Row (
164
183
modifier = Modifier
184
+ .selectedBackground(isSelected)
165
185
.height(148 .dp)
166
186
.combinedClickable(
167
187
onClick = onClick,
@@ -171,24 +191,36 @@ fun BrowseSourceEHentaiListItem(
171
191
verticalAlignment = Alignment .CenterVertically ,
172
192
) {
173
193
Box {
174
- MangaCover .Book (
175
- modifier = Modifier
176
- .fillMaxHeight()
177
- .drawWithContent {
178
- drawContent()
179
- if (manga.favorite) {
180
- drawRect(overlayColor)
181
- }
182
- },
183
- data = manga,
184
- )
194
+ // KMK -->
195
+ if (DebugToggles .HIDE_COVER_IMAGE_ONLY_SHOW_COLOR .enabled) {
196
+ MangaCoverHide .Book (
197
+ modifier = Modifier
198
+ .fillMaxHeight(),
199
+ bgColor = bgColor ? : (MaterialTheme .colorScheme.surface.takeIf { isSelected }),
200
+ tint = onBgColor,
201
+ )
202
+ } else {
203
+ // KMK <--
204
+ MangaCover .Book (
205
+ modifier = Modifier
206
+ .fillMaxHeight(),
207
+ // KMK -->
208
+ alpha = if (isSelected) GridSelectedCoverAlpha else coverAlpha,
209
+ bgColor = bgColor ? : (MaterialTheme .colorScheme.surface.takeIf { isSelected }),
210
+ tint = onBgColor,
211
+ // KMK <--
212
+ data = coverData,
213
+ )
214
+ }
185
215
if (manga.favorite) {
186
216
BadgeGroup (
187
217
modifier = Modifier
188
218
.padding(4 .dp)
189
219
.align(Alignment .TopStart ),
190
220
) {
191
- Badge (stringResource(MR .strings.in_library))
221
+ // KMK -->
222
+ InLibraryBadge (enabled = true )
223
+ // KMK <--
192
224
}
193
225
}
194
226
}
0 commit comments