Skip to content

Custom image loadersΒΆ

In its essence, ZoomableImage is simply an abstraction over an image loading library. If your preferred library isn't supported by telephoto out of the box, you can create your own by extending ZoomableImageSource.

@Composable
fun ZoomablePicassoImage(
  model: Any?,
  contentDescription: String?,
) {
  ZoomableImage(
    image = ZoomableImageSource.picasso(model),
    contentDescription = contentDescription,
  )
}

@Composable
private fun ZoomableImageSource.Companion.picasso(
  model: Any?,
  picasso: Picasso = Picasso
    .Builder(LocalContext.current)
    .build(),
): ZoomableImageSource {
  return remember(model, picasso) {
    TODO("See ZoomableImageSource.coil() or glide() for an example.")
  }
}

ZoomableImageSource.picasso() will be responsible for loading images and determining whether they can be displayed as-is or should be presented in a sub-sampled image viewer to prevent OOM errors. Here are two examples: