-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25418 from Expensify/georgia-DownloadAppBanner
Add Download Banner to mWeb
- Loading branch information
Showing
12 changed files
with
268 additions
and
20 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React, {useState} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import ONYXKEYS from '../ONYXKEYS'; | ||
import styles from '../styles/styles'; | ||
import CONST from '../CONST'; | ||
import AppIcon from '../../assets/images/expensify-app-icon.svg'; | ||
import useLocalize from '../hooks/useLocalize'; | ||
import * as Link from '../libs/actions/Link'; | ||
import * as Browser from '../libs/Browser'; | ||
import getOperatingSystem from '../libs/getOperatingSystem'; | ||
import setShowDownloadAppModal from '../libs/actions/DownloadAppModal'; | ||
import ConfirmModal from './ConfirmModal'; | ||
|
||
const propTypes = { | ||
/** ONYX PROP to hide banner for a user that has dismissed it */ | ||
// eslint-disable-next-line react/forbid-prop-types | ||
showDownloadAppBanner: PropTypes.bool, | ||
}; | ||
|
||
const defaultProps = { | ||
showDownloadAppBanner: true, | ||
}; | ||
|
||
function DownloadAppModal({showDownloadAppBanner}) { | ||
const [shouldShowBanner, setshouldShowBanner] = useState(Browser.isMobile() && showDownloadAppBanner); | ||
|
||
const {translate} = useLocalize(); | ||
|
||
const handleCloseBanner = () => { | ||
setShowDownloadAppModal(false); | ||
setshouldShowBanner(false); | ||
}; | ||
|
||
let link = ''; | ||
|
||
if (getOperatingSystem() === CONST.OS.IOS) { | ||
link = CONST.APP_DOWNLOAD_LINKS.IOS; | ||
} else if (getOperatingSystem() === CONST.OS.ANDROID) { | ||
link = CONST.APP_DOWNLOAD_LINKS.ANDROID; | ||
} | ||
|
||
const handleOpenAppStore = () => { | ||
Link.openExternalLink(link, true); | ||
}; | ||
|
||
return ( | ||
<ConfirmModal | ||
title={translate('DownloadAppModal.downloadTheApp')} | ||
isVisible={shouldShowBanner} | ||
onConfirm={handleOpenAppStore} | ||
onCancel={handleCloseBanner} | ||
prompt={translate('DownloadAppModal.keepTheConversationGoing')} | ||
confirmText={translate('common.download')} | ||
cancelText={translate('DownloadAppModal.noThanks')} | ||
shouldCenterContent | ||
iconSource={AppIcon} | ||
promptStyles={[styles.textNormal, styles.lh20]} | ||
titleStyles={[styles.textHeadline]} | ||
iconAdditionalStyles={[styles.appIconBorderRadius]} | ||
shouldStackButtons={false} | ||
/> | ||
); | ||
} | ||
|
||
DownloadAppModal.displayName = 'DownloadAppModal'; | ||
DownloadAppModal.propTypes = propTypes; | ||
DownloadAppModal.defaultProps = defaultProps; | ||
|
||
export default withOnyx({ | ||
showDownloadAppBanner: { | ||
key: ONYXKEYS.SHOW_DOWNLOAD_APP_BANNER, | ||
}, | ||
})(DownloadAppModal); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Onyx from 'react-native-onyx'; | ||
import ONYXKEYS from '../../ONYXKEYS'; | ||
|
||
/** | ||
* @param {Boolean} shouldShowBanner | ||
*/ | ||
function setShowDownloadAppModal(shouldShowBanner) { | ||
Onyx.set(ONYXKEYS.SHOW_DOWNLOAD_APP_BANNER, shouldShowBanner); | ||
} | ||
|
||
export default setShowDownloadAppModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.