-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
executable file
·74 lines (65 loc) · 2.53 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
import { StatusBar } from "expo-status-bar";
import {
NavigationContainer,
useNavigationContainerRef,
} from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { useFonts } from "expo-font";
import HomeScreen from './screens/HomeScreen';
import CompareLocationsScreen from './screens/CompareLocations';
import SeeLocationScreen from './screens/SeeLocationScreen';
import OptionsLocationScreen from './screens/OptionsLocationScreen';
const Stack = createNativeStackNavigator();
import BottomTab from './components/BottomTab'
import {useState} from 'react'
export default function App() {
const [fontsLoaded] = useFonts({
"VarelaRound-Regular": require("./assets/fonts/VarelaRound-Regular.ttf"),
});
const navigationRef = useNavigationContainerRef();
let routeNameRef;
const [routeName, setRouteName] = useState('');
const options = { headerTintColor: 'white', headerStyle: { backgroundColor: '#2C2727' } };
return (
<>
<StatusBar style="light" />
<NavigationContainer
ref={navigationRef}
onReady={() => {
routeNameRef = navigationRef.getCurrentRoute().name;
// console.log(routeNameRef);
setRouteName(routeNameRef);
}}
onStateChange={async () => {
const previousRouteName = routeNameRef.current;
const currentRouteName = navigationRef.getCurrentRoute().name;
const trackScreenView = () => {
// Your implementation of analytics goes here!
};
if (previousRouteName !== currentRouteName) {
// Save the current route name for later comparison
routeNameRef = currentRouteName;
// Replace the line below to add the tracker from a mobile analytics SDK
await trackScreenView(currentRouteName);
}
}}
>
<Stack.Navigator initialRouteName="Home" >
<Stack.Screen name="Home" component={HomeScreen} options={options}/>
<Stack.Screen
name="CompareLocations"
component={CompareLocationsScreen}
options={options}
/>
<Stack.Screen
name="SearchLocation"
component={OptionsLocationScreen}
options={options}
/>
<Stack.Screen name="SeeLocation" component={SeeLocationScreen} options={options} valorEstrella={4}/>
</Stack.Navigator>
<BottomTab currentRouteName={routeName} navigationRef={navigationRef}/>
</NavigationContainer>
</>
);
}