-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathAppDownloadLinks.js
88 lines (82 loc) · 3.53 KB
/
AppDownloadLinks.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
import _ from 'underscore';
import React from 'react';
import {ScrollView} from 'react-native';
import HeaderWithBackButton from '../../components/HeaderWithBackButton';
import CONST from '../../CONST';
import * as Expensicons from '../../components/Icon/Expensicons';
import ScreenWrapper from '../../components/ScreenWrapper';
import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize';
import compose from '../../libs/compose';
import MenuItem from '../../components/MenuItem';
import styles from '../../styles/styles';
import * as Link from '../../libs/actions/Link';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../components/withWindowDimensions';
import * as ReportActionContextMenu from '../home/report/ContextMenu/ReportActionContextMenu';
import {CONTEXT_MENU_TYPES} from '../home/report/ContextMenu/ContextMenuActions';
import ROUTES from '../../ROUTES';
import Navigation from '../../libs/Navigation/Navigation';
const propTypes = {
...withLocalizePropTypes,
...windowDimensionsPropTypes,
};
function AppDownloadLinksPage(props) {
let popoverAnchor;
const menuItems = [
{
translationKey: 'initialSettingsPage.appDownloadLinks.android.label',
icon: Expensicons.Android,
iconRight: Expensicons.NewWindow,
action: () => {
Link.openExternalLink(CONST.APP_DOWNLOAD_LINKS.ANDROID);
},
link: CONST.APP_DOWNLOAD_LINKS.ANDROID,
},
{
translationKey: 'initialSettingsPage.appDownloadLinks.ios.label',
icon: Expensicons.Apple,
iconRight: Expensicons.NewWindow,
action: () => {
Link.openExternalLink(CONST.APP_DOWNLOAD_LINKS.IOS, true);
},
link: CONST.APP_DOWNLOAD_LINKS.IOS,
},
{
translationKey: 'initialSettingsPage.appDownloadLinks.desktop.label',
icon: Expensicons.Monitor,
iconRight: Expensicons.NewWindow,
action: () => {
Link.openExternalLink(CONST.APP_DOWNLOAD_LINKS.DESKTOP);
},
link: CONST.APP_DOWNLOAD_LINKS.DESKTOP,
},
];
return (
<ScreenWrapper testID={AppDownloadLinksPage.displayName}>
<HeaderWithBackButton
title={props.translate('initialSettingsPage.aboutPage.appDownloadLinks')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_ABOUT)}
/>
<ScrollView style={[styles.mt5]}>
{_.map(menuItems, (item) => (
<MenuItem
key={item.translationKey}
onPress={() => item.action()}
onSecondaryInteraction={(e) => ReportActionContextMenu.showContextMenu(CONTEXT_MENU_TYPES.LINK, e, item.link, popoverAnchor)}
onKeyDown={(event) => {
event.target.blur();
}}
ref={(el) => (popoverAnchor = el)}
title={props.translate(item.translationKey)}
icon={item.icon}
iconRight={item.iconRight}
shouldBlockSelection
shouldShowRightIcon
/>
))}
</ScrollView>
</ScreenWrapper>
);
}
AppDownloadLinksPage.propTypes = propTypes;
AppDownloadLinksPage.displayName = 'AppDownloadLinksPage';
export default compose(withWindowDimensions, withLocalize)(AppDownloadLinksPage);