diff --git a/RNApp/app/components/Map/Map.js b/RNApp/app/components/Map/Map.js index 6fee157..d0606aa 100644 --- a/RNApp/app/components/Map/Map.js +++ b/RNApp/app/components/Map/Map.js @@ -139,7 +139,7 @@ class Map extends Component { @@ -151,7 +151,7 @@ class Map extends Component { tiles.push( @@ -161,8 +161,8 @@ class Map extends Component { } return ( - - + + { const { titleText, figureText, detailText, image, tileType, - onPress, containsGraph, data, containsPercentage, percentage } = props; + onPress, navigator, containsGraph, data, containsPercentage, percentage } = props; + + var navigate = () => { + if (tileType == 'country') { + props.navigator.push(Routes.getCountryRoute(props.titleText)); + } + } + return ( - + {/* Main tile view */} @@ -41,6 +49,7 @@ const Tile = (props) => { + } {/* If there is graph data, display the graph */} {containsGraph && } @@ -83,6 +92,7 @@ Tile.propTypes = { image: React.PropTypes.number, tileType: React.PropTypes.string, onPress: React.PropTypes.func, + navigator: React.PropTypes.object, containsGraph: React.PropTypes.bool, data: React.PropTypes.array, containsPercentage: React.PropTypes.bool, diff --git a/RNApp/app/components/TopBar/TopBar.js b/RNApp/app/components/TopBar/TopBar.js index 07cd659..3709abc 100644 --- a/RNApp/app/components/TopBar/TopBar.js +++ b/RNApp/app/components/TopBar/TopBar.js @@ -1,31 +1,49 @@ import React from 'react'; -import { Text, TouchableOpacity, View } from 'react-native'; +import { Text, TouchableOpacity, View, Image} from 'react-native'; import styles from './styles'; +import Routes from '../../config/routes'; +import images from '../../config/images'; const TopBar = (props) => { + const onPress = () => { + props.navigator.pop(); + }; + const getBackButton = () => { if (props.back) { return ( - + + + + + + {props.title} + + ); } else { - return; + return ( + + {props.title} + + ); } }; return ( - + {getBackButton()} - - {props.title} - - ); }; TopBar.propTypes = { title: React.PropTypes.string, + back: React.PropTypes.bool, + navigator: React.PropTypes.object, }; diff --git a/RNApp/app/components/TopBar/styles.js b/RNApp/app/components/TopBar/styles.js index 8c57bdf..b24ff44 100644 --- a/RNApp/app/components/TopBar/styles.js +++ b/RNApp/app/components/TopBar/styles.js @@ -11,23 +11,34 @@ export default StyleSheet.create({ height: 50, }, topbarText: { - fontSize: 25, + fontSize: 25, fontWeight:'bold', color:'white', textAlign:'center', }, + topbarTextWithBack: { + marginLeft: 10, + }, topbarTextWrapper: { flex:0, width:Dimensions.get('window').width, - alignItems:'center' + alignItems:'center', }, back: { - position:'absolute', - backgroundColor: colors.countryArrow, + position:'absolute', + backgroundColor: colors.countryMain, alignSelf:'flex-start', width:50, height:50, + alignItems: 'center', + top: -10, + justifyContent:'center', }, - - + backArrow: { + tintColor: 'white', + width:40, + height:40, + top:0, + left:0, + } }); \ No newline at end of file diff --git a/RNApp/app/config/images.js b/RNApp/app/config/images.js index 8395685..a393e6e 100644 --- a/RNApp/app/config/images.js +++ b/RNApp/app/config/images.js @@ -11,6 +11,7 @@ const images = { profileHeader: require('../images/header-image.png'), avatarPlaceholder: require('../images/avatar-placeholder.png'), worldMap: require('../images/world-map.png'), + backArrow: require('../images/back.png'), countryIcons: { afg: require('../images/country-icons/afg.png'), ago: require('../images/country-icons/ago.png'), diff --git a/RNApp/app/config/routes.js b/RNApp/app/config/routes.js index 3f71040..7f14504 100644 --- a/RNApp/app/config/routes.js +++ b/RNApp/app/config/routes.js @@ -3,6 +3,9 @@ import MapView from '../routes/MapView'; import Geolocator from '../routes/Geolocator'; import Search from '../routes/Search'; import About from '../routes/About'; +import Map from '../components/Map'; +import CountryToId from './countryToId'; +import CountryCodes from './countryCodes'; export const routes = { getSearchRoute() { @@ -44,16 +47,37 @@ export const routes = { showNavigationBar: false, }; }, - getGeolocationRoute() { + getGeolocationRoute(countryName) { return { renderScene(navigator) { - return ; + return ; }, getTitle() { return 'Geolocator'; }, + showNavigationBar: false, + }; + }, + getCountryRoute(countryName) { + countryIso3Code = CountryToId[countryName].toUpperCase(); + var countryIso2Code = ""; + + for (code in CountryCodes) { + if (CountryCodes[code] == countryIso3Code) { + countryIso2Code = code; + } + } + return { + renderScene(navigator) { + return ; + }, + + getTitle() { + return 'Country'; + }, + showNavigationBar: false, }; }, diff --git a/RNApp/app/images/back.png b/RNApp/app/images/back.png new file mode 100644 index 0000000..3c0586b Binary files /dev/null and b/RNApp/app/images/back.png differ diff --git a/RNApp/app/routes/MapView/MapView.js b/RNApp/app/routes/MapView/MapView.js index ed7febb..79128c6 100644 --- a/RNApp/app/routes/MapView/MapView.js +++ b/RNApp/app/routes/MapView/MapView.js @@ -8,7 +8,7 @@ const MapView = (props) => { return (
- + ); }; @@ -16,6 +16,7 @@ const MapView = (props) => { MapView.propTypes = { country: React.PropTypes.string, back: React.PropTypes.bool, + navigator: React.PropTypes.object, }; export default MapView; diff --git a/RNApp/app/routes/MapView/MapViewContainer.js b/RNApp/app/routes/MapView/MapViewContainer.js index 2a3b4d0..44a80aa 100644 --- a/RNApp/app/routes/MapView/MapViewContainer.js +++ b/RNApp/app/routes/MapView/MapViewContainer.js @@ -4,7 +4,7 @@ import Routes from '../../config/routes'; const MapViewContainer = (props) => { return ( - + ); }; diff --git a/RNApp/app/routes/Search/Search.js b/RNApp/app/routes/Search/Search.js index 1f7b58a..dee47f0 100644 --- a/RNApp/app/routes/Search/Search.js +++ b/RNApp/app/routes/Search/Search.js @@ -9,6 +9,7 @@ import CountryCodes from './../../config/countryCodes'; import Countries from './../../config/countries'; import CountryToId from './../../config/countryToId'; import images from './../../config/images'; +import Routes from '../../config/routes'; class Search extends React.Component { @@ -33,10 +34,10 @@ componentDidMount() { for (var countryName in CountryToId){ var countryCode = CountryToId[countryName]; i = i + 1; - newArr.push( - - - + + var tile = this.makeTile(countryName, images.countryIcons[countryCode], i); + + newArr.push(tile ); } this.setState({allTilesArr: newArr}); @@ -46,10 +47,10 @@ componentDidMount() { if (countryName.includes(searchTermVal)) { var countryCode = CountryToId[countryName]; i = i + 1; - newArr.push( - - - + + var tile = this.makeTile(countryName, images.countryIcons[countryCode], i); + + newArr.push(tile ); } } @@ -62,6 +63,12 @@ componentDidMount() { this.populateTiles(searchTermVal); } + makeTile(countryName, imageDir, i) { + return + + + } + render() { return ( @@ -81,4 +88,6 @@ Search.propTypes = { handleSearchTermUpdateHa: React.PropTypes.func, }; + + export default Search; diff --git a/RNApp/app/routes/Search/SearchContainer.js b/RNApp/app/routes/Search/SearchContainer.js index 5a79a83..8bdf450 100644 --- a/RNApp/app/routes/Search/SearchContainer.js +++ b/RNApp/app/routes/Search/SearchContainer.js @@ -5,6 +5,7 @@ import Routes from '../../config/routes'; const SearchContainer = (props) => { return ( props.navigator.push(Routes.getDetailsRoute())} /> );