Skip to content

Commit d072b21

Browse files
Implement network check
1 parent 8cdab2c commit d072b21

File tree

6 files changed

+45
-1
lines changed

6 files changed

+45
-1
lines changed

licenses.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
"licenseUrl": "https://github.com/react-native-community/react-native-art",
1717
"parents": "opendtu-react-native"
1818
},
19+
"@react-native-community/[email protected]": {
20+
"licenses": "MIT",
21+
"repository": "https://github.com/react-native-netinfo/react-native-netinfo",
22+
"licenseUrl": "https://github.com/react-native-netinfo/react-native-netinfo/raw/master/LICENSE",
23+
"parents": "opendtu-react-native"
24+
},
1925
"@react-native-masked-view/[email protected]": {
2026
"licenses": "MIT",
2127
"repository": "https://github.com/react-native-masked-view/masked-view",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@os-team/i18next-react-native-language-detector": "^1.0.30",
3030
"@react-native-async-storage/async-storage": "^1.19.3",
3131
"@react-native-community/art": "^1.2.0",
32+
"@react-native-community/netinfo": "^11.2.1",
3233
"@react-native-masked-view/masked-view": "^0.3.0",
3334
"@react-navigation/bottom-tabs": "^6.5.9",
3435
"@react-navigation/native": "^6.1.8",

src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { SafeAreaProvider } from 'react-native-safe-area-context';
1414
import SplashScreen from 'react-native-splash-screen';
1515
import { Provider as ReduxProvider } from 'react-redux';
1616

17+
import AppOfflineModal from '@/components/modals/AppOfflineModal';
1718
import EnableAppUpdatesModal from '@/components/modals/EnableAppUpdatesModal';
1819

1920
import ApiProvider from '@/api/ApiHandler';
@@ -243,6 +244,7 @@ const _App: FC = () => {
243244

244245
return (
245246
<PaperProvider theme={theme}>
247+
<AppOfflineModal />
246248
<StatusBar
247249
backgroundColor={theme.colors.background}
248250
barStyle={theme.dark ? 'light-content' : 'dark-content'}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { useNetInfo } from '@react-native-community/netinfo';
2+
3+
import type { FC } from 'react';
4+
import { useTranslation } from 'react-i18next';
5+
import { Box } from 'react-native-flex-layout';
6+
import { Portal, Text } from 'react-native-paper';
7+
8+
import BaseModal from '@/components/BaseModal';
9+
10+
const AppOfflineModal: FC = () => {
11+
const { t } = useTranslation();
12+
const { isConnected } = useNetInfo();
13+
14+
return (
15+
<Portal>
16+
<BaseModal visible={!isConnected} dismissable={false}>
17+
<Box p={16}>
18+
<Box mb={8}>
19+
<Text variant="bodyLarge">{t('offlineModal.title')}</Text>
20+
</Box>
21+
<Box mb={4}>
22+
<Text>{t('offlineModal.description')}</Text>
23+
</Box>
24+
</Box>
25+
</BaseModal>
26+
</Portal>
27+
);
28+
};
29+
30+
export default AppOfflineModal;

src/translations/translation-files

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,6 +2274,11 @@
22742274
prompts "^2.4.0"
22752275
semver "^7.5.2"
22762276

2277+
"@react-native-community/netinfo@^11.2.1":
2278+
version "11.2.1"
2279+
resolved "https://registry.yarnpkg.com/@react-native-community/netinfo/-/netinfo-11.2.1.tgz#177f5409f2ac41fd51ede6e4994307bb0edb2178"
2280+
integrity sha512-n9kgmH7vLaU7Cdo8vGfJGGwhrlgppaOSq5zKj9I7H4k5iRM3aNtwURw83mgrc22Ip7nSye2afZV2xDiIyvHttQ==
2281+
22772282
"@react-native-masked-view/masked-view@^0.3.0":
22782283
version "0.3.0"
22792284
resolved "https://registry.yarnpkg.com/@react-native-masked-view/masked-view/-/masked-view-0.3.0.tgz#bd29fae18d148a685331910a3c7b766ce87eafcc"

0 commit comments

Comments
 (0)