<commit_before>/* eslint-disable no-use-before-define */
import React from 'react-native';
import Camera from 'react-native-camera';
import { connect } from 'react-redux';
import { reviewQuilt, selectWatchQuilt } from '../actions/index';
import Button from '../components/button';

const {
  Component,
  Dimensions,
  PropTypes,
  StyleSheet,
  Text,
  View,
} = React;

class ShowCamera extends Component {
  constructor(props) {
    super(props);
    this.cameraRef = this.cameraRef.bind(this);
    this._onStartCapture = this._onStartCapture.bind(this);
    this._onStopCapture = this._onStopCapture.bind(this);
    this.onCapturePress = this.onCapturePress.bind(this);
    this.reverseCamera = this.reverseCamera.bind(this);

    // refactor into redux?
    this.state = {
      isCapturing: false,
      type: 'back',
    };
  }

  // testing video posting, should be moved into action creator in future
  // also, add spinners,
  // add catches
  onCapturePress() {
    if (!this.state.isCapturing) {
      this._onStartCapture();
    } else {
      this._onStopCapture();
    }
  }

  _onStartCapture() {
    this.setState({
      isCapturing: true,
    });

    this.camera.capture()
      .then(file => {
        if (this.props.currentQuilt.status === 'watchAdd') {
          this.props.selectWatchQuilt({ status: 'add' });
        }
        this.props.reviewQuilt(file);
        this.props.navigator.replace({ name: 'video' });
      });
  }

  _onStopCapture() {
    this.setState({
      isCapturing: false,
    });
    this.camera.stopCapture();
  }

  cameraRef(cam) {
    // not sure the reason for this function yet
    this.camera = cam;
  }

  reverseCamera() {
    this.setState({ type: this.state.type === 'back' ? 'front' : 'back' });
  }
  render() {
    return (
      <View style={styles.container}>
        <Camera
          ref={this.cameraRef}
          style={styles.preview}
          aspect={'fill'}
          captureTarget={Camera.constants.CaptureTarget.temp}
          captureMode={Camera.constants.CaptureMode.video}
          captureQuality={Camera.constants.CaptureQuality.medium}
          type={this.state.type}
        >
          <Text style={styles.capture} onPress={this.onCapturePress}>
            [CAPTURE]
          </Text>
          <Button text="SELFIE!" onPress={this.reverseCamera} />
        </Camera>
      </View>
    );<commit_msg>style camera view<commit_after>/* eslint-disable no-use-before-define */
import React from 'react-native';
import Camera from 'react-native-camera';
import { connect } from 'react-redux';
import { reviewQuilt, selectWatchQuilt } from '../actions/index';
import Button from '../components/button';
import Icon from 'react-native-vector-icons/FontAwesome';
import { camera } from '../assets/styles';

const {
  Component,
  Dimensions,
  PropTypes,
  StyleSheet,
  Text,
  TouchableHighlight,
  View,
} = React;

class ShowCamera extends Component {
  constructor(props) {
    super(props);
    this.cameraRef = this.cameraRef.bind(this);
    this._onStartCapture = this._onStartCapture.bind(this);
    this._onStopCapture = this._onStopCapture.bind(this);
    this.onCapturePress = this.onCapturePress.bind(this);
    this.reverseCamera = this.reverseCamera.bind(this);

    // refactor into redux?
    this.state = {
      isCapturing: false,
      type: 'back',
    };
  }

  // testing video posting, should be moved into action creator in future
  // also, add spinners,
  // add catches
  onCapturePress() {
    if (!this.state.isCapturing) {
      this._onStartCapture();
    } else {
      this._onStopCapture();
    }
  }

  _onStartCapture() {
    this.setState({
      isCapturing: true,
    });

    this.camera.capture()
      .then(file => {
        if (this.props.currentQuilt.status === 'watchAdd') {
          this.props.selectWatchQuilt({ status: 'add' });
        }
        this.props.reviewQuilt(file);
        this.props.navigator.replace({ name: 'video' });
      });
  }

  _onStopCapture() {
    this.setState({
      isCapturing: false,
    });
    this.camera.stopCapture();
  }

  cameraRef(cam) {
    // not sure the reason for this function yet
    this.camera = cam;
  }

  reverseCamera() {
    this.setState({ type: this.state.type === 'back' ? 'front' : 'back' });
  }
  render() {
    return (
      <Camera
        ref={this.cameraRef}
        style={camera.preview}
        aspect={'fill'}
        captureTarget={Camera.constants.CaptureTarget.temp}
        captureMode={Camera.constants.CaptureMode.video}
        captureQuality={Camera.constants.CaptureQuality.medium}
        type={this.state.type}
      >
        <View style={camera.containerA}>
          <TouchableHighlight style={camera.iconContainerA} onPress={this.reverseCamera}>
            <Icon name="refresh" size={40}/>
          </TouchableHighlight>
        </View>
        <View style={camera.containerB}>
          <TouchableHighlight style={camera.iconContainerB} onPress={this.onCapturePress}>
            <Icon name="camera" size={40}/>
          </TouchableHighlight>
        </View>
      </Camera>
    );
{'fraction_non_alphanumeric': 0.1396078431372549, 'fraction_numerical': 0.000784313725490196, 'mean_word_length': 2.651395848246242, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '490702', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1538, 'n_words': 298}