<commit_before>/**
 * mSupply Mobile
 * Sustainable Solutions (NZ) Ltd. 2019
 */

import React from 'react';
import PropTypes from 'prop-types';

import { Dimensions, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';

import { APP_FONT_FAMILY, DARK_GREY, SUSSOL_ORANGE } from '../globalStyles';

const renderTitleComponent = (isEditingDisabled, columnIndex, rowData, rowIndex) => {
  // If null or empty string, use single space to avoid squishing row
  const titleString = rowData.title ? rowData.title : ' ';
  const titleComponent = (
    <Text
      key={`Title ${columnIndex}-${rowIndex}`}
      style={[localStyles.text, localStyles.titleText]}
      numberOfLines={1}
    >
      {titleString}
    </Text>
  );
  if (rowData.onPress && !isEditingDisabled) {
    return (
      <TouchableOpacity
        style={localStyles.rowContainer}
        key={`Touchable ${columnIndex}-${rowIndex}`}
        onPress={rowData.onPress}
      >
        {titleComponent}
      </TouchableOpacity>
    );
  }
  return (
    <View style={localStyles.rowContainer} key={`ViewTitle ${columnIndex}-${rowIndex}`}>
      {titleComponent}
    </View>
  );
};

const renderInfoComponent = (isEditingDisabled, columnIndex, rowData, rowIndex) => {
  let editTextStyle;
  let containerStyle;
  let iconName;
  const { editableType, canEdit } = rowData;
  switch (editableType) {
    case 'selectable':
      containerStyle = localStyles.selectContainer;
      iconName = 'angle-down';
      break;
    case 'text':
    default:
      containerStyle = localStyles.editableTextContainer;
      iconName = 'pencil';
      editTextStyle = localStyles.infoText;
      break;
  }
  // If null or empty string, use single space to avoid squishing row
  let infoString = (rowData.info || rowData.info === 0) && String(rowData.info);
  infoString = infoString && infoString.length > 0 ? infoString : ' ';
  const infoComponent = (
    <Text
      key={`Info ${columnIndex}-${rowIndex}`}
      style={[localStyles.text, editTextStyle]}
      numberOfLines={1}
    >
      {infoString}
    </Text>
  );
  if (rowData.onPress && (!isEditingDisabled && canEdit)) {
    return (
      <TouchableOpacity
        style={localStyles.rowContainer}
        key={`Touchable ${columnIndex}-${rowIndex}`}
        onPress={rowData.onPress}
      >
        <View style={containerStyle}>
          {infoComponent}
          <Icon name={iconName} size={14} style={localStyles.editIcon} color={SUSSOL_ORANGE} />
        </View>
      </TouchableOpacity>
    );
  }
  return (
    <View style={localStyles.rowContainer} key={`ViewInfo ${columnIndex}-${rowIndex}`}>
      {infoComponent}
    </View><commit_msg>Add support for adjusting pageinfo fontSize/color<commit_after>/**
 * mSupply Mobile
 * Sustainable Solutions (NZ) Ltd. 2019
 */

import React from 'react';
import PropTypes from 'prop-types';

import { Dimensions, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';

import { APP_FONT_FAMILY, DARK_GREY, SUSSOL_ORANGE } from '../globalStyles';

const renderTitleComponent = (isEditingDisabled, columnIndex, rowData, rowIndex) => {
  // If null or empty string, use single space to avoid squishing row
  const titleString = rowData.title ? rowData.title : ' ';
  const titleComponent = (
    <Text
      key={`Title ${columnIndex}-${rowIndex}`}
      style={[localStyles.text, localStyles.titleText]}
      numberOfLines={1}
    >
      {titleString}
    </Text>
  );
  if (rowData.onPress && !isEditingDisabled) {
    return (
      <TouchableOpacity
        style={localStyles.rowContainer}
        key={`Touchable ${columnIndex}-${rowIndex}`}
        onPress={rowData.onPress}
      >
        {titleComponent}
      </TouchableOpacity>
    );
  }
  return (
    <View style={localStyles.rowContainer} key={`ViewTitle ${columnIndex}-${rowIndex}`}>
      {titleComponent}
    </View>
  );
};

const renderInfoComponent = (isEditingDisabled, columnIndex, rowData, rowIndex) => {
  let editTextStyle;
  let containerStyle;
  let iconName;
  const { editableType, canEdit, infoColor, infoSize } = rowData;
  switch (editableType) {
    case 'selectable':
      containerStyle = localStyles.selectContainer;
      iconName = 'angle-down';
      break;
    case 'text':
    default:
      containerStyle = localStyles.editableTextContainer;
      iconName = 'pencil';
      editTextStyle = localStyles.infoText;
      break;
  }

  if (infoColor) editTextStyle = { ...editTextStyle, color: infoColor };
  if (infoSize) editTextStyle = { ...editTextStyle, fontSize: infoSize };

  // If null or empty string, use single space to avoid squishing row
  let infoString = (rowData.info || rowData.info === 0) && String(rowData.info);
  infoString = infoString && infoString.length > 0 ? infoString : ' ';
  const infoComponent = (
    <Text
      key={`Info ${columnIndex}-${rowIndex}`}
      style={[localStyles.text, editTextStyle]}
      numberOfLines={1}
    >
      {infoString}
    </Text>
  );
  if (rowData.onPress && (!isEditingDisabled && canEdit)) {
    return (
      <TouchableOpacity
        style={localStyles.rowContainer}
        key={`Touchable ${columnIndex}-${rowIndex}`}
        onPress={rowData.onPress}
      >
        <View style={containerStyle}>
          {infoComponent}
          <Icon
            name={iconName}
            size={infoSize || 14}
            style={localStyles.editIcon}
            color={infoColor || SUSSOL_ORANGE}
          />
        </View>
      </TouchableOpacity>
    );
  }
  return (
    <View style={localStyles.rowContainer} key={`ViewInfo ${columnIndex}-${rowIndex}`}>
      {infoComponent}
    </View>
{'fraction_non_alphanumeric': 0.13253430606218516, 'fraction_numerical': 0.0034740316136876847, 'mean_word_length': 3.1275985663082437, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 39, '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': '2815156', 'n_tokens_mistral': 1782, 'n_tokens_neox': 1785, 'n_words': 378}