diff --git a/package.json b/package.json index ce0cd58..4408018 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "dependencies": { "native-base": "2.2.0", "prop-types": "^15.5.10", - "react": "16.0.0-alpha.12", + "react": "^16.0.0-alpha.12", "react-burger-menu": "^2.1.3", "react-burger-nav": "^2.0.2", "react-native": "0.45.1", @@ -18,6 +18,7 @@ "react-native-material-ui": "^1.12.0", "react-native-responsive-image": "^2.1.0", "react-native-spinkit": "^1.1.1", + "react-native-vector-icons": "^4.1.1", "react-navigation": "^1.0.0-beta.11", "react-redux": "^5.0.5", "redux": "^3.7.1", diff --git a/src/actions/index.js b/src/actions/index.js index 6e0165b..3480316 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -1,14 +1,27 @@ import { FETCHED_DATA, START_FETCHING } from './types'; - +import {AsyncStorage} from 'react-native'; import Api from '../api/Api'; export const actionFetchData = () => (dispatch) => { dispatch({ type: START_FETCHING }); - Api.getCombinedData(Api.getCategories, Api.getSites, Api.getThumbnail) - .then((data) => { - dispatch({ - type: FETCHED_DATA, - payload: data, - }); - }); + AsyncStorage.getItem('data').then( + (value)=>{ + if(value){ + dispatch({ + type: FETCHED_DATA, + payload: JSON.parse(value), + }); + } + else{ + Api.getCombinedData(Api.getCategories, Api.getSites, Api.getThumbnail) + .then((data) => { + dispatch({ + type: FETCHED_DATA, + payload: data, + }); + AsyncStorage.setItem('data', JSON.stringify(data)); + }); + } + } + ); }; diff --git a/src/components/common/BoxItem.js b/src/components/common/BoxItem.js index eb80f42..c8f589c 100644 --- a/src/components/common/BoxItem.js +++ b/src/components/common/BoxItem.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { StyleSheet, TouchableHighlight, View, Platform } from 'react-native'; +import { StyleSheet, TouchableHighlight, View, Platform, Image } from 'react-native'; import ResponsiveImage from 'react-native-responsive-image'; import { UNKNOWN } from '../../../img/index'; @@ -33,11 +33,15 @@ class Item extends Component { return ( - + {/* + /> */} ); diff --git a/src/reducers/data_reducer.js b/src/reducers/data_reducer.js index 045c855..0f427c1 100644 --- a/src/reducers/data_reducer.js +++ b/src/reducers/data_reducer.js @@ -6,17 +6,20 @@ const InitialState = { }; export default (state = InitialState, action) => { + let result = Object.assign({}, state); switch (action.type) { case FETCHED_DATA: - return Object.assign({}, state, { - categories: action.payload, - isFetching: false, - }); + return { + ...result, + categories: action.payload, + isFetching: false, + }; case START_FETCHING: - return Object.assign({}, state, { - categories: [], - isFetching: true, - }); + return { + ...result, + categories: [], + isFetching: true, + }; default: return state; }