-
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 #9649 from Expensify/arosiclair-full-page-not-foun…
…d-view Add FullPageNotFoundView
- Loading branch information
Showing
7 changed files
with
134 additions
and
53 deletions.
There are no files selected for viewing
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,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; |
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,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
41
src/components/BlockingViews/FullPageOfflineBlockingView.js
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,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); |
This file was deleted.
Oops, something went wrong.
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
Empty file.