This commit is contained in:
tom5079
2024-03-24 22:56:24 -07:00
parent e648b6dfee
commit e8ba5c4881
3 changed files with 55 additions and 29 deletions

View File

@@ -217,6 +217,7 @@ class Pupil : Application(), ImageLoaderFactory {
.Builder() .Builder()
.sslSocketFactory(SSLSettings.sslContext!!.socketFactory, SSLSettings.trustManager!!) .sslSocketFactory(SSLSettings.sslContext!!.socketFactory, SSLSettings.trustManager!!)
.build() .build()
}.build() }.memoryCache(null)
.build()
} }

View File

@@ -248,22 +248,35 @@ fun TagGroup(tags: List<GalleryTag>) {
@Composable @Composable
fun DetailedGalleryInfoHeader(galleryInfo: GalleryInfo, thumbnailUrl: String?) { fun DetailedGalleryInfoHeader(galleryInfo: GalleryInfo, thumbnailUrl: String?) {
val thumbnailFile = galleryInfo.files.firstOrNull() val thumbnailFile = galleryInfo.files.first()
if (thumbnailFile?.let { it.width > it.height } == true) { val aspectRatio = thumbnailFile.let { it.width / it.height.toFloat() }
if (thumbnailFile.let { it.width > it.height }) {
Column { Column {
SubcomposeAsyncImage( if (thumbnailUrl != null) {
model = ImageRequest.Builder(LocalContext.current) SubcomposeAsyncImage(
.data(thumbnailUrl) model = ImageRequest.Builder(LocalContext.current)
.setHeader("Referer", "https://hitomi.la/") .data(thumbnailUrl)
.build(), .setHeader("Referer", "https://hitomi.la/")
modifier = Modifier .build(),
.fillMaxWidth() modifier = Modifier
.aspectRatio(thumbnailFile.let { it.width / it.height.toFloat() }) .fillMaxWidth()
.clip(RoundedCornerShape(8.dp)), .aspectRatio(aspectRatio)
loading = { CircularProgressIndicator() }, .clip(RoundedCornerShape(8.dp)),
error = { Image(painter= painterResource(R.drawable.thumbnail), contentDescription = null) }, loading = { CircularProgressIndicator(Modifier.size(32.dp)) },
contentDescription = "Thumbnail" error = {
) Image(
painter = painterResource(R.drawable.thumbnail),
contentDescription = null
)
},
contentDescription = "Thumbnail"
)
} else {
Box(Modifier.fillMaxWidth().aspectRatio(aspectRatio)) {
CircularProgressIndicator(Modifier.size(32.dp))
}
}
Text(galleryInfo.title, style = MaterialTheme.typography.headlineSmall) Text(galleryInfo.title, style = MaterialTheme.typography.headlineSmall)
val artistsAndGroups = buildString { val artistsAndGroups = buildString {
if (!galleryInfo.artists.isNullOrEmpty()) if (!galleryInfo.artists.isNullOrEmpty())
@@ -307,18 +320,30 @@ fun DetailedGalleryInfoHeader(galleryInfo: GalleryInfo, thumbnailUrl: String?) {
horizontalArrangement = Arrangement.spacedBy(4.dp), horizontalArrangement = Arrangement.spacedBy(4.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
SubcomposeAsyncImage( if (thumbnailUrl != null) {
model = ImageRequest.Builder(LocalContext.current) SubcomposeAsyncImage(
.data(thumbnailUrl) model = ImageRequest.Builder(LocalContext.current)
.setHeader("Referer", "https://hitomi.la/") .data(thumbnailUrl)
.build(), .setHeader("Referer", "https://hitomi.la/")
modifier = Modifier .build(),
.height(200.dp) modifier = Modifier
.clip(RoundedCornerShape(8.dp)), .height(200.dp)
loading = { CircularProgressIndicator() }, .aspectRatio(aspectRatio)
error = { Image(painter= painterResource(R.drawable.thumbnail), contentDescription = null) }, .clip(RoundedCornerShape(8.dp)),
contentDescription = "Thumbnail" loading = { CircularProgressIndicator(Modifier.size(32.dp)) },
) error = {
Image(
painter = painterResource(R.drawable.thumbnail),
contentDescription = null
)
},
contentDescription = "Thumbnail"
)
} else {
Box(Modifier.height(200.dp).aspectRatio(aspectRatio)) {
CircularProgressIndicator(Modifier.size(32.dp))
}
}
Column(Modifier.heightIn(min = 200.dp)) { Column(Modifier.heightIn(min = 200.dp)) {
Text(galleryInfo.title, style = MaterialTheme.typography.headlineSmall) Text(galleryInfo.title, style = MaterialTheme.typography.headlineSmall)
val artistsAndGroups = buildString { val artistsAndGroups = buildString {

View File

@@ -443,7 +443,7 @@ fun MainScreen(
loadSearchResult(pageToRange(page)) loadSearchResult(pageToRange(page))
}} }}
LaunchedEffect(Unit) { loadSearchResult(pageToRange(0)) } LaunchedEffect(uiState.query, uiState.currentDestination) { loadSearchResult(pageToRange(0)) }
if (contentType == ContentType.DUAL_PANE) { if (contentType == ContentType.DUAL_PANE) {
TwoPane( TwoPane(