Implement zoom mode toggle for Android

This commit is contained in:
aarongrider 2021-01-05 15:39:04 -08:00
parent 7dafa09114
commit 2594fd4f03
2 changed files with 3 additions and 10 deletions

View File

@ -56,7 +56,7 @@ import { Camera } from 'react-native-camera-kit';
```jsx ```jsx
<Camera <Camera
ref={(ref) => this.camera = ref} ref={(ref) => (this.camera = ref)}
type={CameraType.Back} // front/back(default) type={CameraType.Back} // front/back(default)
style={{ flex: 1 }} style={{ flex: 1 }}
/> />
@ -68,7 +68,7 @@ import { Camera } from 'react-native-camera-kit';
| ------------------------------ | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ------------------------------ | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `flashMode` | `'on'`/`'off'`/`'auto'` | Camera flash mode. Default: `auto` | | `flashMode` | `'on'`/`'off'`/`'auto'` | Camera flash mode. Default: `auto` |
| `focusMode` | `'on'`/`'off'` | Camera focus mode. Default: `on` | | `focusMode` | `'on'`/`'off'` | Camera focus mode. Default: `on` |
| `zoomMode` | `'on'`/`'off'` | iOS only. Enable pinch to zoom camera. Default: `on` | | `zoomMode` | `'on'`/`'off'` | Enable pinch to zoom camera. Default: `on` |
| `ratioOverlay` | `['int':'int', ...]` | Show a guiding overlay in the camera preview for the selected ratio. Does not crop image as of v9.0. Example: `['16:9', '1:1', '3:4']` | | `ratioOverlay` | `['int':'int', ...]` | Show a guiding overlay in the camera preview for the selected ratio. Does not crop image as of v9.0. Example: `['16:9', '1:1', '3:4']` |
| `ratioOverlayColor` | Color | Any color with alpha. Default: `'#ffffff77'` | | `ratioOverlayColor` | Color | Any color with alpha. Default: `'#ffffff77'` |
| `resetFocusTimeout` | Number | iOS only. Dismiss tap to focus after this many milliseconds. Default `0` (disabled). Example: `5000` is 5 seconds. | | `resetFocusTimeout` | Number | iOS only. Dismiss tap to focus after this many milliseconds. Default `0` (disabled). Example: `5000` is 5 seconds. |

View File

@ -134,6 +134,7 @@ class CKCamera(context: ThemedReactContext) : FrameLayout(context), LifecycleObs
val onScaleGestureListener = object: ScaleGestureDetector.SimpleOnScaleGestureListener() { val onScaleGestureListener = object: ScaleGestureDetector.SimpleOnScaleGestureListener() {
override fun onScale(detector: ScaleGestureDetector?): Boolean { override fun onScale(detector: ScaleGestureDetector?): Boolean {
if (zoomMode == "off") return true
val cameraControl = camera?.cameraControl ?: return true val cameraControl = camera?.cameraControl ?: return true
val zoom = camera?.cameraInfo?.zoomState?.value?.zoomRatio ?: return true val zoom = camera?.cameraInfo?.zoomState?.value?.zoomRatio ?: return true
val scaleFactor = detector?.scaleFactor ?: return true val scaleFactor = detector?.scaleFactor ?: return true
@ -386,14 +387,6 @@ class CKCamera(context: ThemedReactContext) : FrameLayout(context), LifecycleObs
fun setZoomMode(mode: String = "on") { fun setZoomMode(mode: String = "on") {
zoomMode = mode zoomMode = mode
when(mode) {
"on" -> {
// TODO: Add gesture detector
}
"off" -> {
// TODO: Remove gesture detector
}
}
} }
fun setScanBarcode(enabled: Boolean) { fun setScanBarcode(enabled: Boolean) {