feat(ui): better cover_error size
This commit is contained in:
parent
06004de0f1
commit
a2b0103e98
9 changed files with 65 additions and 13 deletions
|
|
@ -61,6 +61,7 @@ fun HistoryItem(
|
|||
// KMK -->
|
||||
bgColor = bgColor,
|
||||
tint = onBgColor,
|
||||
size = MangaCover.Size.Medium,
|
||||
// KMK <--
|
||||
)
|
||||
Column(
|
||||
|
|
|
|||
|
|
@ -382,6 +382,7 @@ fun MangaListItem(
|
|||
alpha = coverAlpha,
|
||||
bgColor = bgColor,
|
||||
tint = onBgColor,
|
||||
size = MangaCover.Size.Big,
|
||||
// KMK <--
|
||||
)
|
||||
Text(
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@ private val defaultCover: @Composable RowScope.(Manga, () -> Unit) -> Unit = { m
|
|||
.fillMaxHeight(),
|
||||
data = manga,
|
||||
onClick = onClick,
|
||||
// KMK -->
|
||||
size = MangaCover.Size.Big,
|
||||
// KMK <--
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,12 @@ enum class MangaCover(val ratio: Float) {
|
|||
Book(2f / 3f),
|
||||
;
|
||||
|
||||
enum class Size {
|
||||
Normal,
|
||||
Medium,
|
||||
Big,
|
||||
}
|
||||
|
||||
@Composable
|
||||
operator fun invoke(
|
||||
data: Any?,
|
||||
|
|
@ -46,9 +52,15 @@ enum class MangaCover(val ratio: Float) {
|
|||
bgColor: Color? = null,
|
||||
@ColorInt tint: Int? = null,
|
||||
onCoverLoaded: ((DomainMangaCover) -> Unit)? = null,
|
||||
size: Size = Size.Normal,
|
||||
// KMK <--
|
||||
) {
|
||||
// KMK -->
|
||||
val coverErrorPainter = when (size) {
|
||||
Size.Big -> rememberResourceBitmapPainter(id = R.drawable.cover_error_big, tint)
|
||||
Size.Medium -> rememberResourceBitmapPainter(id = R.drawable.cover_error_medium, tint)
|
||||
else -> rememberResourceBitmapPainter(id = R.drawable.cover_error, tint)
|
||||
}
|
||||
val animatedImageVector = AnimatedImageVector.animatedVectorResource(R.drawable.anim_waiting)
|
||||
var atEnd by remember { mutableStateOf(false) }
|
||||
|
||||
|
|
@ -71,8 +83,8 @@ enum class MangaCover(val ratio: Float) {
|
|||
// KMK -->
|
||||
// placeholder = ColorPainter(CoverPlaceholderColor),
|
||||
placeholder = rememberAnimatedVectorPainter(animatedImageVector = animatedImageVector, atEnd = atEnd),
|
||||
error = rememberResourceBitmapPainter(id = R.drawable.cover_error, tint),
|
||||
fallback = rememberResourceBitmapPainter(id = R.drawable.cover_error, tint),
|
||||
error = coverErrorPainter,
|
||||
fallback = coverErrorPainter,
|
||||
onSuccess = {
|
||||
succeed = true
|
||||
if (onCoverLoaded != null) {
|
||||
|
|
|
|||
|
|
@ -183,6 +183,7 @@ private fun UpdatesUiItem(
|
|||
// KMK -->
|
||||
bgColor = bgColor,
|
||||
tint = onBgColor,
|
||||
size = MangaCover.Size.Big,
|
||||
// KMK <--
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,16 +9,8 @@
|
|||
android:top="48dp"
|
||||
android:bottom="48dp"
|
||||
android:left="48dp"
|
||||
android:right="48dp">
|
||||
<vector
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/cover_placeholder"
|
||||
android:pathData="M21,5v6.59l-2.29,-2.3c-0.39,-0.39 -1.03,-0.39 -1.42,0L14,12.59 10.71,9.3c-0.39,-0.39 -1.02,-0.39 -1.41,0L6,12.59 3,9.58L3,5c0,-1.1 0.9,-2 2,-2h14c1.1,0 2,0.9 2,2zM18,11.42l3,3.01L21,19c0,1.1 -0.9,2 -2,2L5,21c-1.1,0 -2,-0.9 -2,-2v-6.58l2.29,2.29c0.39,0.39 1.02,0.39 1.41,0l3.3,-3.3 3.29,3.29c0.39,0.39 1.02,0.39 1.41,0l3.3,-3.28z"/>
|
||||
</vector>
|
||||
</item>
|
||||
android:right="48dp"
|
||||
android:drawable="@drawable/cover_error_vector"
|
||||
/>
|
||||
|
||||
</layer-list>
|
||||
|
|
|
|||
16
app/src/main/res/drawable/cover_error_big.xml
Normal file
16
app/src/main/res/drawable/cover_error_big.xml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<item>
|
||||
<color android:color="@color/cover_placeholder" />
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:top="6dp"
|
||||
android:bottom="6dp"
|
||||
android:left="6dp"
|
||||
android:right="6dp"
|
||||
android:drawable="@drawable/cover_error_vector"
|
||||
/>
|
||||
|
||||
</layer-list>
|
||||
16
app/src/main/res/drawable/cover_error_medium.xml
Normal file
16
app/src/main/res/drawable/cover_error_medium.xml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<item>
|
||||
<color android:color="@color/cover_placeholder" />
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:top="24dp"
|
||||
android:bottom="24dp"
|
||||
android:left="24dp"
|
||||
android:right="24dp"
|
||||
android:drawable="@drawable/cover_error_vector"
|
||||
/>
|
||||
|
||||
</layer-list>
|
||||
10
app/src/main/res/drawable/cover_error_vector.xml
Normal file
10
app/src/main/res/drawable/cover_error_vector.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/cover_placeholder"
|
||||
android:pathData="M21,5v6.59l-2.29,-2.3c-0.39,-0.39 -1.03,-0.39 -1.42,0L14,12.59 10.71,9.3c-0.39,-0.39 -1.02,-0.39 -1.41,0L6,12.59 3,9.58L3,5c0,-1.1 0.9,-2 2,-2h14c1.1,0 2,0.9 2,2zM18,11.42l3,3.01L21,19c0,1.1 -0.9,2 -2,2L5,21c-1.1,0 -2,-0.9 -2,-2v-6.58l2.29,2.29c0.39,0.39 1.02,0.39 1.41,0l3.3,-3.3 3.29,3.29c0.39,0.39 1.02,0.39 1.41,0l3.3,-3.28z"/>
|
||||
</vector>
|
||||
Loading…
Reference in a new issue