2018-08-31 16:46:33 +00:00
|
|
|
import React from 'react';
|
2021-09-13 20:41:05 +00:00
|
|
|
// @ts-ignore
|
|
|
|
import { Pressable, StyleSheet, Text, View } from 'react-native';
|
2018-08-31 16:46:33 +00:00
|
|
|
|
|
|
|
import Avatar from '../containers/Avatar';
|
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';
|
2019-12-04 16:39:53 +00:00
|
|
|
import { themes } from '../constants/colors';
|
2020-07-29 21:03:17 +00:00
|
|
|
import { isIOS } from '../utils/deviceInfo';
|
2018-08-31 16:46:33 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
button: {
|
2019-12-04 16:39:53 +00:00
|
|
|
height: 54
|
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',
|
2020-05-08 17:09:36 +00:00
|
|
|
justifyContent: 'center',
|
|
|
|
marginRight: 15
|
2018-08-31 16:46:33 +00:00
|
|
|
},
|
|
|
|
name: {
|
2019-03-29 19:36:07 +00:00
|
|
|
fontSize: 17,
|
2019-12-04 16:39:53 +00:00
|
|
|
...sharedStyles.textMedium
|
2018-08-31 16:46:33 +00:00
|
|
|
},
|
|
|
|
username: {
|
|
|
|
fontSize: 14,
|
2019-12-04 16:39:53 +00:00
|
|
|
...sharedStyles.textRegular
|
2018-08-31 18:13:30 +00:00
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
marginHorizontal: 15,
|
2019-12-04 16:39:53 +00:00
|
|
|
alignSelf: 'center'
|
2018-08-31 16:46:33 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
interface IUserItem {
|
|
|
|
name: string;
|
|
|
|
username: string;
|
|
|
|
onPress(): void;
|
|
|
|
testID: string;
|
|
|
|
onLongPress(): void;
|
|
|
|
style: any;
|
|
|
|
icon: string;
|
|
|
|
theme: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const UserItem = ({ name, username, onPress, testID, onLongPress, style, icon, theme }: IUserItem) => (
|
2020-07-29 21:03:17 +00:00
|
|
|
<Pressable
|
|
|
|
onPress={onPress}
|
|
|
|
onLongPress={onLongPress}
|
|
|
|
testID={testID}
|
|
|
|
android_ripple={{
|
|
|
|
color: themes[theme].bannerBackground
|
|
|
|
}}
|
2021-09-13 20:41:05 +00:00
|
|
|
style={({ pressed }: any) => ({
|
|
|
|
backgroundColor: isIOS && pressed ? themes[theme].bannerBackground : 'transparent'
|
|
|
|
})}>
|
2020-07-29 21:03:17 +00:00
|
|
|
<View style={[styles.container, styles.button, style]}>
|
2020-10-30 13:12:02 +00:00
|
|
|
<Avatar text={username} size={30} style={styles.avatar} />
|
2020-07-29 21:03:17 +00:00
|
|
|
<View style={styles.textContainer}>
|
2021-09-13 20:41:05 +00:00
|
|
|
<Text style={[styles.name, { color: themes[theme].titleText }]} numberOfLines={1}>
|
|
|
|
{name}
|
|
|
|
</Text>
|
|
|
|
<Text style={[styles.username, { color: themes[theme].auxiliaryText }]} numberOfLines={1}>
|
|
|
|
@{username}
|
|
|
|
</Text>
|
2020-05-04 20:20:45 +00:00
|
|
|
</View>
|
2020-07-29 21:03:17 +00:00
|
|
|
{icon ? <CustomIcon name={icon} size={22} style={[styles.icon, { color: themes[theme].actionTintColor }]} /> : null}
|
|
|
|
</View>
|
|
|
|
</Pressable>
|
2020-05-04 20:20:45 +00:00
|
|
|
);
|
2018-08-31 16:46:33 +00:00
|
|
|
|
|
|
|
export default UserItem;
|