2018-08-31 16:46:33 +00:00
|
|
|
import React from 'react';
|
2018-09-25 19:28:42 +00:00
|
|
|
import {
|
2019-03-01 16:49:11 +00:00
|
|
|
Text, View, StyleSheet, ViewPropTypes
|
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-03-01 16:49:11 +00:00
|
|
|
import { CustomIcon } from '../lib/Icons';
|
2019-03-29 19:36:07 +00:00
|
|
|
import sharedStyles from '../views/Styles';
|
|
|
|
import { COLOR_PRIMARY, COLOR_WHITE } from '../constants/colors';
|
2018-08-31 16:46:33 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
button: {
|
2018-08-31 18:13:30 +00:00
|
|
|
height: 54,
|
2019-03-29 19:36:07 +00:00
|
|
|
backgroundColor: COLOR_WHITE
|
2018-08-31 16:46:33 +00:00
|
|
|
},
|
|
|
|
container: {
|
|
|
|
flexDirection: 'row'
|
|
|
|
},
|
|
|
|
avatar: {
|
|
|
|
marginHorizontal: 15,
|
|
|
|
marginVertical: 12
|
|
|
|
},
|
|
|
|
textContainer: {
|
|
|
|
flex: 1,
|
2019-03-29 19:36:07 +00:00
|
|
|
flexDirection: 'column',
|
|
|
|
justifyContent: 'center'
|
2018-08-31 16:46:33 +00:00
|
|
|
},
|
|
|
|
name: {
|
2019-03-29 19:36:07 +00:00
|
|
|
fontSize: 17,
|
|
|
|
...sharedStyles.textMedium,
|
|
|
|
...sharedStyles.textColorNormal
|
2018-08-31 16:46:33 +00:00
|
|
|
},
|
|
|
|
username: {
|
|
|
|
fontSize: 14,
|
2019-03-29 19:36:07 +00:00
|
|
|
...sharedStyles.textRegular,
|
|
|
|
...sharedStyles.textColorDescription
|
2018-08-31 18:13:30 +00:00
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
marginHorizontal: 15,
|
2019-03-01 16:49:11 +00:00
|
|
|
alignSelf: 'center',
|
2019-03-29 19:36:07 +00:00
|
|
|
color: COLOR_PRIMARY
|
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-04-18 20:57:35 +00:00
|
|
|
<Avatar text={username} size={30} type='d' style={styles.avatar} baseUrl={baseUrl} userId={user.id} token={user.token} />
|
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>
|
2019-03-01 16:49:11 +00:00
|
|
|
{icon ? <CustomIcon name={icon} size={22} 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;
|