2018-08-31 16:46:33 +00:00
|
|
|
import React from 'react';
|
2018-09-25 19:28:42 +00:00
|
|
|
import {
|
2019-01-29 19:52:56 +00:00
|
|
|
Text, View, StyleSheet, ViewPropTypes, Image
|
2018-09-25 19:28:42 +00:00
|
|
|
} 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';
|
2019-01-29 19:52:56 +00:00
|
|
|
import { isIOS } from '../utils/deviceInfo';
|
2018-08-31 16:46:33 +00:00
|
|
|
|
|
|
|
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',
|
2019-01-29 19:52:56 +00:00
|
|
|
marginTop: isIOS ? 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 = ({
|
2019-02-07 19:58:20 +00:00
|
|
|
name, username, onPress, testID, onLongPress, style, icon, baseUrl, user
|
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]}>
|
2019-02-07 19:58:20 +00:00
|
|
|
<Avatar text={username} size={30} type='d' style={styles.avatar} baseUrl={baseUrl} user={user} />
|
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,
|
2019-02-07 19:58:20 +00:00
|
|
|
user: PropTypes.shape({
|
|
|
|
id: PropTypes.string,
|
|
|
|
token: PropTypes.string
|
|
|
|
}),
|
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;
|