mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 07:29:14 +01:00
crossfade only the hero image, not the grid
This commit is contained in:
@@ -4,7 +4,6 @@ import android.app.Application
|
|||||||
import coil3.ImageLoader
|
import coil3.ImageLoader
|
||||||
import coil3.SingletonImageLoader
|
import coil3.SingletonImageLoader
|
||||||
import coil3.network.okhttp.OkHttpNetworkFetcherFactory
|
import coil3.network.okhttp.OkHttpNetworkFetcherFactory
|
||||||
import coil3.request.crossfade
|
|
||||||
import com.subtracks.di.appModule
|
import com.subtracks.di.appModule
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import org.koin.core.context.startKoin
|
import org.koin.core.context.startKoin
|
||||||
@@ -23,7 +22,6 @@ class SubtracksApp : Application() {
|
|||||||
ImageLoader
|
ImageLoader
|
||||||
.Builder(context)
|
.Builder(context)
|
||||||
.components { add(OkHttpNetworkFetcherFactory(callFactory = { http })) }
|
.components { add(OkHttpNetworkFetcherFactory(callFactory = { http })) }
|
||||||
.crossfade(150)
|
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import coil3.compose.AsyncImage
|
import coil3.compose.AsyncImage
|
||||||
import coil3.compose.LocalPlatformContext
|
import coil3.compose.LocalPlatformContext
|
||||||
import coil3.request.ImageRequest
|
import coil3.request.ImageRequest
|
||||||
|
import coil3.request.crossfade
|
||||||
import com.subtracks.data.model.CoverArtRef
|
import com.subtracks.data.model.CoverArtRef
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -37,7 +38,7 @@ fun CoverArt(
|
|||||||
)
|
)
|
||||||
if (thumbnailRef != null && thumbnailRef != ref) {
|
if (thumbnailRef != null && thumbnailRef != ref) {
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
model = remember(thumbnailRef) { imageRequest(context, thumbnailRef) },
|
model = remember(thumbnailRef) { imageRequest(context, thumbnailRef, crossfade = false) },
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
contentScale = ContentScale.Crop,
|
contentScale = ContentScale.Crop,
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
@@ -45,7 +46,7 @@ fun CoverArt(
|
|||||||
}
|
}
|
||||||
if (ref != null) {
|
if (ref != null) {
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
model = remember(ref) { imageRequest(context, ref) },
|
model = remember(ref) { imageRequest(context, ref, crossfade = thumbnailRef != null) },
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
contentScale = ContentScale.Crop,
|
contentScale = ContentScale.Crop,
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
@@ -57,12 +58,14 @@ fun CoverArt(
|
|||||||
private fun imageRequest(
|
private fun imageRequest(
|
||||||
context: Context,
|
context: Context,
|
||||||
ref: CoverArtRef,
|
ref: CoverArtRef,
|
||||||
|
crossfade: Boolean,
|
||||||
): ImageRequest =
|
): ImageRequest =
|
||||||
ImageRequest
|
ImageRequest
|
||||||
.Builder(context)
|
.Builder(context)
|
||||||
.data(ref.url)
|
.data(ref.url)
|
||||||
.memoryCacheKey(ref.cacheKey)
|
.memoryCacheKey(ref.cacheKey)
|
||||||
.diskCacheKey(ref.cacheKey)
|
.diskCacheKey(ref.cacheKey)
|
||||||
|
.crossfade(crossfade)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
Reference in New Issue
Block a user