forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPriorityModePage.js
93 lines (82 loc) · 3.31 KB
/
PriorityModePage.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import _, {compose} from 'underscore';
import React from 'react';
import {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';
import HeaderWithCloseButton from '../../../components/HeaderWithCloseButton';
import ScreenWrapper from '../../../components/ScreenWrapper';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
import Navigation from '../../../libs/Navigation/Navigation';
import ROUTES from '../../../ROUTES';
import OptionsList from '../../../components/OptionsList';
import styles from '../../../styles/styles';
import Text from '../../../components/Text';
import themeColors from '../../../styles/themes/default';
import * as Expensicons from '../../../components/Icon/Expensicons';
import ONYXKEYS from '../../../ONYXKEYS';
import * as User from '../../../libs/actions/User';
import CONST from '../../../CONST';
const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success};
const propTypes = {
/** The chat priority mode */
priorityMode: PropTypes.string,
...withLocalizePropTypes,
};
const defaultProps = {
priorityMode: CONST.PRIORITY_MODE.DEFAULT,
};
const PriorityModePage = (props) => {
const priorityModes = _.map(props.translate('priorityModePage.priorityModes'),
(mode, key) => (
{
value: key,
text: mode.label,
alternateText: mode.description,
// Set max line to undefined to reset line restriction
alternateTextMaxLines: undefined,
keyForList: key,
// Include the green checkmark icon to indicate the currently selected value
customIcon: props.priorityMode === key ? greenCheckmark : undefined,
// This property will make the currently selected value have bold text
boldStyle: props.priorityMode === key,
}
));
return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
<HeaderWithCloseButton
title={props.translate('priorityModePage.priorityMode')}
shouldShowBackButton
onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_PREFERENCES)}
onCloseButtonPress={() => Navigation.dismissModal(true)}
/>
<Text style={[styles.mh5, styles.mv4]}>
{props.translate('priorityModePage.explainerText')}
</Text>
<OptionsList
sections={[{data: priorityModes}]}
onSelectRow={mode => User.updateChatPriorityMode(mode.value)}
hideSectionHeaders
optionHoveredStyle={
{
...styles.hoveredComponentBG,
...styles.mhn5,
...styles.ph5,
}
}
shouldHaveOptionSeparator
shouldDisableRowInnerPadding
contentContainerStyles={[styles.ph5]}
/>
</ScreenWrapper>
);
};
PriorityModePage.displayName = 'PriorityModePage';
PriorityModePage.propTypes = propTypes;
PriorityModePage.defaultProps = defaultProps;
export default compose(
withLocalize,
withOnyx({
priorityMode: {
key: ONYXKEYS.NVP_PRIORITY_MODE,
},
}),
)(PriorityModePage);