Skip to content

Commit

Permalink
Merge pull request #9649 from Expensify/arosiclair-full-page-not-foun…
Browse files Browse the repository at this point in the history
…d-view

Add FullPageNotFoundView
  • Loading branch information
arosiclair authored Jul 6, 2022
2 parents 81012a3 + 81fbbe8 commit 32e67da
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 53 deletions.
47 changes: 47 additions & 0 deletions src/components/BlockingViews/BlockingView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import styles from '../../styles/styles';
import variables from '../../styles/variables';
import Icon from '../Icon';
import Text from '../Text';
import themeColors from '../../styles/themes/default';

const propTypes = {
/** Expensicon for the page */
icon: PropTypes.func.isRequired,

/** Color for the icon (should be from theme) */
iconColor: PropTypes.string,

/** Title message below the icon */
title: PropTypes.string.isRequired,

/** Subtitle message below the title */
subtitle: PropTypes.string.isRequired,
};

const defaultProps = {
iconColor: themeColors.offline,
};

const BlockingView = props => (
<View
style={[styles.flex1, styles.alignItemsCenter, styles.justifyContentCenter]}
>
<Icon
src={props.icon}
fill={props.iconColor}
width={variables.iconSizeSuperLarge}
height={variables.iconSizeSuperLarge}
/>
<Text style={[styles.headerText, styles.textLarge, styles.mt5]}>{props.title}</Text>
<Text style={[styles.w70, styles.textAlignCenter]}>{props.subtitle}</Text>
</View>
);

BlockingView.propTypes = propTypes;
BlockingView.defaultProps = defaultProps;
BlockingView.displayName = 'BlockingView';

export default BlockingView;
42 changes: 42 additions & 0 deletions src/components/BlockingViews/FullPageNotFoundView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

import React from 'react';
import PropTypes from 'prop-types';
import BlockingView from './BlockingView';
import * as Expensicons from '../Icon/Expensicons';
import withLocalize, {withLocalizePropTypes} from '../withLocalize';

const propTypes = {
/** Props to fetch translation features */
...withLocalizePropTypes,

/** Child elements */
children: PropTypes.node.isRequired,

/** If true, child components are replaced with a blocking "not found" view */
shouldShow: PropTypes.bool,
};

const defaultProps = {
shouldShow: false,
};

// eslint-disable-next-line rulesdir/no-negated-variables
const FullPageNotFoundView = (props) => {
if (props.shouldShow) {
return (
<BlockingView
icon={Expensicons.QuestionMark}
title={props.translate('notFound.notHere')}
subtitle={props.translate('notFound.pageNotFound')}
/>
);
}

return props.children;
};

FullPageNotFoundView.propTypes = propTypes;
FullPageNotFoundView.defaultProps = defaultProps;
FullPageNotFoundView.displayName = 'FullPageNotFoundView';

export default withLocalize(FullPageNotFoundView);
41 changes: 41 additions & 0 deletions src/components/BlockingViews/FullPageOfflineBlockingView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import PropTypes from 'prop-types';
import networkPropTypes from '../networkPropTypes';
import {withNetwork} from '../OnyxProvider';
import withLocalize, {withLocalizePropTypes} from '../withLocalize';
import * as Expensicons from '../Icon/Expensicons';
import compose from '../../libs/compose';
import BlockingView from './BlockingView';

const propTypes = {
/** Child elements */
children: PropTypes.node.isRequired,

/** Props to fetch translation features */
...withLocalizePropTypes,

/** Props to detect online status */
network: networkPropTypes.isRequired,
};

const FullPageOfflineBlockingView = (props) => {
if (props.network.isOffline) {
return (
<BlockingView
icon={Expensicons.OfflineCloud}
title={props.translate('common.youAppearToBeOffline')}
subtitle={props.translate('common.thisFeatureRequiresInternet')}
/>
);
}

return props.children;
};

FullPageOfflineBlockingView.propTypes = propTypes;
FullPageOfflineBlockingView.displayName = 'FullPageOfflineBlockingView';

export default compose(
withLocalize,
withNetwork(),
)(FullPageOfflineBlockingView);
53 changes: 0 additions & 53 deletions src/components/FullPageOfflineBlockingView.js

This file was deleted.

2 changes: 2 additions & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,8 @@ export default {
chatYouLookingForCannotBeFound: 'The chat you are looking for cannot be found.',
getMeOutOfHere: 'Get me out of here',
iouReportNotFound: 'The payment details you are looking for cannot be found.',
notHere: "Hmm... it's not here",
pageNotFound: 'That page is nowhere to be found.',
},
setPasswordPage: {
enterPassword: 'Enter a password',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,8 @@ export default {
chatYouLookingForCannotBeFound: 'El chat que estás buscando no se ha podido encontrar.',
getMeOutOfHere: 'Sácame de aquí',
iouReportNotFound: 'Los detalles del pago que estás buscando no se han podido encontrar.',
notHere: 'Hmm… no está aquí',
pageNotFound: 'La página que buscas no existe.',
},
setPasswordPage: {
enterPassword: 'Escribe una contraseña',
Expand Down
Empty file removed src/pages/NotFound.js
Empty file.

0 comments on commit 32e67da

Please sign in to comment.