Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow MacOS app download link to be copy from Right Hand fix #9047

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 49 additions & 8 deletions src/pages/settings/AppDownloadLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,25 @@ 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 PressableWithSecondaryInteraction from '../../components/PressableWithSecondaryInteraction';
import ControlSelection from '../../libs/ControlSelection';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../components/withWindowDimensions';
import canUseTouchScreen from '../../libs/canUseTouchscreen';
import * as ReportActionContextMenu from '../home/report/ContextMenu/ReportActionContextMenu';
import * as ContextMenuActions from '../home/report/ContextMenu/ContextMenuActions';

const propTypes = {
...withLocalizePropTypes,
...windowDimensionsPropTypes,
};

const AppDownloadLinksPage = (props) => {
let popoverAnchor;

const menuItems = [
{
translationKey: 'initialSettingsPage.appDownloadLinks.android.label',
Expand All @@ -24,6 +34,7 @@ const AppDownloadLinksPage = (props) => {
action: () => {
Link.openExternalLink(CONST.APP_DOWNLOAD_LINKS.ANDROID);
},
link: CONST.APP_DOWNLOAD_LINKS.ANDROID,
},
{
translationKey: 'initialSettingsPage.appDownloadLinks.ios.label',
Expand All @@ -32,6 +43,7 @@ const AppDownloadLinksPage = (props) => {
action: () => {
Link.openExternalLink(CONST.APP_DOWNLOAD_LINKS.IOS);
},
link: CONST.APP_DOWNLOAD_LINKS.IOS,
},
{
translationKey: 'initialSettingsPage.appDownloadLinks.desktop.label',
Expand All @@ -40,9 +52,25 @@ const AppDownloadLinksPage = (props) => {
action: () => {
Link.openExternalLink(CONST.APP_DOWNLOAD_LINKS.DESKTOP);
},
link: CONST.APP_DOWNLOAD_LINKS.DESKTOP,
},
];

/**
* Show the ReportActionContextMenu modal popover.
*
* @param {Object} [event] - A press event.
* @param {string} [selection] - A copy text.
*/
const showPopover = (event, selection) => {
ReportActionContextMenu.showContextMenu(
ContextMenuActions.CONTEXT_MENU_TYPES.LINK,
event,
selection,
popoverAnchor,
);
};

return (
<ScreenWrapper>
<HeaderWithCloseButton
Expand All @@ -53,14 +81,24 @@ const AppDownloadLinksPage = (props) => {
/>
<ScrollView style={[styles.mt5]}>
{_.map(menuItems, item => (
<MenuItem
<PressableWithSecondaryInteraction
key={item.translationKey}
title={props.translate(item.translationKey)}
icon={item.icon}
iconRight={item.iconRight}
onPress={() => item.action()}
shouldShowRightIcon
/>
onPressIn={() => props.isSmallScreenWidth && canUseTouchScreen() && ControlSelection.block()}
onPressOut={() => ControlSelection.unblock()}
onSecondaryInteraction={e => showPopover(e, item.link)}
Justicea83 marked this conversation as resolved.
Show resolved Hide resolved
ref={el => popoverAnchor = el}
onKeyDown={(event) => {
event.target.blur();
}}
>
<MenuItem
title={props.translate(item.translationKey)}
icon={item.icon}
iconRight={item.iconRight}
onPress={() => item.action()}
shouldShowRightIcon
/>
</PressableWithSecondaryInteraction>
))}
</ScrollView>
</ScreenWrapper>
Expand All @@ -70,4 +108,7 @@ const AppDownloadLinksPage = (props) => {
AppDownloadLinksPage.propTypes = propTypes;
AppDownloadLinksPage.displayName = 'AppDownloadLinksPage';

export default withLocalize(AppDownloadLinksPage);
export default compose(
Justicea83 marked this conversation as resolved.
Show resolved Hide resolved
withWindowDimensions,
withLocalize,
)(AppDownloadLinksPage);