GlideImage composable in Landscapist library missing some parameters

2k Views Asked by At

The GlideImage composable in the Landscapist image loading library for Compose is missing the loading, success, and failure parameters, but the GitHub Readme for the library states these parameters are available. Android Studio just throws a compile time error. Do I have to implement them differently with this library?

GlideImage(
  imageModel = imageUrl,
  modifier = modifier,
  // Throws compiler error here
  loading = {
    Box(modifier = Modifier.matchParentSize()) {
      CircularProgressIndicator(
        modifier = Modifier.align(Alignment.Center)
      )
    }
  }
)
1

There are 1 best solutions below

5
On

I try replicate but works for me. I using version 1.4.9 of Glide. You can try implement success and failure too.

GlideImage(
     modifier = Modifier
         .size(40.dp)
         .background(Color.Green),
     imageModel = "https://yt3.ggpht.com/ytc/AMLnZu-v-ApUfdP0KinqrJQyNYP5BVd1ke0C7HsoTtkH=s900-c-k-c0x00ffffff-no-rj",
      success = {
         Image(
              painter = rememberDrawablePainter(drawable = it.drawable),
              contentDescription = null
         )
      },
      failure = {
         Image(
             painter = rememberDrawablePainter(drawable = it.errorDrawable),
             contentDescription = null
         )
      },
      loading = {
         Box(modifier = Modifier.matchParentSize()) {
             CircularProgressIndicator(
                  modifier = Modifier.align(Alignment.Center),
                  progress = it.progress
             )
       }
   }
)