From 8f9fd98496c64843fb8cbbf6f87e456cf61d4bd6 Mon Sep 17 00:00:00 2001 From: Lochlan Wansbrough Date: Sun, 31 Jan 2016 19:46:33 -0800 Subject: [PATCH] Updated docs. --- README.md | 38 ++++++++++++++++---------------------- index.ios.js | 44 +++++++++++++++++++++++--------------------- 2 files changed, 39 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index bde659e..80bebdb 100644 --- a/README.md +++ b/README.md @@ -214,17 +214,9 @@ Values: Use the `torchMode` property to specify the camera torch mode. -#### `onFocusChanged` +#### `onFocusChanged: Event { nativeEvent: { touchPoint: { x, y } }` -Args: -``` -e: { - nativeEvent: { - touchPoint: { x, y } - } -} -``` -Will call when touch to focus has been made. +Called when a touch focus gesture has been made. By default, `onFocusChanged` is not defined and tap-to-focus is disabled. #### `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. -#### `onZoomChanged` +#### `onZoomChanged: Event { nativeEvent: { velocity, zoomFactor } }` -Args: -``` - e: { - nativeEvent: { - velocity, zoomFactor - } - } -``` -Will call when focus has changed. +Called when focus has changed. 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 `` 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. - `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()` 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. diff --git a/index.ios.js b/index.ios.js index 1235243..79578b8 100644 --- a/index.ios.js +++ b/index.ios.js @@ -62,36 +62,38 @@ export default class Camera extends Component { PropTypes.string, PropTypes.number ]), - type: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.number - ]), - orientation: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.number - ]), + defaultOnFocusComponent: PropTypes.bool, flashMode: PropTypes.oneOfType([ PropTypes.string, PropTypes.number ]), + onBarCodeRead: PropTypes.func, + onFocusChanged: PropTypes.func, + onZoomChanged: PropTypes.func + orientation: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number + ]), torchMode: PropTypes.oneOfType([ PropTypes.string, PropTypes.number ]), - onBarCodeRead: PropTypes.func, - onFocusChanged: PropTypes.func, - onZoomChanged: PropTypes.func + type: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.number + ]) }; static defaultProps = { - aspect: constants.Aspect.fill, - type: constants.Type.back, - orientation: constants.Orientation.auto, + aspect: Camera.constants.Aspect.fill, + type: Camera.constants.Type.back, + orientation: Camera.constants.Orientation.auto, captureAudio: true, - captureMode: constants.CaptureMode.still, - captureTarget: constants.CaptureTarget.cameraRoll, - flashMode: constants.FlashMode.off, - torchMode: constants.TorchMode.off, + captureMode: Camera.constants.CaptureMode.still, + captureTarget: Camera.constants.CaptureTarget.cameraRoll, + defaultOnFocusComponent: true, + flashMode: Camera.constants.FlashMode.off, + torchMode: Camera.constants.TorchMode.off, onBarCodeRead: () => {}, onFocusChanged: () => {}, onZoomChanged: () => {} @@ -108,7 +110,7 @@ export default class Camera extends Component { this.state = { isAuthorized: false, isRecording: false - } + }; } 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: {}, });