-
Notifications
You must be signed in to change notification settings - Fork 3k
/
RadioListItem.js
74 lines (65 loc) · 2.71 KB
/
RadioListItem.js
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
import React from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import PressableWithFeedback from '../Pressable/PressableWithFeedback';
import styles from '../../styles/styles';
import Text from '../Text';
import Icon from '../Icon';
import * as Expensicons from '../Icon/Expensicons';
import themeColors from '../../styles/themes/default';
import {radioListItemPropTypes} from './selectionListRadioPropTypes';
const propTypes = {
/** The section list item */
item: PropTypes.shape(radioListItemPropTypes),
/** Whether this item is focused (for arrow key controls) */
isFocused: PropTypes.bool,
/** Callback to fire when the item is pressed */
onSelectRow: PropTypes.func,
};
const defaultProps = {
item: {},
isFocused: false,
onSelectRow: () => {},
};
function RadioListItem(props) {
return (
<PressableWithFeedback
onPress={() => props.onSelectRow(props.item)}
accessibilityLabel={props.item.text}
accessibilityRole="button"
hoverDimmingValue={1}
hoverStyle={styles.hoveredComponentBG}
focusStyle={styles.hoveredComponentBG}
>
<View style={[styles.flex1, styles.justifyContentBetween, styles.sidebarLinkInner, styles.optionRow, props.isFocused && styles.sidebarLinkActive]}>
<View style={[styles.flex1, styles.alignItemsStart]}>
<Text style={[styles.optionDisplayName, props.isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText, props.item.isSelected && styles.sidebarLinkTextBold]}>
{props.item.text}
</Text>
{Boolean(props.item.alternateText) && (
<Text style={[props.isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText, styles.optionAlternateText, styles.textLabelSupporting]}>
{props.item.alternateText}
</Text>
)}
</View>
{props.item.isSelected && (
<View
style={[styles.flexRow, styles.alignItemsCenter]}
accessible={false}
>
<View>
<Icon
src={Expensicons.Checkmark}
fill={themeColors.success}
/>
</View>
</View>
)}
</View>
</PressableWithFeedback>
);
}
RadioListItem.displayName = 'RadioListItem';
RadioListItem.propTypes = propTypes;
RadioListItem.defaultProps = defaultProps;
export default RadioListItem;