{"size": 2675, "ext": "js", "max_stars_repo_path": "src/components/DeepARView.js", "max_stars_repo_name": "readytowork-org/deepar-example-reactnative", "max_stars_repo_stars_event_min_datetime": "2021-08-23T09:47:54.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-23T09:47:54.000Z", "max_issues_repo_path": "src/components/DeepARView.js", "max_issues_repo_name": "readytowork-org/deepar-example-reactnative", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/DeepARView.js", "max_forks_repo_name": "readytowork-org/deepar-example-reactnative", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.7685185185, "max_line_length": 92, "alphanum_fraction": 0.683364486}
// DeepArView.js
import PropTypes from 'prop-types';
import React from 'react';
import {findNodeHandle, requireNativeComponent, UIManager} from 'react-native';

var RNT_DEEPARVIEW_REF = 'deeparview';

class DeepARView extends React.Component {
  getDeepARViewHandle = () => {
    return findNodeHandle(this.refs[RNT_DEEPARVIEW_REF]);
  };

  switchCamera = () => {
    UIManager.dispatchViewManagerCommand(
      this.getDeepARViewHandle(),
      UIManager.getViewManagerConfig('RNTDeepARView').Commands.switchCamera,
      null,
    );
  };

  switchEffect = (maskName, slot) => {
    UIManager.dispatchViewManagerCommand(
      this.getDeepARViewHandle(),
      UIManager.getViewManagerConfig('RNTDeepARView').Commands.switchEffect,
      [maskName, slot],
    );
  };

  setFlashOn = flashOn => {
    UIManager.dispatchViewManagerCommand(
      this.getDeepARViewHandle(),
      UIManager.getViewManagerConfig('RNTDeepARView').Commands.setFlashOn,
      [flashOn],
    );
  };

  pause() {
    UIManager.dispatchViewManagerCommand(
      this.getDeepARViewHandle(),
      UIManager.getViewManagerConfig('RNTDeepARView').Commands.pause,
      null,
    );
  }

  resume() {
    UIManager.dispatchViewManagerCommand(
      this.getDeepARViewHandle(),
      UIManager.getViewManagerConfig('RNTDeepARView').Commands.resume,
      null,
    );
  }

  takeScreenshot() {
    UIManager.dispatchViewManagerCommand(
      this.getDeepARViewHandle(),
      UIManager.getViewManagerConfig('RNTDeepARView').Commands.takeScreenshot,
      null,
    );
  }

  startRecording() {
    UIManager.dispatchViewManagerCommand(
      this.getDeepARViewHandle(),
      UIManager.getViewManagerConfig('RNTDeepARView').Commands.startRecording,
      null,
    );
  }

  finishRecording() {
    UIManager.dispatchViewManagerCommand(
      this.getDeepARViewHandle(),
      UIManager.getViewManagerConfig('RNTDeepARView').Commands.finishRecording,
      null,
    );
  }

  render() {
    var onEventSent = event => {
      const onEventSentCallback = this.props.onEventSent;
      //console.log("RECEIVED message from native", event.nativeEvent, onEventSentCallback);

      if (onEventSentCallback) {
        onEventSentCallback(event.nativeEvent);
        //this.props.onEventSent(event.nativeEvent);
      }
    };

    let {...props} = {...this.props};
    delete props.onEventSent;

    return (
      <RNTDeepARView
        ref={RNT_DEEPARVIEW_REF}
        {...this.props}
        onEventSent={onEventSent}
      />
    );
  }
}

DeepARView.propTypes = {
  onEventSent: PropTypes.func,
};

var RNTDeepARView = requireNativeComponent('RNTDeepARView', DeepARView);

export default DeepARView;
