Rocket.Chat.ReactNative/app/presentation/UserItem.js

77 lines
1.8 KiB
JavaScript
Raw Normal View History

import React from 'react';
import {
Text, View, StyleSheet, ViewPropTypes
} from 'react-native';
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';
import { CustomIcon } from '../lib/Icons';
const styles = StyleSheet.create({
button: {
height: 54,
backgroundColor: '#fff'
},
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,
marginBottom: 1,
textAlign: 'left'
},
username: {
fontSize: 14,
color: '#9EA2A8'
},
icon: {
marginHorizontal: 15,
alignSelf: 'center',
color: '#1D74F5'
}
});
const UserItem = ({
name, username, onPress, testID, onLongPress, style, icon, baseUrl, user
}) => (
<Touch onPress={onPress} onLongPress={onLongPress} style={styles.button} testID={testID}>
<View style={[styles.container, style]}>
<Avatar text={username} size={30} type='d' style={styles.avatar} baseUrl={baseUrl} user={user} />
<View style={styles.textContainer}>
<Text style={styles.name}>{name}</Text>
<Text style={styles.username}>@{username}</Text>
</View>
{icon ? <CustomIcon name={icon} size={22} style={styles.icon} /> : null}
</View>
</Touch>
);
UserItem.propTypes = {
name: PropTypes.string.isRequired,
username: PropTypes.string.isRequired,
user: PropTypes.shape({
id: PropTypes.string,
token: PropTypes.string
}),
baseUrl: PropTypes.string.isRequired,
onPress: PropTypes.func.isRequired,
testID: PropTypes.string.isRequired,
onLongPress: PropTypes.func,
style: ViewPropTypes.style,
icon: PropTypes.string
};
export default UserItem;