File tree Expand file tree Collapse file tree 7 files changed +87
-1
lines changed Expand file tree Collapse file tree 7 files changed +87
-1
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * @format
3+ */
4+ /* eslint-env jest */
5+
6+ const defaultState = {
7+ type : 'cellular' ,
8+ isConnected : true ,
9+ isInternetReachable : true ,
10+ details : {
11+ isConnectionExpensive : true ,
12+ cellularGeneration : '3g' ,
13+ } ,
14+ } ;
15+
16+ const NetInfoStateType = {
17+ unknown : 'unknown' ,
18+ none : 'none' ,
19+ cellular : 'cellular' ,
20+ wifi : 'wifi' ,
21+ bluetooth : 'bluetooth' ,
22+ ethernet : 'ethernet' ,
23+ wimax : 'wimax' ,
24+ vpn : 'vpn' ,
25+ other : 'other' ,
26+ } ;
27+
28+ const RNCNetInfoMock = {
29+ NetInfoStateType,
30+ configure : jest . fn ( ) ,
31+ fetch : jest . fn ( ) ,
32+ refresh : jest . fn ( ) ,
33+ addEventListener : jest . fn ( ) ,
34+ useNetInfo : jest . fn ( ) ,
35+ } ;
36+
37+ RNCNetInfoMock . fetch . mockResolvedValue ( defaultState ) ;
38+ RNCNetInfoMock . refresh . mockResolvedValue ( defaultState ) ;
39+ RNCNetInfoMock . useNetInfo . mockReturnValue ( defaultState ) ;
40+ RNCNetInfoMock . addEventListener . mockReturnValue ( jest . fn ( ) ) ;
41+
42+ module . exports = RNCNetInfoMock ;
Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { SafeAreaProvider } from 'react-native-safe-area-context';
1414import SplashScreen from 'react-native-splash-screen' ;
1515import { Provider as ReduxProvider } from 'react-redux' ;
1616
17+ import AppOfflineModal from '@/components/modals/AppOfflineModal' ;
1718import EnableAppUpdatesModal from '@/components/modals/EnableAppUpdatesModal' ;
1819
1920import 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' }
Original file line number Diff line number Diff line change 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 ;
Original file line number Diff line number Diff line change 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"
You can’t perform that action at this time.
0 commit comments