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,9 +248,12 @@ 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 {
if (thumbnailUrl != null) {
SubcomposeAsyncImage( SubcomposeAsyncImage(
model = ImageRequest.Builder(LocalContext.current) model = ImageRequest.Builder(LocalContext.current)
.data(thumbnailUrl) .data(thumbnailUrl)
@@ -258,12 +261,22 @@ fun DetailedGalleryInfoHeader(galleryInfo: GalleryInfo, thumbnailUrl: String?) {
.build(), .build(),
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.aspectRatio(thumbnailFile.let { it.width / it.height.toFloat() }) .aspectRatio(aspectRatio)
.clip(RoundedCornerShape(8.dp)), .clip(RoundedCornerShape(8.dp)),
loading = { CircularProgressIndicator() }, loading = { CircularProgressIndicator(Modifier.size(32.dp)) },
error = { Image(painter= painterResource(R.drawable.thumbnail), contentDescription = null) }, error = {
Image(
painter = painterResource(R.drawable.thumbnail),
contentDescription = null
)
},
contentDescription = "Thumbnail" 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,6 +320,7 @@ fun DetailedGalleryInfoHeader(galleryInfo: GalleryInfo, thumbnailUrl: String?) {
horizontalArrangement = Arrangement.spacedBy(4.dp), horizontalArrangement = Arrangement.spacedBy(4.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
if (thumbnailUrl != null) {
SubcomposeAsyncImage( SubcomposeAsyncImage(
model = ImageRequest.Builder(LocalContext.current) model = ImageRequest.Builder(LocalContext.current)
.data(thumbnailUrl) .data(thumbnailUrl)
@@ -314,11 +328,22 @@ fun DetailedGalleryInfoHeader(galleryInfo: GalleryInfo, thumbnailUrl: String?) {
.build(), .build(),
modifier = Modifier modifier = Modifier
.height(200.dp) .height(200.dp)
.aspectRatio(aspectRatio)
.clip(RoundedCornerShape(8.dp)), .clip(RoundedCornerShape(8.dp)),
loading = { CircularProgressIndicator() }, loading = { CircularProgressIndicator(Modifier.size(32.dp)) },
error = { Image(painter= painterResource(R.drawable.thumbnail), contentDescription = null) }, error = {
Image(
painter = painterResource(R.drawable.thumbnail),
contentDescription = null
)
},
contentDescription = "Thumbnail" 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(