Add placeholder color for Compose manga covers

This commit is contained in:
arkon 2022-04-21 19:02:54 -04:00
parent bc2ed763bd
commit f1e5cccee7
5 changed files with 9 additions and 28 deletions

View File

@ -5,7 +5,9 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.painter.ColorPainter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
@ -25,6 +27,7 @@ fun MangaCover(
) {
AsyncImage(
model = data,
placeholder = ColorPainter(CoverPlaceholderColor),
contentDescription = contentDescription,
modifier = modifier
.aspectRatio(aspect.ratio)
@ -32,3 +35,5 @@ fun MangaCover(
contentScale = ContentScale.Crop
)
}
private val CoverPlaceholderColor = Color(0x1F888888)

View File

@ -76,7 +76,7 @@ fun HistoryScreen(
onClickResume: (HistoryWithRelations) -> Unit,
onClickDelete: (HistoryWithRelations, Boolean) -> Unit,
) {
val nestedSrollInterop = rememberNestedScrollInteropConnection(composeView)
val nestedScrollInterop = rememberNestedScrollInteropConnection(composeView)
TachiyomiTheme {
val state by presenter.state.collectAsState()
val history = state.list?.collectAsLazyPagingItems()
@ -91,7 +91,7 @@ fun HistoryScreen(
}
else -> {
HistoryContent(
nestedScroll = nestedSrollInterop,
nestedScroll = nestedScrollInterop,
history = history,
onClickItem = onClickItem,
onClickResume = onClickResume,

View File

@ -8,7 +8,7 @@ import com.google.android.material.composethemeadapter3.createMdc3Theme
@Composable
fun TachiyomiTheme(content: @Composable () -> Unit) {
val context = LocalContext.current
var (colorScheme, typography) = createMdc3Theme(
val (colorScheme, typography) = createMdc3Theme(
context = context
)

View File

@ -1,24 +0,0 @@
package eu.kanade.tachiyomi.ui.manga.info
import android.content.Context
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatImageView
import kotlin.math.min
/**
* A custom ImageView for holding a manga cover with:
* - width: min(maxWidth attr, 33% of parent width)
* - height: 2:3 width:height ratio
*
* Should be defined with a width of match_parent.
*/
class MangaCoverImageView(context: Context, attrs: AttributeSet?) : AppCompatImageView(context, attrs) {
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
val width = min(maxWidth, measuredWidth / 3)
val height = width / 2 * 3
setMeasuredDimension(width, height)
}
}

View File

@ -6,4 +6,4 @@ foundation = { module = "androidx.compose.foundation:foundation", version.ref="c
material3-core = "androidx.compose.material3:material3:1.0.0-alpha09"
material3-adapter = "com.google.android.material:compose-theme-adapter-3:1.0.6"
animation = { module = "androidx.compose.animation:animation", version.ref="compose" }
ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref="compose" }
ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref="compose" }