-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
FullPageNotFoundView.tsx
89 lines (74 loc) · 3.12 KB
/
FullPageNotFoundView.tsx
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
89
import React from 'react';
import {View} from 'react-native';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import * as Illustrations from '@components/Icon/Illustrations';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import variables from '@styles/variables';
import type {TranslationPaths} from '@src/languages/types';
import BlockingView from './BlockingView';
import ForceFullScreenView from './ForceFullScreenView';
type FullPageNotFoundViewProps = {
/** Child elements */
children?: React.ReactNode;
/** If true, child components are replaced with a blocking "not found" view */
shouldShow?: boolean;
/** The key in the translations file to use for the title */
titleKey?: TranslationPaths;
/** The key in the translations file to use for the subtitle */
subtitleKey?: TranslationPaths;
/** Whether we should show a link to navigate elsewhere */
shouldShowLink?: boolean;
/** Whether we should show the back button on the header */
shouldShowBackButton?: boolean;
/** The key in the translations file to use for the go back link */
linkKey?: TranslationPaths;
/** Method to trigger when pressing the back button of the header */
onBackButtonPress?: () => void;
/** Function to call when pressing the navigation link */
onLinkPress?: () => void;
/** Whether we should force the full page view */
shouldForceFullScreen?: boolean;
};
// eslint-disable-next-line rulesdir/no-negated-variables
function FullPageNotFoundView({
children = null,
shouldShow = false,
titleKey = 'notFound.notHere',
subtitleKey = 'notFound.pageNotFound',
linkKey = 'notFound.goBackHome',
onBackButtonPress = () => Navigation.goBack(),
shouldShowLink = true,
shouldShowBackButton = true,
onLinkPress = () => Navigation.dismissModal(),
shouldForceFullScreen = false,
}: FullPageNotFoundViewProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
if (shouldShow) {
return (
<ForceFullScreenView shouldForceFullScreen={shouldForceFullScreen}>
<HeaderWithBackButton
onBackButtonPress={onBackButtonPress}
shouldShowBackButton={shouldShowBackButton}
/>
<View style={[styles.flex1, styles.blockingViewContainer]}>
<BlockingView
icon={Illustrations.ToddBehindCloud}
iconWidth={variables.modalTopIconWidth}
iconHeight={variables.modalTopIconHeight}
title={translate(titleKey)}
subtitle={translate(subtitleKey)}
linkKey={linkKey}
shouldShowLink={shouldShowLink}
onLinkPress={onLinkPress}
/>
</View>
</ForceFullScreenView>
);
}
return children;
}
FullPageNotFoundView.displayName = 'FullPageNotFoundView';
export default FullPageNotFoundView;