-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSplash.js
70 lines (65 loc) · 1.51 KB
/
Splash.js
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
import React, { useEffect } from 'react';
import {
View,
Text,
StyleSheet,
Animated,
Image
} from 'react-native';
import { useNavigation } from '@react-navigation/native';
import SplashScreen from 'react-native-splash-screen';
const Splash = () => {
const navigation = useNavigation();
const opacity = new Animated.Value(0);
useEffect(() => {
Animated.timing(opacity, {
toValue: 1,
duration: 3500,
useNativeDriver: true
}).start(() => {
if (SplashScreen && typeof SplashScreen.hide === 'function') {
SplashScreen.hide();
}
navigation.reset({
index: 0,
routes: [{ name: 'Login' }],
});
});
}, [navigation, opacity]);
return (
<View style={styles.container}>
<Animated.Image
source={require('./assets/logo.png')}
style={[styles.logo, { opacity: opacity }]}
/>
<Animated.Text style={[styles.appName, { opacity: opacity }]}>DOMANT</Animated.Text>
<Animated.Text style={[styles.appTitle, { opacity: opacity }]}>Chat App</Animated.Text>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#333'
},
logo: {
width: 300,
height: 300,
resizeMode: 'contain'
},
appName: {
fontSize: 30,
fontWeight: 'bold',
marginTop: 10,
color: '#FFF'
},
appTitle: {
fontSize: 17,
fontWeight: 'bold',
marginTop: 6,
color: '#FFF'
}
});
export default Splash;