-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
78 lines (67 loc) · 2.05 KB
/
App.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
71
72
73
74
75
76
77
78
import React, { useEffect } from 'react';
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View, Image } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
const Stack = createNativeStackNavigator();
function IntroductionPage({ navigation }) {
useEffect(() => {
// Thiết lập một timer để chuyển đến HomePage sau 10 giây
const timer = setTimeout(() => {
navigation.navigate('HomePage');
}, 10000);
// Dọn dẹp timer khi component bị unmount
return () => clearTimeout(timer);
}, [navigation]);
return (
<View style={styles.container}>
<Text>Hi, I'm Diep!</Text>
<Text>I'm a Java Developer.</Text>
<Image
source={require('./assets/cat.png')} // Đường dẫn tới ảnh trong thư mục dự án
style={styles.image}
/>
<StatusBar style="auto" />
{/* Nút điều hướng đến trang Home */}
<Text style={styles.linkText} onPress={() => navigation.navigate('HomePage')}>
Go to Home Page
</Text>
</View>
);
}
function HomePage() {
return (
<View style={styles.container}>
<Text>Welcome to the Home Page!</Text>
</View>
);
}
export default function App() {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="IntroductionPage">
<Stack.Screen name="IntroductionPage" component={IntroductionPage} />
<Stack.Screen name="HomePage" component={HomePage} />
</Stack.Navigator>
</NavigationContainer>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
image: {
width: 200,
height: 200,
resizeMode: 'contain', // Giữ nguyên tỷ lệ ảnh
marginTop: 20, // Khoảng cách giữa ảnh và văn bản trên
},
linkText: {
marginTop: 20,
color: 'blue',
textDecorationLine: 'underline',
},
});