2018-08-31 16:46:33 +00:00
|
|
|
import React from 'react';
|
2018-08-31 18:13:30 +00:00
|
|
|
import { Text, View, StyleSheet, Platform, ViewPropTypes, Image } from 'react-native';
|
2018-08-31 16:46:33 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import Avatar from '../containers/Avatar';
|
|
|
|
import Touch from '../utils/touch';
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
button: {
|
2018-08-31 18:13:30 +00:00
|
|
|
height: 54,
|
|
|
|
backgroundColor: '#fff'
|
2018-08-31 16:46:33 +00:00
|
|
|
},
|
|
|
|
container: {
|
|
|
|
flexDirection: 'row'
|
|
|
|
},
|
|
|
|
avatar: {
|
|
|
|
marginHorizontal: 15,
|
|
|
|
marginVertical: 12
|
|
|
|
},
|
|
|
|
textContainer: {
|
|
|
|
flex: 1,
|
|
|
|
flexDirection: 'column'
|
|
|
|
},
|
|
|
|
name: {
|
|
|
|
fontSize: 18,
|
|
|
|
color: '#0C0D0F',
|
|
|
|
marginTop: Platform.OS === 'ios' ? 6 : 3,
|
2018-08-31 18:13:30 +00:00
|
|
|
marginBottom: 1,
|
|
|
|
textAlign: 'left'
|
2018-08-31 16:46:33 +00:00
|
|
|
},
|
|
|
|
username: {
|
|
|
|
fontSize: 14,
|
|
|
|
color: '#9EA2A8'
|
2018-08-31 18:13:30 +00:00
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
width: 20,
|
|
|
|
height: 20,
|
|
|
|
marginHorizontal: 15,
|
|
|
|
resizeMode: 'contain',
|
|
|
|
alignSelf: 'center'
|
2018-08-31 16:46:33 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const UserItem = ({
|
2018-09-11 16:32:52 +00:00
|
|
|
name, username, onPress, testID, onLongPress, style, icon, baseUrl
|
2018-08-31 16:46:33 +00:00
|
|
|
}) => (
|
|
|
|
<Touch onPress={onPress} onLongPress={onLongPress} style={styles.button} testID={testID}>
|
2018-08-31 18:13:30 +00:00
|
|
|
<View style={[styles.container, style]}>
|
2018-09-11 16:32:52 +00:00
|
|
|
<Avatar text={username} size={30} type='d' style={styles.avatar} baseUrl={baseUrl} />
|
2018-08-31 16:46:33 +00:00
|
|
|
<View style={styles.textContainer}>
|
|
|
|
<Text style={styles.name}>{name}</Text>
|
|
|
|
<Text style={styles.username}>@{username}</Text>
|
|
|
|
</View>
|
2018-08-31 18:13:30 +00:00
|
|
|
{icon ? <Image source={{ uri: icon }} style={styles.icon} /> : null}
|
2018-08-31 16:46:33 +00:00
|
|
|
</View>
|
|
|
|
</Touch>
|
|
|
|
);
|
|
|
|
|
|
|
|
UserItem.propTypes = {
|
|
|
|
name: PropTypes.string.isRequired,
|
|
|
|
username: PropTypes.string.isRequired,
|
2018-09-11 16:32:52 +00:00
|
|
|
baseUrl: PropTypes.string.isRequired,
|
2018-08-31 16:46:33 +00:00
|
|
|
onPress: PropTypes.func.isRequired,
|
|
|
|
testID: PropTypes.string.isRequired,
|
2018-08-31 18:13:30 +00:00
|
|
|
onLongPress: PropTypes.func,
|
|
|
|
style: ViewPropTypes.style,
|
|
|
|
icon: PropTypes.string
|
2018-08-31 16:46:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default UserItem;
|