GlideImage

@Composable()
fun GlideImage(imageModel: Any, modifier: Modifier = Modifier, requestBuilder: RequestBuilder<Bitmap> = LocalGlideProvider.getGlideRequestBuilder(imageModel), requestOptions: RequestOptions = LocalGlideProvider.getGlideRequestOptions(), alignment: Alignment = Alignment.Center, contentScale: ContentScale = ContentScale.Crop, contentDescription: String? = null, alpha: Float = DefaultAlpha, colorFilter: ColorFilter? = null, circularRevealedEnabled: Boolean = false, circularRevealedDuration: Int = DefaultCircularRevealedDuration, placeHolder: Any? = null, error: Any? = null)

Requests loading an image with a loading placeholder and error image resource (ImageBitmap, ImageVector, Painter).

GlideImage(
imageModel = imageUrl,
requestBuilder = Glide
.with(LocalContext.current)
.asBitmap()
.apply(RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL))
.thumbnail(0.6f)
.transition(withCrossFade()),
placeHolder = ImageBitmap.imageResource(R.drawable.placeholder),
error = ImageBitmap.imageResource(R.drawable.error)
)

Parameters

imageModel

The data model to request image. See RequestBuilder.load for types allowed.

modifier

Modifier used to adjust the layout or drawing content.

requestBuilder

Most options in Glide can be applied directly on the RequestBuilder object returned by Glide.with().

requestOptions

Provides type independent options to customize loads with Glide.

alignment

The alignment parameter used to place the loaded ImageBitmap in the image container.

alpha

The alpha parameter used to apply for the image when it is rendered onscreen.

contentScale

The scale parameter used to determine the aspect ratio scaling to be used for the loaded ImageBitmap.

contentDescription

The content description used to provide accessibility to describe the image.

circularRevealedEnabled

Whether to run a circular reveal animation when images are successfully loaded.

circularRevealedDuration

The duration of the circular reveal animation.

colorFilter

The colorFilter parameter used to apply for the image when it is rendered onscreen.

placeHolder

An ImageBitmap, ImageVector, or Painter to be displayed when the request is in progress.

error

An ImageBitmap, ImageVector, or Painter for showing instead of the target image when images are failed to load.

@Composable()
fun GlideImage(imageModel: Any, modifier: Modifier = Modifier, requestBuilder: RequestBuilder<Bitmap> = LocalGlideProvider.getGlideRequestBuilder(imageModel), requestOptions: RequestOptions = LocalGlideProvider.getGlideRequestOptions(), alignment: Alignment = Alignment.Center, contentScale: ContentScale = ContentScale.Crop, contentDescription: String? = null, alpha: Float = DefaultAlpha, colorFilter: ColorFilter? = null, circularRevealedEnabled: Boolean = false, circularRevealedDuration: Int = DefaultCircularRevealedDuration, shimmerParams: ShimmerParams, error: Any? = null)

Requests loading an image with a loading placeholder and error image resource (ImageBitmap, ImageVector, Painter).

GlideImage(
imageModel = imageUrl,
requestBuilder = Glide
.with(LocalContext.current)
.asBitmap()
.apply(RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL))
.thumbnail(0.6f)
.transition(withCrossFade()),
circularRevealedEnabled = true,
shimmerParams = ShimmerParams (
baseColor = backgroundColor,
highlightColor = highlightColor
),
error = ImageVector.vectorResource(R.drawable.error)
)

Parameters

imageModel

The data model to request image. See RequestBuilder.load for types allowed.

modifier

Modifier used to adjust the layout or drawing content.

requestBuilder

Most options in Glide can be applied directly on the RequestBuilder object returned by Glide.with().

requestOptions

Provides type independent options to customize loads with Glide.

alignment

The alignment parameter used to place the loaded ImageBitmap in the image container.

alpha

The alpha parameter used to apply for the image when it is rendered onscreen.

contentScale

The scale parameter used to determine the aspect ratio scaling to be used for the loaded ImageBitmap.

contentDescription

The content description used to provide accessibility to describe the image.

circularRevealedEnabled

Whether to run a circular reveal animation when images are successfully loaded.

circularRevealedDuration

The duration of the circular reveal animation.

colorFilter

The colorFilter parameter used to apply for the image when it is rendered onscreen.

shimmerParams

The shimmer related parameter used to determine constructions of the Shimmer.

error

An ImageBitmap, ImageVector, or Painter for showing instead of the target image when images are failed to load.

