react-native-camera-kit
Advanced tools
Comparing version 8.0.0 to 8.0.1
@@ -10,3 +10,3 @@ { | ||
}, | ||
"version": "8.0.0", | ||
"version": "8.0.1", | ||
"description": "Advanced native camera control with pre-defined aspect ratio, crop, etc", | ||
@@ -13,0 +13,0 @@ "author": "Ran Greenberg <rang@wix.com>", |
@@ -139,2 +139,10 @@ | ||
#### setTorchMode - must have the wanted camera capture reference | ||
Set Torch mode (`on`/`off`) | ||
```js | ||
const success = await this.camera.setTorchMode(newTorchMode); | ||
``` | ||
#### changeCamera - must have the wanted camera capture reference | ||
@@ -141,0 +149,0 @@ |
@@ -11,2 +11,4 @@ import * as _ from 'lodash'; | ||
const NativeCameraModule = NativeModules.CameraModule; | ||
const TORCH_MODE_ON = 'on'; | ||
const TORCH_MODE_CALL_ARG = 'torch'; | ||
@@ -43,2 +45,9 @@ export default class CameraKitCamera extends React.Component { | ||
async setTorchMode(torchMode) { | ||
if (torchMode == TORCH_MODE_ON){ | ||
return await NativeCameraModule.setFlashMode(TORCH_MODE_CALL_ARG); | ||
} | ||
return await NativeCameraModule.setFlashMode(torchMode); | ||
} | ||
async setFlashMode(flashMode = 'auto') { | ||
@@ -45,0 +54,0 @@ return await NativeCameraModule.setFlashMode(flashMode); |
@@ -40,2 +40,6 @@ import * as _ from 'lodash'; | ||
} | ||
async setTorchMode(torchMode = '') { | ||
return await NativeCameraAction.setTorchMode(torchMode); | ||
} | ||
} |
@@ -23,2 +23,4 @@ import PropTypes from 'prop-types'; | ||
const FLASH_MODE_OFF = 'off'; | ||
const TORCH_MODE_ON = 'on'; | ||
const TORCH_MODE_OFF = 'off'; | ||
const OVERLAY_DEFAULT_COLOR = '#ffffff77'; | ||
@@ -57,2 +59,3 @@ const OFFSET_FRAME = 30; | ||
flashData: this.flashArray[this.currentFlashArrayPosition], | ||
torchData: false, | ||
ratios: [], | ||
@@ -66,2 +69,3 @@ cameraOptions: {}, | ||
this.onSetFlash = this.onSetFlash.bind(this); | ||
this.onSetTorch = this.onSetTorch.bind(this); | ||
this.onSwitchCameraPressed = this.onSwitchCameraPressed.bind(this); | ||
@@ -295,2 +299,8 @@ } | ||
async onSetTorch() { | ||
const newTorchData = !this.state.torchData; | ||
this.setState({ torchData: newTorchData }); | ||
newTorchData ? this.camera.setTorchMode(TORCH_MODE_ON) : this.camera.setTorchMode(TORCH_MODE_OFF); | ||
} | ||
async onCaptureImagePressed() { | ||
@@ -297,0 +307,0 @@ const shouldSaveToCameraRoll = !this.props.allowCaptureRetake; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
446855
777
260