Implement zoom mode toggle for Android
This commit is contained in:
parent
7dafa09114
commit
2594fd4f03
|
@ -56,7 +56,7 @@ import { Camera } from 'react-native-camera-kit';
|
|||
|
||||
```jsx
|
||||
<Camera
|
||||
ref={(ref) => this.camera = ref}
|
||||
ref={(ref) => (this.camera = ref)}
|
||||
type={CameraType.Back} // front/back(default)
|
||||
style={{ flex: 1 }}
|
||||
/>
|
||||
|
@ -68,7 +68,7 @@ import { Camera } from 'react-native-camera-kit';
|
|||
| ------------------------------ | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `flashMode` | `'on'`/`'off'`/`'auto'` | Camera flash mode. Default: `auto` |
|
||||
| `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']` |
|
||||
| `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. |
|
||||
|
|
|
@ -134,6 +134,7 @@ class CKCamera(context: ThemedReactContext) : FrameLayout(context), LifecycleObs
|
|||
|
||||
val onScaleGestureListener = object: ScaleGestureDetector.SimpleOnScaleGestureListener() {
|
||||
override fun onScale(detector: ScaleGestureDetector?): Boolean {
|
||||
if (zoomMode == "off") return true
|
||||
val cameraControl = camera?.cameraControl ?: return true
|
||||
val zoom = camera?.cameraInfo?.zoomState?.value?.zoomRatio ?: return true
|
||||
val scaleFactor = detector?.scaleFactor ?: return true
|
||||
|
@ -386,14 +387,6 @@ class CKCamera(context: ThemedReactContext) : FrameLayout(context), LifecycleObs
|
|||
|
||||
fun setZoomMode(mode: String = "on") {
|
||||
zoomMode = mode
|
||||
when(mode) {
|
||||
"on" -> {
|
||||
// TODO: Add gesture detector
|
||||
}
|
||||
"off" -> {
|
||||
// TODO: Remove gesture detector
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setScanBarcode(enabled: Boolean) {
|
||||
|
|
Loading…
Reference in New Issue