-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
193 lines (179 loc) · 5.71 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import React, { useEffect, useState } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import HomeScreen from './Screens/HomeScreen'; // Import HomeScreen
import RewardScreen from './Screens/RewardScreen'; // Import RewardScreen
import AppoinmentScreen from './Screens/AppoinmentScreen';
import Icon from 'react-native-vector-icons/Ionicons';
import { View, StyleSheet, Text } from 'react-native';
import AppIntroSlider from 'react-native-app-intro-slider';
import LottieView from 'lottie-react-native';
import LoginScreen from './Screens/LoginScreen';
export default function App() {
const [showSplash, setShowSplash] = useState(true);
const [showIntro, setShowIntro] = useState(true);
const [isLoggedIn, setIsLoggedIn] = useState(false);
const Stack = createNativeStackNavigator();
const Tab = createBottomTabNavigator();
useEffect(() => {
if (showSplash) {
setTimeout(() => {
setShowSplash(false); // After the splash, show the intro slider
}, 3000); // Splash screen duration: 3 seconds
}
}, [showSplash]);
// Data for intro slides
const slides = [
{
key: '1',
title: 'Schedule Doctor Appointments',
text: 'Book appointments with your preferred doctors hassle-free. Choose from a list of experienced healthcare professionals.',
backgroundColor: '#1E3A8A',
lottieFile: require('./assets/online_appointment.json'),
},
{
key: '2',
title: 'Never Miss a Dose',
text: 'Set up personalized medicine reminders to ensure you never miss a dose. Stay on top of your treatment plan with timely notifications.',
backgroundColor: '#0E7490',
lottieFile: require('./assets/dose.json'),
},
{
key: '3',
title: 'Smart Health Checkup',
text: 'Experience the future of healthcare with our smart checkup feature. Get instant health insights and personalized recommendations.',
backgroundColor: '#047857',
lottieFile: require('./assets/checkup.json')
},
];
const renderSlide = ({ item }) => (
<View style={[styles.slide, { backgroundColor: item.backgroundColor }]}>
<LottieView
source={item.lottieFile} // Dynamic Lottie file
autoPlay
loop
style={styles.lottie}
/>
<Text style={styles.title}>{item.title}</Text>
<Text style={styles.text}>{item.text}</Text>
</View>
);
if (showSplash) {
return (
<View style={styles.splashContainer}>
<LottieView
source={require('./assets/doctor.json')} // Dynamic Lottie file
autoPlay
loop
style={styles.lottie}
/>
<Text style={styles.splashText}>Health Desk</Text>
</View>
);
}
if (showIntro) {
return (
<AppIntroSlider
renderItem={renderSlide}
data={slides}
onDone={() => setShowIntro(false)} // Move to main app when done
showSkipButton
onSkip={() => setShowIntro(false)} // Allow skipping the intro
/>
);
}
return (
<NavigationContainer>
{!isLoggedIn ? (
<Stack.Navigator>
<Stack.Screen
name="Login"
options={{ headerShown: false }}
>
{props => <LoginScreen {...props} setIsLoggedIn={setIsLoggedIn} />}
</Stack.Screen>
</Stack.Navigator>
) : (
<Tab.Navigator>
<Tab.Screen
name="Home"
component={HomeStack}
options={{
headerShown: false,
tabBarIcon: ({ color, size }) => <Icon name="home-outline" size={size} color={color} />,
}}
/>
<Tab.Screen
name="Rewards"
component={RewardScreen}
options={{
tabBarIcon: ({ color, size }) => <Icon name="trophy-outline" size={size} color={color} />, tabBarButton: (props) => <View {...props} />
}}
/>
<Tab.Screen
name="Device"
component={RewardScreen}
options={{
tabBarIcon: ({ color, size }) => <Icon name="watch-outline" size={size} color={color} />,tabBarButton: (props) => <View {...props} />
}}
/>
<Tab.Screen
name="Profile"
component={RewardScreen}
options={{
tabBarIcon: ({ color, size }) => <Icon name="person-outline" size={size} color={color} />,tabBarButton: (props) => <View {...props} />
}}
/>
</Tab.Navigator>
)}
</NavigationContainer>
);
}
// HomeStack Navigator that includes both HomeScreen and AppointmentScreen
function HomeStack() {
const Stack = createNativeStackNavigator();
return (
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen} options={{ headerShown: false }}/>
<Stack.Screen name="Appointment" component={AppoinmentScreen} options={{headerTitle:'Create Appoinment'}} />
<Stack.Screen name='Login' component={LoginScreen}/>
</Stack.Navigator>
);
}
const styles = StyleSheet.create({
splashContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#1E3A8A',
},
splashText: {
fontSize: 36,
fontWeight: 'bold',
color: '#fff',
},
slide: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: 20,
},
title: {
fontSize: 24,
fontWeight: 'bold',
color: '#fff',
textAlign: 'center',
marginBottom: 10,
},
text: {
fontSize: 16,
color: '#fff',
textAlign: 'center',
},
lottie: {
width: 250, // Adjust size as needed
height: 250,
marginBottom: 20, // Space between the Lottie animation and the title
},
});