{"size": 1104, "ext": "js", "max_stars_repo_path": "src/components/checkbox/index.js", "max_stars_repo_name": "faketeam555/pumc", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/checkbox/index.js", "max_issues_repo_name": "faketeam555/pumc", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/checkbox/index.js", "max_forks_repo_name": "faketeam555/pumc", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.3076923077, "max_line_length": 115, "alphanum_fraction": 0.5788043478}
import React, { PureComponent } from "react";
import { Text, TouchableOpacity, View } from "react-native";
import { Icon } from "../index";
import styles from "../../styles";

export default class Checkbox extends PureComponent {
  state = {
    checked: true
  };

  onChange = () => {
    this.setState({ checked: !this.state.checked });
  };

  render() {
    let {
      checked = this.state.checked,
      textStyle = {},
      iconStyle = {},
      rightText = "",
      onPressFnc = this.onChange,
      size = 24
    } = this.props;

    return (
      <TouchableOpacity activeOpacity={1} onPress={onPressFnc}>
        <View style={[styles.f1, styles.flexRow, styles.jStart, styles.aCenter]}>
          {checked ? (
            <Icon color="#FFF" size={size} name={"check-box"} style={iconStyle} />
          ) : (
            <Icon color="#FFF" size={size} name={"check-box-outline-blank"} style={iconStyle} />
          )}
          <Text style={[styles.cWhite, styles.textCenter, styles.pl5, styles.font12, textStyle]}>{rightText}</Text>
        </View>
      </TouchableOpacity>
    );
  }
}