@Composable()
fun GlideImage(imageModel: Any, modifier: Modifier = Modifier, requestBuilder: RequestBuilder<Bitmap> = LocalGlideProvider.getGlideRequestBuilder(imageModel), requestOptions: RequestOptions = LocalGlideProvider.getGlideRequestOptions(), alignment: Alignment = Alignment.Center, contentScale: ContentScale = ContentScale.Crop, contentDescription: String? = null, alpha: Float = DefaultAlpha, colorFilter: ColorFilter? = null, circularRevealedEnabled: Boolean = false, circularRevealedDuration: Int = DefaultCircularRevealedDuration, shimmerParams: ShimmerParams, success: @Composable() (imageState: GlideImageState.Success) -> Unit? = null, failure: @Composable() (imageState: GlideImageState.Failure) -> Unit? = null)

Requests loading an image and create some composables based on GlideImageState.

GlideImage(
imageModel = imageUrl,
requestBuilder = Glide
.with(LocalContext.current)
.asBitmap()
.apply(RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL))
.thumbnail(0.6f)
.transition(withCrossFade()),
modifier = modifier,
shimmerParams = ShimmerParams (
baseColor = backgroundColor,
highlightColor = highlightColor
),
failure = {
Text(text = "image request failed.")
})

Parameters

imageModel

The data model to request image. See RequestBuilder.load for types allowed.

modifier

Modifier used to adjust the layout or drawing content.

requestBuilder

Most options in Glide can be applied directly on the RequestBuilder object returned by Glide.with().

requestOptions

Provides type independent options to customize loads with Glide.

alignment

The alignment parameter used to place the loaded ImageBitmap in the image container.

alpha

The alpha parameter used to apply for the image when it is rendered onscreen.

contentScale

The scale parameter used to determine the aspect ratio scaling to be used for the loaded ImageBitmap.

contentDescription

The content description used to provide accessibility to describe the image.

circularRevealedEnabled

Whether to run a circular reveal animation when images are successfully loaded.

circularRevealedDuration

The duration of the circular reveal animation.

colorFilter

The colorFilter parameter used to apply for the image when it is rendered onscreen.

shimmerParams

The shimmer related parameter used to determine constructions of the Shimmer.

success

Content to be displayed when the request is succeeded.

failure

Content to be displayed when the request is failed.

@Composable()
fun GlideImage(imageModel: Any, modifier: Modifier = Modifier, requestBuilder: RequestBuilder<Bitmap> = LocalGlideProvider.getGlideRequestBuilder(imageModel), requestOptions: RequestOptions = LocalGlideProvider.getGlideRequestOptions(), alignment: Alignment = Alignment.Center, contentScale: ContentScale = ContentScale.Crop, contentDescription: String? = null, alpha: Float = DefaultAlpha, colorFilter: ColorFilter? = null, circularRevealedEnabled: Boolean = false, circularRevealedDuration: Int = DefaultCircularRevealedDuration, loading: @Composable() (imageState: GlideImageState.Loading) -> Unit? = null, success: @Composable() (imageState: GlideImageState.Success) -> Unit? = null, failure: @Composable() (imageState: GlideImageState.Failure) -> Unit? = null)

Requests loading an image and create some composables based on GlideImageState.

GlideImage(
imageModel = imageUrl,
requestBuilder = Glide
.with(LocalContext.current)
.asBitmap()
.apply(RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL))
.thumbnail(0.6f)
.transition(withCrossFade()),
modifier = modifier,
loading = {
ConstraintLayout(
modifier = Modifier.fillMaxSize()
) {
val indicator = createRef()
CircularProgressIndicator(
modifier = Modifier.constrainAs(indicator) {
top.linkTo(parent.top)
bottom.linkTo(parent.bottom)
start.linkTo(parent.start)
end.linkTo(parent.end)
}
)
}
},
failure = {
Text(text = "image request failed.")
})

Parameters

imageModel

The data model to request image. See RequestBuilder.load for types allowed.

modifier

Modifier used to adjust the layout or drawing content.

requestBuilder

Most options in Glide can be applied directly on the RequestBuilder object returned by Glide.with().

requestOptions

Provides type independent options to customize loads with Glide.

alignment

The alignment parameter used to place the loaded ImageBitmap in the image container.

alpha

The alpha parameter used to apply for the image when it is rendered onscreen.

contentScale

The scale parameter used to determine the aspect ratio scaling to be used for the loaded ImageBitmap.

contentDescription

The content description used to provide accessibility to describe the image.

circularRevealedEnabled

Whether to run a circular reveal animation when images are successfully loaded.

circularRevealedDuration

The duration of the circular reveal animation.

colorFilter

The colorFilter parameter used to apply for the image when it is rendered onscreen.

loading

Content to be displayed when the request is in progress.

success

Content to be displayed when the request is succeeded.

failure

Content to be displayed when the request is failed.