HistoryScreen Card Impl

This commit is contained in:
tarsin committed 2023-01-23 12:48:45 +08:00
1 parent ef4e0d76ec
commit b219b4e832
6 files changed
+119 -5

No files matched your search

+1 -1
View File
@@ -156,7 +156,7 @@ dependencies {
implementation 'dev.rikka.rikkax.material:material-preference:2.0.0'
// https://coil-kt.github.io/coil/changelog/
// implementation 'io.coil-kt:coil:2.2.2'
implementation 'com.github.Ehviewer-Overhauled.coil:coil:d65881d'
implementation 'com.github.Ehviewer-Overhauled.coil:coil-compose:d65881d'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
implementation 'org.jsoup:jsoup:1.15.3'
}
@@ -268,6 +268,7 @@ class EhApplication : Application(), DefaultLifecycleObserver, ImageLoaderFactor
fetcherDispatcher(Dispatchers.IO.limitedParallelism(8))
decoderDispatcher(Dispatchers.IO.limitedParallelism(2))
transformationDispatcher(Dispatchers.IO.limitedParallelism(2))
crossfade(true)
}.build()
}
@@ -768,7 +768,7 @@ class GalleryDetailScene : CollapsingToolbarScene(), View.OnClickListener, Downl
return
}
try {
val path = imageLoader(context).diskCache!![EhCacheKeyFactory.getThumbKey(gid)]!!.data
val path = imageLoader(context).diskCache!![mGalleryInfo!!.thumb!!]!!.data
val lub = ListUrlBuilder()
lub.mode = ListUrlBuilder.MODE_IMAGE_SEARCH
lub.imagePath = path.toString()
@@ -1,18 +1,27 @@
package com.hippo.ehviewer.ui.scene.history
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Card
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
@@ -26,17 +35,28 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.cachedIn
import androidx.paging.compose.collectAsLazyPagingItems
import androidx.paging.compose.items
import coil.compose.AsyncImage
import com.hippo.ehviewer.EhDB
import com.hippo.ehviewer.R
import com.hippo.ehviewer.Settings
import com.hippo.ehviewer.client.EhUtils
import com.hippo.ehviewer.client.data.GalleryInfo
import com.hippo.ehviewer.widget.SimpleRatingView
import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.system.pxToDp
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@@ -75,14 +95,14 @@ fun HistoryScreen(toggleDrawer: () -> Unit) {
}
) { paddingValues ->
LazyColumn(
Modifier.padding(paddingValues)
contentPadding = paddingValues
) {
items(
items = historyData,
key = { item -> item.gid }
) {
it?.let {
Text(text = it.title!!)
InfoCard(info = it)
}
}
}
@@ -144,3 +164,93 @@ private fun NoHistory() {
)
}
}
@Composable
private fun InfoCard(info: GalleryInfo) {
OutlinedCard(
modifier = Modifier.padding(6.dp),
border = remember { BorderStroke(1.dp, Color.Transparent) }
) {
val listCardSize = remember { Settings.getListThumbSize().pxToDp }
Row(
modifier = Modifier.height((listCardSize * 3).dp)
) {
Card {
AsyncImage(
model = info.thumb,
contentDescription = "",
contentScale = ContentScale.FillHeight,
modifier = Modifier
.width((listCardSize * 2).dp)
.height((listCardSize * 3).dp)
)
}
Column(Modifier.padding(8.dp, 4.dp)) {
Text(
text = EhUtils.getSuitableTitle(info)!!,
maxLines = 2,
modifier = Modifier.fillMaxWidth(),
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.titleSmall
)
Spacer(modifier = Modifier.weight(1f))
Row(verticalAlignment = Alignment.Bottom) {
Column {
Text(
text = info.uploader ?: "(DISOWNED)",
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.labelLarge
)
AndroidView(factory = { context ->
SimpleRatingView(context).apply {
rating = info.rating
}
})
Text(
text = EhUtils.getCategory(info.category),
modifier = Modifier
.padding(2.dp)
.background(remember {
Color(
EhUtils.getCategoryColor(
info.category
)
)
})
.padding(vertical = 3.dp, horizontal = 3.dp),
color = Color.White,
textAlign = TextAlign.Center,
style = MaterialTheme.typography.labelLarge
)
}
Spacer(modifier = Modifier.weight(1f))
Column(horizontalAlignment = Alignment.End) {
Row(verticalAlignment = Alignment.CenterVertically) {
if (false) {
Icon(
painterResource(id = R.drawable.v_download_x16),
contentDescription = null
)
}
if (info.favoriteSlot != -2) {
Icon(
painterResource(id = R.drawable.v_heart_x16),
contentDescription = null
)
}
Text(
text = info.simpleLanguage.orEmpty(),
style = MaterialTheme.typography.labelLarge
)
}
Text(
text = info.posted.orEmpty(),
style = MaterialTheme.typography.labelLarge
)
}
}
}
}
}
}
@@ -135,7 +135,7 @@ open class LoadImageView @JvmOverloads constructor(
clearRetry()
task?.dispose()
mRequest =
ImageRequest.Builder(context).data(url).memoryCacheKey(key).diskCacheKey(key)
ImageRequest.Builder(context).data(url).crossfade(false)
.size(Size.ORIGINAL).target(
{ onWait() },
{ onFailure() },
@@ -81,6 +81,9 @@ val getDisplayMaxHeightInPx: Int
val Int.dpToPx: Int
get() = (this * Resources.getSystem().displayMetrics.density).toInt()
val Int.pxToDp: Float
get() = (this / Resources.getSystem().displayMetrics.density)
/**
* Converts to px and takes into account LTR/RTL layout.
*/