Migrate to coil3

This commit is contained in:
Benoit Marty
2025-03-03 12:30:17 +01:00
parent f2a7e5d538
commit 3a09d1c4ca
43 changed files with 148 additions and 117 deletions

View File

@@ -11,6 +11,7 @@ import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
@@ -22,9 +23,10 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImagePainter
import coil.compose.rememberAsyncImagePainter
import coil.request.ImageRequest
import coil3.Extras
import coil3.compose.AsyncImagePainter
import coil3.compose.rememberAsyncImagePainter
import coil3.request.ImageRequest
import io.element.android.compound.theme.ElementTheme
import io.element.android.features.location.api.internal.StaticMapPlaceholder
import io.element.android.features.location.api.internal.StaticMapUrlBuilder
@@ -33,7 +35,6 @@ import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import io.element.android.libraries.designsystem.theme.components.Icon
import io.element.android.libraries.designsystem.utils.CommonDrawables
import timber.log.Timber
/**
* Shows a static map image downloaded via a third party service's static maps API.
@@ -75,14 +76,15 @@ fun StaticMapView(
)
)
.size(width = constraints.maxWidth, height = constraints.maxHeight)
.setParameter("retry_hash", retryHash, memoryCacheKey = null)
.apply {
extras.set(Extras.Key("retry_hash"), retryHash).build()
}
.build()
}.apply {
Timber.d("Static map image request: ${this?.data}")
}
)
if (painter.state is AsyncImagePainter.State.Success) {
val collectedState = painter.state.collectAsState()
if (collectedState.value is AsyncImagePainter.State.Success) {
Image(
painter = painter,
contentDescription = contentDescription,
@@ -100,7 +102,7 @@ fun StaticMapView(
)
} else {
StaticMapPlaceholder(
showProgress = painter.state is AsyncImagePainter.State.Loading,
showProgress = collectedState.value is AsyncImagePainter.State.Loading,
contentDescription = contentDescription,
width = maxWidth,
height = maxHeight,