diff --git a/app/src/main/kotlin/com/github/skydoves/landscapistdemo/ui/MainPosters.kt b/app/src/main/kotlin/com/github/skydoves/landscapistdemo/ui/MainPosters.kt index 645fa096..f6f08a13 100644 --- a/app/src/main/kotlin/com/github/skydoves/landscapistdemo/ui/MainPosters.kt +++ b/app/src/main/kotlin/com/github/skydoves/landscapistdemo/ui/MainPosters.kt @@ -123,7 +123,7 @@ private fun PosterItem( component = rememberImageComponent { +CrossfadePlugin() }, - previewPlaceholder = R.drawable.poster, + previewPlaceholder = painterResource(id = R.drawable.poster), ) } } @@ -183,7 +183,7 @@ private fun SelectedPoster( .fillMaxWidth() .padding(8.dp) .clip(RoundedCornerShape(8.dp)), - previewPlaceholder = R.drawable.poster, + previewPlaceholder = painterResource(id = R.drawable.poster), ) Spacer(modifier = Modifier.height(12.dp)) @@ -219,6 +219,12 @@ private fun ColorPalettes(palette: Palette?) { @Composable private fun SelectedPosterPreview() { DisneyComposeTheme(darkTheme = false) { - SelectedPoster(poster = MockUtil.getMockPoster()) + Column( + modifier = Modifier + .fillMaxSize() + .verticalScroll(rememberScrollState()), + ) { + SelectedPoster(poster = MockUtil.getMockPoster()) + } } } diff --git a/benchmark-landscapist-app/src/main/kotlin/com/skydoves/benchmark/landscapist/app/CoilImageProfiles.kt b/benchmark-landscapist-app/src/main/kotlin/com/skydoves/benchmark/landscapist/app/CoilImageProfiles.kt index 4f19c701..6e20f594 100644 --- a/benchmark-landscapist-app/src/main/kotlin/com/skydoves/benchmark/landscapist/app/CoilImageProfiles.kt +++ b/benchmark-landscapist-app/src/main/kotlin/com/skydoves/benchmark/landscapist/app/CoilImageProfiles.kt @@ -18,6 +18,7 @@ package com.skydoves.benchmark.landscapist.app import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import com.skydoves.landscapist.ImageOptions import com.skydoves.landscapist.coil.CoilImage @@ -31,7 +32,7 @@ fun CoilImageProfiles() { "https://user-images.githubusercontent.com/" + "24237865/75087936-5c1d9f80-553e-11ea-81d3-a912634dd8f7.jpg" }, - previewPlaceholder = R.drawable.poster, + previewPlaceholder = painterResource(id = R.drawable.poster), component = LocalImageComponent.current, imageOptions = ImageOptions(tag = "CoilImage"), ) diff --git a/benchmark-landscapist-app/src/main/kotlin/com/skydoves/benchmark/landscapist/app/FrescoImageProfiles.kt b/benchmark-landscapist-app/src/main/kotlin/com/skydoves/benchmark/landscapist/app/FrescoImageProfiles.kt index e2de6c36..8d0d964f 100644 --- a/benchmark-landscapist-app/src/main/kotlin/com/skydoves/benchmark/landscapist/app/FrescoImageProfiles.kt +++ b/benchmark-landscapist-app/src/main/kotlin/com/skydoves/benchmark/landscapist/app/FrescoImageProfiles.kt @@ -18,6 +18,7 @@ package com.skydoves.benchmark.landscapist.app import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import com.skydoves.landscapist.ImageOptions import com.skydoves.landscapist.components.LocalImageComponent @@ -29,7 +30,7 @@ fun FrescoImageProfiles() { modifier = Modifier.size(120.dp), imageUrl = "https://user-images.githubusercontent.com/" + "24237865/75087936-5c1d9f80-553e-11ea-81d3-a912634dd8f7.jpg", - previewPlaceholder = R.drawable.poster, + previewPlaceholder = painterResource(id = R.drawable.poster), component = LocalImageComponent.current, imageOptions = ImageOptions(tag = "FrescoImage"), ) diff --git a/benchmark-landscapist-app/src/main/kotlin/com/skydoves/benchmark/landscapist/app/GlideImageProfiles.kt b/benchmark-landscapist-app/src/main/kotlin/com/skydoves/benchmark/landscapist/app/GlideImageProfiles.kt index f726b8e6..bef0657b 100644 --- a/benchmark-landscapist-app/src/main/kotlin/com/skydoves/benchmark/landscapist/app/GlideImageProfiles.kt +++ b/benchmark-landscapist-app/src/main/kotlin/com/skydoves/benchmark/landscapist/app/GlideImageProfiles.kt @@ -18,6 +18,7 @@ package com.skydoves.benchmark.landscapist.app import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import com.skydoves.landscapist.ImageOptions import com.skydoves.landscapist.components.LocalImageComponent @@ -31,7 +32,7 @@ fun GlideImageProfiles() { "https://user-images.githubusercontent.com/" + "24237865/75087936-5c1d9f80-553e-11ea-81d3-a912634dd8f7.jpg" }, - previewPlaceholder = R.drawable.poster, + previewPlaceholder = painterResource(id = R.drawable.poster), component = LocalImageComponent.current, imageOptions = ImageOptions(tag = "GlideImage"), ) diff --git a/coil/api/coil.api b/coil/api/coil.api index 28c5adf6..014615fd 100644 --- a/coil/api/coil.api +++ b/coil/api/coil.api @@ -1,6 +1,6 @@ public final class com/skydoves/landscapist/coil/CoilImage { - public static final fun CoilImage (Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lcom/skydoves/landscapist/components/ImageComponent;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function1;ILkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function5;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;II)V - public static final fun CoilImage (Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lcom/skydoves/landscapist/components/ImageComponent;Lkotlin/jvm/functions/Function0;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function1;ILkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function5;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;III)V + public static final fun CoilImage (Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lcom/skydoves/landscapist/components/ImageComponent;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/graphics/painter/Painter;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function5;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;II)V + public static final fun CoilImage (Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lcom/skydoves/landscapist/components/ImageComponent;Lkotlin/jvm/functions/Function0;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/graphics/painter/Painter;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function5;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;III)V } public abstract class com/skydoves/landscapist/coil/CoilImageState : com/skydoves/landscapist/ImageState { diff --git a/coil/src/main/kotlin/com/skydoves/landscapist/coil/CoilImage.kt b/coil/src/main/kotlin/com/skydoves/landscapist/coil/CoilImage.kt index b51480a7..07307b6c 100644 --- a/coil/src/main/kotlin/com/skydoves/landscapist/coil/CoilImage.kt +++ b/coil/src/main/kotlin/com/skydoves/landscapist/coil/CoilImage.kt @@ -36,7 +36,6 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.platform.testTag -import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.IntSize import androidx.core.graphics.drawable.toBitmap import coil.ImageLoader @@ -95,7 +94,7 @@ import java.nio.ByteBuffer * @param requestListener A class for monitoring the status of a request while images load. * @param imageOptions Represents parameters to load generic [Image] Composable. * @param onImageStateChanged An image state change listener will be triggered whenever the image state is changed. - * @param previewPlaceholder Drawable resource ID which will be displayed when this function is ran in preview mode. + * @param previewPlaceholder A painter that is specifically rendered when this function operates in preview mode. * @param loading Content to be displayed when the request is in progress. * @param success Content to be displayed when the request is succeeded. * @param failure Content to be displayed when the request is failed. @@ -109,7 +108,7 @@ public fun CoilImage( requestListener: (() -> ImageRequest.Listener)? = null, imageOptions: ImageOptions = ImageOptions(), onImageStateChanged: (CoilImageState) -> Unit = {}, - @DrawableRes previewPlaceholder: Int = 0, + previewPlaceholder: Painter? = null, loading: @Composable (BoxScope.(imageState: CoilImageState.Loading) -> Unit)? = null, success: @Composable ( BoxScope.( @@ -171,7 +170,7 @@ public fun CoilImage( * @param component An image component that conjuncts pluggable [ImagePlugin]s. * @param imageOptions Represents parameters to load generic [Image] Composable. * @param onImageStateChanged An image state change listener will be triggered whenever the image state is changed. - * @param previewPlaceholder Drawable resource ID which will be displayed when this function is ran in preview mode. + * @param previewPlaceholder A painter that is specifically rendered when this function operates in preview mode. * @param loading Content to be displayed when the request is in progress. * @param success Content to be displayed when the request is succeeded. * @param failure Content to be displayed when the request is failed. @@ -184,7 +183,7 @@ public fun CoilImage( component: ImageComponent = rememberImageComponent {}, imageOptions: ImageOptions = ImageOptions(), onImageStateChanged: (CoilImageState) -> Unit = {}, - @DrawableRes previewPlaceholder: Int = 0, + previewPlaceholder: Painter? = null, loading: @Composable (BoxScope.(imageState: CoilImageState.Loading) -> Unit)? = null, success: @Composable ( BoxScope.( @@ -194,11 +193,11 @@ public fun CoilImage( )? = null, failure: @Composable (BoxScope.(imageState: CoilImageState.Failure) -> Unit)? = null, ) { - if (LocalInspectionMode.current && previewPlaceholder != 0) { + if (LocalInspectionMode.current && previewPlaceholder != null) { with(imageOptions) { Image( modifier = modifier, - painter = painterResource(id = previewPlaceholder), + painter = previewPlaceholder, alignment = alignment, contentScale = contentScale, alpha = alpha, diff --git a/coil3/src/commonMain/kotlin/com/skydoves/landscapist/coil3/CoilImage.kt b/coil3/src/commonMain/kotlin/com/skydoves/landscapist/coil3/CoilImage.kt index 56352d56..e92c900e 100644 --- a/coil3/src/commonMain/kotlin/com/skydoves/landscapist/coil3/CoilImage.kt +++ b/coil3/src/commonMain/kotlin/com/skydoves/landscapist/coil3/CoilImage.kt @@ -79,7 +79,7 @@ import kotlinx.coroutines.flow.channelFlow * @param requestListener A class for monitoring the status of a request while images load. * @param imageOptions Represents parameters to load generic [Image] Composable. * @param onImageStateChanged An image state change listener will be triggered whenever the image state is changed. - * @param previewPlaceholder Drawable resource ID which will be displayed when this function is ran in preview mode. + * @param previewPlaceholder A painter that is specifically rendered when this function operates in preview mode. * @param loading Content to be displayed when the request is in progress. * @param success Content to be displayed when the request is succeeded. * @param failure Content to be displayed when the request is failed. @@ -149,7 +149,7 @@ public fun CoilImage( * @param component An image component that conjuncts pluggable [ImagePlugin]s. * @param imageOptions Represents parameters to load generic [Image] Composable. * @param onImageStateChanged An image state change listener will be triggered whenever the image state is changed. - * @param previewPlaceholder Drawable resource ID which will be displayed when this function is ran in preview mode. + * @param previewPlaceholder A painter that is specifically rendered when this function operates in preview mode. * @param loading Content to be displayed when the request is in progress. * @param success Content to be displayed when the request is succeeded. * @param failure Content to be displayed when the request is failed. diff --git a/fresco/api/fresco.api b/fresco/api/fresco.api index 5bc06f27..0f953f0a 100644 --- a/fresco/api/fresco.api +++ b/fresco/api/fresco.api @@ -6,7 +6,7 @@ public final class com/skydoves/landscapist/fresco/ComposableSingletons$FrescoIm } public final class com/skydoves/landscapist/fresco/FrescoImage { - public static final fun FrescoImage (Ljava/lang/String;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lcom/skydoves/landscapist/components/ImageComponent;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function1;ILkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function5;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;II)V + public static final fun FrescoImage (Ljava/lang/String;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function2;Lcom/skydoves/landscapist/components/ImageComponent;Lcom/skydoves/landscapist/ImageOptions;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/graphics/painter/Painter;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function5;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;II)V } public abstract class com/skydoves/landscapist/fresco/FrescoImageState : com/skydoves/landscapist/ImageState { diff --git a/fresco/src/main/kotlin/com/skydoves/landscapist/fresco/FrescoImage.kt b/fresco/src/main/kotlin/com/skydoves/landscapist/fresco/FrescoImage.kt index bf96ff22..81083b00 100644 --- a/fresco/src/main/kotlin/com/skydoves/landscapist/fresco/FrescoImage.kt +++ b/fresco/src/main/kotlin/com/skydoves/landscapist/fresco/FrescoImage.kt @@ -19,7 +19,6 @@ package com.skydoves.landscapist.fresco -import androidx.annotation.DrawableRes import androidx.compose.foundation.Image import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.BoxWithConstraintsScope @@ -30,7 +29,6 @@ import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.platform.testTag -import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.IntSize import com.facebook.common.executors.CallerThreadExecutor import com.facebook.drawee.backends.pipeline.info.ImageOriginRequestListener @@ -80,7 +78,7 @@ import kotlinx.coroutines.suspendCancellableCoroutine * @param success Content to be displayed when the request is succeeded. * @param failure Content to be displayed when the request is failed. * @param onImageStateChanged An image state change listener will be triggered whenever the image state is changed.ΓΈ - * @param previewPlaceholder Drawable resource ID which will be displayed when this function is ran in preview mode. + * @param previewPlaceholder A painter that is specifically rendered when this function operates in preview mode. */ @Composable public fun FrescoImage( @@ -92,7 +90,7 @@ public fun FrescoImage( component: ImageComponent = rememberImageComponent {}, imageOptions: ImageOptions = ImageOptions(), onImageStateChanged: (FrescoImageState) -> Unit = {}, - @DrawableRes previewPlaceholder: Int = 0, + previewPlaceholder: Painter? = null, loading: @Composable (BoxScope.(imageState: FrescoImageState.Loading) -> Unit)? = null, success: @Composable ( BoxScope.( @@ -102,11 +100,11 @@ public fun FrescoImage( )? = null, failure: @Composable (BoxScope.(imageState: FrescoImageState.Failure) -> Unit)? = null, ) { - if (LocalInspectionMode.current && previewPlaceholder != 0) { + if (LocalInspectionMode.current && previewPlaceholder != null) { with(imageOptions) { Image( modifier = modifier, - painter = painterResource(id = previewPlaceholder), + painter = previewPlaceholder, alignment = alignment, contentScale = contentScale, alpha = alpha, diff --git a/glide/api/glide.api b/glide/api/glide.api index 6eb678e9..0c453baa 100644 --- a/glide/api/glide.api +++ b/glide/api/glide.api @@ -6,7 +6,7 @@ public final class com/skydoves/landscapist/glide/ComposableSingletons$GlideImag } public final class com/skydoves/landscapist/glide/GlideImage { - public static final fun GlideImage (Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/glide/GlideRequestType;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function0;Lcom/skydoves/landscapist/components/ImageComponent;Lcom/skydoves/landscapist/ImageOptions;ZLkotlin/jvm/functions/Function1;ILkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function5;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;III)V + public static final fun GlideImage (Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;Lcom/skydoves/landscapist/glide/GlideRequestType;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function0;Lcom/skydoves/landscapist/components/ImageComponent;Lcom/skydoves/landscapist/ImageOptions;ZLkotlin/jvm/functions/Function1;Landroidx/compose/ui/graphics/painter/Painter;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function5;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;III)V } public abstract class com/skydoves/landscapist/glide/GlideImageState : com/skydoves/landscapist/ImageState { diff --git a/glide/src/main/kotlin/com/skydoves/landscapist/glide/GlideImage.kt b/glide/src/main/kotlin/com/skydoves/landscapist/glide/GlideImage.kt index 3226ad86..55e91c46 100644 --- a/glide/src/main/kotlin/com/skydoves/landscapist/glide/GlideImage.kt +++ b/glide/src/main/kotlin/com/skydoves/landscapist/glide/GlideImage.kt @@ -21,7 +21,6 @@ package com.skydoves.landscapist.glide import android.graphics.Bitmap import android.graphics.drawable.Drawable -import androidx.annotation.DrawableRes import androidx.compose.foundation.Image import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.BoxWithConstraintsScope @@ -30,7 +29,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.platform.testTag -import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.IntSize import com.bumptech.glide.RequestBuilder import com.bumptech.glide.RequestManager @@ -92,7 +90,7 @@ import kotlinx.coroutines.flow.callbackFlow * @param imageOptions Represents parameters to load generic [Image] Composable. * @param clearTarget Whether clear the target or not. * @param onImageStateChanged An image state change listener will be triggered whenever the image state is changed. - * @param previewPlaceholder Drawable resource ID which will be displayed when this function is ran in preview mode. + * @param previewPlaceholder A painter that is specifically rendered when this function operates in preview mode. * @param loading Content to be displayed when the request is in progress. * @param success Content to be displayed when the request is succeeded. * @param failure Content to be displayed when the request is failed. @@ -113,7 +111,7 @@ public fun GlideImage( imageOptions: ImageOptions = ImageOptions(), clearTarget: Boolean = false, onImageStateChanged: (GlideImageState) -> Unit = {}, - @DrawableRes previewPlaceholder: Int = 0, + previewPlaceholder: Painter? = null, loading: @Composable (BoxScope.(imageState: GlideImageState.Loading) -> Unit)? = null, success: @Composable ( BoxScope.( @@ -123,11 +121,11 @@ public fun GlideImage( )? = null, failure: @Composable (BoxScope.(imageState: GlideImageState.Failure) -> Unit)? = null, ) { - if (LocalInspectionMode.current && previewPlaceholder != 0) { + if (LocalInspectionMode.current && previewPlaceholder != null) { with(imageOptions) { Image( modifier = modifier, - painter = painterResource(id = previewPlaceholder), + painter = previewPlaceholder, alignment = alignment, contentScale = contentScale, alpha = alpha,