Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Commit

Permalink
feat(preview): add new props to JS
Browse files Browse the repository at this point in the history
  • Loading branch information
jgfidelis committed May 31, 2018
1 parent b9fb708 commit 9bf9a2e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/RNCamera.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const styles = StyleSheet.create({
},
});

type Orientation = "auto"|"landscapeLeft"|"landscapeRight"|"portrait"|"portraitUpsideDown";
type Orientation = 'auto' | 'landscapeLeft' | 'landscapeRight' | 'portrait' | 'portraitUpsideDown';

type PictureOptions = {
quality?: number,
Expand Down Expand Up @@ -82,6 +82,7 @@ type PropsType = typeof View.props & {
type?: number | string,
onCameraReady?: Function,
onBarCodeRead?: Function,
onPictureSaved?: Function,
onGoogleVisionBarcodesDetected?: Function,
faceDetectionMode?: number,
flashMode?: number | string,
Expand All @@ -96,6 +97,7 @@ type PropsType = typeof View.props & {
captureAudio?: boolean,
useCamera2Api?: boolean,
playSoundOnCapture?: boolean,
pictureSize?: string,
};

type StateType = {
Expand Down Expand Up @@ -176,6 +178,7 @@ export default class Camera extends React.Component<PropsType, StateType> {
onMountError: PropTypes.func,
onCameraReady: PropTypes.func,
onBarCodeRead: PropTypes.func,
onPictureSaved: PropTypes.func,
onGoogleVisionBarcodesDetected: PropTypes.func,
onFacesDetected: PropTypes.func,
onTextRecognized: PropTypes.func,
Expand All @@ -195,6 +198,7 @@ export default class Camera extends React.Component<PropsType, StateType> {
captureAudio: PropTypes.bool,
useCamera2Api: PropTypes.bool,
playSoundOnCapture: PropTypes.bool,
pictureSize: PropTypes.string,
};

static defaultProps: Object = {
Expand Down Expand Up @@ -226,6 +230,7 @@ export default class Camera extends React.Component<PropsType, StateType> {
captureAudio: false,
useCamera2Api: false,
playSoundOnCapture: false,
pictureSize: 'Photo',
};

_cameraRef: ?Object;
Expand Down Expand Up @@ -289,6 +294,12 @@ export default class Camera extends React.Component<PropsType, StateType> {
}
};

_onPictureSaved = ({ nativeEvent }) => {
if (this.props.onPictureSaved) {
this.props.onPictureSaved(nativeEvent);
}
};

_onObjectDetected = (callback: ?Function) => ({ nativeEvent }: EventCallbackArgumentsType) => {
const { type } = nativeEvent;

Expand Down Expand Up @@ -363,6 +374,7 @@ export default class Camera extends React.Component<PropsType, StateType> {
onBarCodeRead={this._onObjectDetected(this.props.onBarCodeRead)}
onFacesDetected={this._onObjectDetected(this.props.onFacesDetected)}
onTextRecognized={this._onObjectDetected(this.props.onTextRecognized)}
onPictureSaved={this._onPictureSaved}
>
{this.renderChildren()}
</RNCamera>
Expand Down Expand Up @@ -427,6 +439,7 @@ const RNCamera = requireNativeComponent('RNCamera', Camera, {
onBarCodeRead: true,
onGoogleVisionBarcodesDetected: true,
onCameraReady: true,
onPictureSaved: true,
onFaceDetected: true,
onLayout: true,
onMountError: true,
Expand Down

0 comments on commit 9bf9a2e

Please sign in to comment.