All files / grid Row.js

100% Statements 8/8
100% Branches 12/12
100% Functions 1/1
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59      2x 3x   3x             3x 1x                                   2x                         2x               2x          
import React, { PropTypes } from 'react';
import { View, StyleSheet, TouchableOpacity } from 'react-native';
 
const Row = (props) => {
  const {containerStyle, size, onPress, activeOpacity} = props;
 
  const styles = StyleSheet.create({
    container: {
      flex: (size) ? size : (containerStyle && containerStyle.height) ? 0 : 1,
      flexDirection: 'row',
    },
  });
 
  if (onPress) {
    return (
      <TouchableOpacity
        style={[
          styles.container,
          containerStyle && containerStyle,
        ]}
        activeOpacity={activeOpacity}
        onPress={onPress}
      >
        <View
          {...props}
        >
          {props.children}
        </View>
      </TouchableOpacity>
    );
  }
 
  return (
    <View
      style={[
        styles.container,
        containerStyle && containerStyle,
      ]}
      {...props}
    >
      {props.children}
    </View>
  );
};
 
Row.propTypes = {
  size: PropTypes.number,
  containerStyle: PropTypes.any,
  onPress: PropTypes.func,
  activeOpacity: PropTypes.number,
  children: PropTypes.any,
};
 
Row.defaultProps = {
  activeOpacity: 1,
};
 
export default Row;