-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
84 lines (69 loc) · 2.31 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
import * as React from 'react';
import {StyleSheet, ActivityIndicator, SafeAreaView} from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { useEffect, useState } from 'react';
import ErrorScreen from './Components/ErrorScreen';
import CityListCountry from './Components/CityListCountry';
import HomeScreen from './Screens/HomeScreen';
import CitySearchResult from './Screens/CitySearchResult';
import CitySearch from './Screens/CitySearch';
import CountrySearch from './Screens/CountrySearch';
import Country from './Screens/Country';
/**
* The first window in the Stack, with navigation buttons to access search windows.
*
* @param {*} navigation object passed to keep track of navigation state in NavigationContainer
* @returns {SafeAreaView} Home screen with navigation buttons
*/
/**
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
* @param {*} string
* @returns {String} with escaped regexp characters so users will have a harder time
*/
function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}
const Stack = createStackNavigator();
export default function App() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name = "Home"
component = {HomeScreen}
options = {{ title: 'Overview'}}
/>
<Stack.Screen
name = "CitySearch"
component = {CitySearch}
options = {{title: "Search by city name"}}
/>
<Stack.Screen
name = "CountrySearch"
component = {CountrySearch}
options = {{title: "Search by country name"}}
/>
<Stack.Screen
name = "Country"
component = {Country}
options = {{title: "Search results"}}
/>
<Stack.Screen
name = "CitySearchResult"
component = {CitySearchResult}
options = {{title: "Search results"}}
/>
</Stack.Navigator>
</NavigationContainer>
);
}
const styles = StyleSheet.create({
container : {
paddingTop: 30
},
text : {
fontSize : 20
},
standardView : { flex: 1, alignItems: 'center', justifyContent: 'center'}
})