Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mr-pine/zoomables

Easy to use libraries for Android and Jetpack Compose
https://github.com/mr-pine/zoomables

Last synced: 11 days ago
JSON representation

Easy to use libraries for Android and Jetpack Compose

Awesome Lists containing this project

README

        

# Zoomables

[![MavenCentral](https://maven-badges.herokuapp.com/maven-central/de.mr-pine.utils/zoomables/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/de.mr-pine.utils/zoomables)

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](https://github.com/Mr-Pine/AndroidUtilityLibraries/issues/new/choose)

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

![](Zoom_comparison.gif)

## 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](https://maven-badges.herokuapp.com/maven-central/de.mr-pine.utils/zoomables/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/de.mr-pine.utils/zoomables)

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

Zoomable Image:
```kt
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:
```kt
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 */
}
```