Updated docs.

This commit is contained in:
Lochlan Wansbrough 2016-01-31 19:46:33 -08:00
parent 84809401a5
commit 8f9fd98496
2 changed files with 39 additions and 43 deletions

View File

@ -214,17 +214,9 @@ Values:
Use the `torchMode` property to specify the camera torch mode. Use the `torchMode` property to specify the camera torch mode.
#### `onFocusChanged` #### `onFocusChanged: Event { nativeEvent: { touchPoint: { x, y } }`
Args: Called when a touch focus gesture has been made.
```
e: {
nativeEvent: {
touchPoint: { x, y }
}
}
```
Will call when touch to focus has been made.
By default, `onFocusChanged` is not defined and tap-to-focus is disabled. By default, `onFocusChanged` is not defined and tap-to-focus is disabled.
#### `defaultOnFocusComponent` #### `defaultOnFocusComponent`
@ -235,20 +227,12 @@ Values:
If `defaultOnFocusComponent` set to false, default internal implementation of visual feedback for tap-to-focus gesture will be disabled. If `defaultOnFocusComponent` set to false, default internal implementation of visual feedback for tap-to-focus gesture will be disabled.
#### `onZoomChanged` #### `onZoomChanged: Event { nativeEvent: { velocity, zoomFactor } }`
Args: Called when focus has changed.
```
e: {
nativeEvent: {
velocity, zoomFactor
}
}
```
Will call when focus has changed.
By default, `onZoomChanged` is not defined and pinch-to-zoom is disabled. By default, `onZoomChanged` is not defined and pinch-to-zoom is disabled.
## Component methods ## Component instance methods
You can access component methods by adding a `ref` (ie. `ref="camera"`) prop to your `<Camera>` element, then you can use `this.refs.camera.capture(cb)`, etc. inside your component. You can access component methods by adding a `ref` (ie. `ref="camera"`) prop to your `<Camera>` element, then you can use `this.refs.camera.capture(cb)`, etc. inside your component.
@ -265,11 +249,21 @@ Supported options:
- `location` This is the object returned from `navigator.geolocation.getCurrentPosition()` (React Native's geolocation polyfill). It will add GPS metadata to the image. - `location` This is the object returned from `navigator.geolocation.getCurrentPosition()` (React Native's geolocation polyfill). It will add GPS metadata to the image.
- `rotation` This will rotate the image by the number of degrees specified. - `rotation` This will rotate the image by the number of degrees specified.
#### `iOS` `getFOV(): Promise`
Returns the camera's current field of view.
#### `iOS` `hasFlash(): Promise`
Returns whether or not the camera has flash capabilities.
#### `stopCapture()` #### `stopCapture()`
Ends the current capture session for video captures. Only applies when the current `captureMode` is `video`. Ends the current capture session for video captures. Only applies when the current `captureMode` is `video`.
#### `checkDeviceAuthorizationStatus(): Promise` ## Component static methods
#### `Camera.checkDeviceAuthorizationStatus(): Promise`
Exposes the native API for checking if the device has authorized access to the camera. Can be used to call before loading the Camera component to ensure proper UX. The promise will be fulfilled with `true` or `false` depending on whether the device is authorized. Exposes the native API for checking if the device has authorized access to the camera. Can be used to call before loading the Camera component to ensure proper UX. The promise will be fulfilled with `true` or `false` depending on whether the device is authorized.

View File

@ -62,36 +62,38 @@ export default class Camera extends Component {
PropTypes.string, PropTypes.string,
PropTypes.number PropTypes.number
]), ]),
type: PropTypes.oneOfType([ defaultOnFocusComponent: PropTypes.bool,
PropTypes.string,
PropTypes.number
]),
orientation: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]),
flashMode: PropTypes.oneOfType([ flashMode: PropTypes.oneOfType([
PropTypes.string, PropTypes.string,
PropTypes.number PropTypes.number
]), ]),
onBarCodeRead: PropTypes.func,
onFocusChanged: PropTypes.func,
onZoomChanged: PropTypes.func
orientation: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]),
torchMode: PropTypes.oneOfType([ torchMode: PropTypes.oneOfType([
PropTypes.string, PropTypes.string,
PropTypes.number PropTypes.number
]), ]),
onBarCodeRead: PropTypes.func, type: PropTypes.oneOfType([
onFocusChanged: PropTypes.func, PropTypes.string,
onZoomChanged: PropTypes.func PropTypes.number
])
}; };
static defaultProps = { static defaultProps = {
aspect: constants.Aspect.fill, aspect: Camera.constants.Aspect.fill,
type: constants.Type.back, type: Camera.constants.Type.back,
orientation: constants.Orientation.auto, orientation: Camera.constants.Orientation.auto,
captureAudio: true, captureAudio: true,
captureMode: constants.CaptureMode.still, captureMode: Camera.constants.CaptureMode.still,
captureTarget: constants.CaptureTarget.cameraRoll, captureTarget: Camera.constants.CaptureTarget.cameraRoll,
flashMode: constants.FlashMode.off, defaultOnFocusComponent: true,
torchMode: constants.TorchMode.off, flashMode: Camera.constants.FlashMode.off,
torchMode: Camera.constants.TorchMode.off,
onBarCodeRead: () => {}, onBarCodeRead: () => {},
onFocusChanged: () => {}, onFocusChanged: () => {},
onZoomChanged: () => {} onZoomChanged: () => {}
@ -108,7 +110,7 @@ export default class Camera extends Component {
this.state = { this.state = {
isAuthorized: false, isAuthorized: false,
isRecording: false isRecording: false
} };
} }
async componentWillMount() { async componentWillMount() {
@ -167,8 +169,8 @@ export default class Camera extends Component {
} }
}); });
const RCTCamera = requireNativeComponent('RCTCamera', Camera); var RCTCamera = requireNativeComponent('RCTCamera', Camera);
const styles = StyleSheet.create({ var styles = StyleSheet.create({
base: {}, base: {},
}); });