mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 13:31:51 +01:00
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.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.Shape
|
import androidx.compose.ui.graphics.Shape
|
||||||
|
import androidx.compose.ui.graphics.painter.ColorPainter
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import coil.compose.AsyncImage
|
import coil.compose.AsyncImage
|
||||||
@ -25,6 +27,7 @@ fun MangaCover(
|
|||||||
) {
|
) {
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
model = data,
|
model = data,
|
||||||
|
placeholder = ColorPainter(CoverPlaceholderColor),
|
||||||
contentDescription = contentDescription,
|
contentDescription = contentDescription,
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.aspectRatio(aspect.ratio)
|
.aspectRatio(aspect.ratio)
|
||||||
@ -32,3 +35,5 @@ fun MangaCover(
|
|||||||
contentScale = ContentScale.Crop
|
contentScale = ContentScale.Crop
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val CoverPlaceholderColor = Color(0x1F888888)
|
||||||
|
@ -76,7 +76,7 @@ fun HistoryScreen(
|
|||||||
onClickResume: (HistoryWithRelations) -> Unit,
|
onClickResume: (HistoryWithRelations) -> Unit,
|
||||||
onClickDelete: (HistoryWithRelations, Boolean) -> Unit,
|
onClickDelete: (HistoryWithRelations, Boolean) -> Unit,
|
||||||
) {
|
) {
|
||||||
val nestedSrollInterop = rememberNestedScrollInteropConnection(composeView)
|
val nestedScrollInterop = rememberNestedScrollInteropConnection(composeView)
|
||||||
TachiyomiTheme {
|
TachiyomiTheme {
|
||||||
val state by presenter.state.collectAsState()
|
val state by presenter.state.collectAsState()
|
||||||
val history = state.list?.collectAsLazyPagingItems()
|
val history = state.list?.collectAsLazyPagingItems()
|
||||||
@ -91,7 +91,7 @@ fun HistoryScreen(
|
|||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
HistoryContent(
|
HistoryContent(
|
||||||
nestedScroll = nestedSrollInterop,
|
nestedScroll = nestedScrollInterop,
|
||||||
history = history,
|
history = history,
|
||||||
onClickItem = onClickItem,
|
onClickItem = onClickItem,
|
||||||
onClickResume = onClickResume,
|
onClickResume = onClickResume,
|
||||||
|
@ -8,7 +8,7 @@ import com.google.android.material.composethemeadapter3.createMdc3Theme
|
|||||||
@Composable
|
@Composable
|
||||||
fun TachiyomiTheme(content: @Composable () -> Unit) {
|
fun TachiyomiTheme(content: @Composable () -> Unit) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
var (colorScheme, typography) = createMdc3Theme(
|
val (colorScheme, typography) = createMdc3Theme(
|
||||||
context = context
|
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