Add placeholder color for Compose manga covers
This commit is contained in:
parent
bc2ed763bd
commit
f1e5cccee7
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
)
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user