Skip to content

Easy to use libraries for Android and Jetpack Compose

License

Notifications You must be signed in to change notification settings

Mr-Pine/Zoomables

Repository files navigation

Zoomables

MavenCentral

A Jetpack Compose Library provides Composables that handle nice and smooth zooming behaviour for you

If you have any issues or ideas how to improve any of these libraries feel free to open an issue

Show comparison

Comparison between this library and the way recommended by the Android documentation

Notice that the rotation and zoom are centered at the touch point with this library but at the center of the image with the other option

Why use this library?

  • It provides nicer zooming behaviour (see comparison)
  • Provides callback functions to handle swiping left/right on the image when not zoomed in
  • Reduces difficult to read code

What does this library provide?

  • General Composables for with zooming behaviour
  • Special Composables for Images, reducing boilerplate code even further
  • A ZoomableState

How to use this library

Import via gradle using this version number: MavenCentral

implementation "de.mr-pine.utils:zoomables:{Version number}"

Zoomable Image:

ZoomableImage(
    coroutineScope = rememberCoroutineScope(),
    zoomableState = rememberZoomableState(),
    painter = /* Painter */, //also possible with ImageVector and ImageBitmap
    onSwipeRight = {
     Toast.makeText(
         context, "Swipe right", Toast.LENGTH_LONG
     ).show()
    },
    onSwipeLeft = {
     Toast.makeText(
         context, "Swipe left", Toast.LENGTH_LONG
     ).show()
    }
)

Zoomable:

Zoomable(
    coroutineScope = rememberCoroutineScope(),
    zoomableState = rememberZoomableState(),
    onSwipeLeft = {
     Toast.makeText(
         context, "Swipe left", Toast.LENGTH_LONG
     ).show()
    },
    onSwipeRight = {
     Toast.makeText(
         context, "Swipe right", Toast.LENGTH_LONG
     ).show()
    }
) {
    /* Your Composable */
}