-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
61 lines (54 loc) · 1.53 KB
/
App.tsx
File metadata and controls
61 lines (54 loc) · 1.53 KB
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
import React, {useEffect, useState} from 'react';
import {StyleSheet, Text, View} from 'react-native';
import NetInfo from '@react-native-community/netinfo';
import {StatusUpBar} from 'components/StatusBar/StatusUpBar';
import {colorBase} from 'enums/AppColors';
import Navigation from 'navigation/Navigation';
import {SetupPlayer} from 'services/TrackPlayerService/SetupPlayer';
import SplashScreen from 'react-native-splash-screen';
const App = () => {
const [isConnected, setIsConnected] = useState<any>(true);
useEffect(() => {
// SplashScreen.hide();
// Agrega un listener para detectar cambios en la conexión
const unsubscribe = NetInfo.addEventListener(state => {
setIsConnected(state.isConnected);
});
return () => unsubscribe();
}, []);
useEffect(() => {
SplashScreen.hide();
SetupPlayer();
}, []);
return (
<View style={styles.appContainer}>
<StatusUpBar backgroundColor={colorBase} />
{!isConnected && (
<View style={styles.noInternet}>
<Text style={styles.textNoInternet}>
No Internet connection please reconnect..!
</Text>
</View>
)}
{isConnected && <Navigation />}
</View>
);
};
export default App;
const styles = StyleSheet.create({
appContainer: {
flex: 1,
backgroundColor: colorBase,
},
noInternet: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: `${colorBase}`,
},
textNoInternet: {
color: 'white',
fontSize: 18,
fontWeight: 'bold',
},
});