import React, { Component, PropTypes, View, Image, Text } from 'react-native';
import Icon from './Icon';
import { getColor } from './helpers';

export default class Avatar extends Component {

    static propTypes = {
        image: PropTypes.shape({ type: PropTypes.oneOf([Image]) }),
        icon: PropTypes.string,
        size: PropTypes.number,
        color: PropTypes.string,
        backgroundColor: PropTypes.string,
        children: PropTypes.string
    };

    static defaultProps = {
        size: 40,
        color: '#ffffff',
        backgroundColor: getColor('paperGrey500')
    };

    render() {
        const { image, icon, size, color, backgroundColor, children } = this.props;

        if (image) {
            return React.cloneElement(image, {
                style: {
                    width: size,
                    height: size,
                    borderRadius: size / 2,
                    borderColor: 'rgba(0,0,0,.1)',
                    borderWidth: 1
                }
            });
        }

        if (icon) {
            return (
                <View style={{ flex: 1 }}>
                    <View style={{ width: size, height: size, borderRadius: size / 2, backgroundColor: getColor(backgroundColor), alignItems:'center', justifyContent: 'center' }}>
                        <Icon
                            name={icon}
                            color={color}
                            size={0.6 * size}
                        />
                    </View>
                </View>
            );
        }

        if (children) {
            return (
                <View style={{ flex: 1 }}>
                    <View style={{ width: size, height: size, borderRadius: size / 2, backgroundColor: getColor(backgroundColor), alignItems:'center', justifyContent: 'center' }}>
                        <Text style={{ color: color }}>{children}</Text>
                    </View>
                </View>
            );
        }

        return null;
    }
}

@@ -428,24 +428,20 @@
         
-children
+text
 : PropTy
@@ -663,24 +663,20 @@
 dColor, 
-children
+text
  %7D = thi
@@ -1559,24 +1559,20 @@
     if (
-children
+text
 ) %7B%0A    
@@ -1871,16 +1871,12 @@
 %7D%7D%3E%7B
-children
+text
 %7D%3C/T

change children to prop