From e82ca3ffe591d984f9b30c4d4d3e96aa4abf474a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 3 Mar 2025 15:52:30 +0100 Subject: [PATCH] Coil3: also show the loader when the request is not yet started (State.Empty) --- .../element/android/features/location/api/StaticMapView.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/features/location/api/src/main/kotlin/io/element/android/features/location/api/StaticMapView.kt b/features/location/api/src/main/kotlin/io/element/android/features/location/api/StaticMapView.kt index aab4adce6f..8065164ad7 100644 --- a/features/location/api/src/main/kotlin/io/element/android/features/location/api/StaticMapView.kt +++ b/features/location/api/src/main/kotlin/io/element/android/features/location/api/StaticMapView.kt @@ -102,7 +102,7 @@ fun StaticMapView( ) } else { StaticMapPlaceholder( - showProgress = collectedState.value is AsyncImagePainter.State.Loading, + showProgress = collectedState.value.isLoading(), contentDescription = contentDescription, width = maxWidth, height = maxHeight, @@ -112,6 +112,11 @@ fun StaticMapView( } } +private fun AsyncImagePainter.State.isLoading(): Boolean { + return this is AsyncImagePainter.State.Empty || + this is AsyncImagePainter.State.Loading +} + @PreviewsDayNight @Composable internal fun StaticMapViewPreview() = ElementPreview {