-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListItemWithImage.tsx
More file actions
88 lines (83 loc) · 2.29 KB
/
ListItemWithImage.tsx
File metadata and controls
88 lines (83 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import { MaterialIcons } from '@expo/vector-icons';
import { TouchableOpacity, View, Text, StyleSheet, ActivityIndicator } from 'react-native';
import AvatarIcon from '@/components/avatar/Avatar';
import { Color, linkStyle, listItemStyle } from '@/styles';
type Props = {
id: string;
imagePath?: string;
title: string;
subtitle: string;
subtitleLink?: boolean;
hideImage?: boolean;
isLast?: boolean;
isSelected?: boolean;
isUpdatingSelection?: boolean;
onPress?: () => void;
disabled?: boolean;
testID?: string;
};
const ListItemWithImage = ({
id,
imagePath,
title,
subtitle,
subtitleLink,
hideImage,
isLast,
isSelected,
isUpdatingSelection,
onPress,
disabled,
testID,
}: Props) => (
<TouchableOpacity
testID={testID}
style={styles.container}
onPress={onPress}
disabled={disabled || !onPress}
activeOpacity={0.7}
>
<View style={[styles.contentWrapper, isLast && styles.lastItem]}>
{!hideImage && (
<View style={styles.avatarWrapper}>
<AvatarIcon id={id} imagePath={imagePath} size={44} />
</View>
)}
<View style={styles.textContainer}>
<Text style={styles.title} numberOfLines={1} ellipsizeMode="tail">
{title}
</Text>
<Text
style={[
subtitleLink ? styles.subtitleLink : styles.subtitle,
disabled && styles.disabledSubtitle,
]}
numberOfLines={1}
ellipsizeMode="tail"
>
{subtitle}
</Text>
</View>
{isUpdatingSelection ? (
<ActivityIndicator size="small" color={Color.brand.primary} />
) : (
isSelected && <MaterialIcons name="check" size={22} color={Color.brand.primary} />
)}
</View>
</TouchableOpacity>
);
const styles = StyleSheet.create({
container: listItemStyle.container,
lastItem: listItemStyle.lastItem,
avatarWrapper: listItemStyle.textAndImage.avatarWrapper,
contentWrapper: {
...listItemStyle.contentWrapper,
...listItemStyle.textAndImage.contentWrapper,
},
textContainer: listItemStyle.textContainer,
title: listItemStyle.title,
subtitle: listItemStyle.textAndImage.subtitle,
subtitleLink: linkStyle.listItemLinkRegular,
disabledSubtitle: listItemStyle.disabled.subtitle,
});
export default ListItemWithImage;