From f1e5cccee727f06f56d8e5f496858fb5e2a954ea Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 21 Apr 2022 19:02:54 -0400 Subject: [PATCH] Add placeholder color for Compose manga covers --- .../presentation/components/MangaCover.kt | 5 ++++ .../presentation/history/HistoryScreen.kt | 4 ++-- .../presentation/theme/TachiyomiTheme.kt | 2 +- .../ui/manga/info/MangaCoverImageView.kt | 24 ------------------- gradle/compose.versions.toml | 2 +- 5 files changed, 9 insertions(+), 28 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaCoverImageView.kt diff --git a/app/src/main/java/eu/kanade/presentation/components/MangaCover.kt b/app/src/main/java/eu/kanade/presentation/components/MangaCover.kt index ca9332d944..33c8dfaf61 100644 --- a/app/src/main/java/eu/kanade/presentation/components/MangaCover.kt +++ b/app/src/main/java/eu/kanade/presentation/components/MangaCover.kt @@ -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) diff --git a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt index 0b687d363c..adbc67298c 100644 --- a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt @@ -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, diff --git a/app/src/main/java/eu/kanade/presentation/theme/TachiyomiTheme.kt b/app/src/main/java/eu/kanade/presentation/theme/TachiyomiTheme.kt index c01bc1e3b2..adb6644d20 100644 --- a/app/src/main/java/eu/kanade/presentation/theme/TachiyomiTheme.kt +++ b/app/src/main/java/eu/kanade/presentation/theme/TachiyomiTheme.kt @@ -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 ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaCoverImageView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaCoverImageView.kt deleted file mode 100644 index f7e5daf1cc..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaCoverImageView.kt +++ /dev/null @@ -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) - } -} diff --git a/gradle/compose.versions.toml b/gradle/compose.versions.toml index c7f1de71eb..6b271fc9ba 100644 --- a/gradle/compose.versions.toml +++ b/gradle/compose.versions.toml @@ -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" } \ No newline at end of file +ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref="compose" }