Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from "react";
- import {
- Text,
- StyleSheet,
- Dimensions,
- DrawerLayoutAndroid
- } from "react-native";
- import { View, Input, Item,Container, Tab, Tabs, TabHeading } from "native-
- base";
- import Header from "../../Uicomponents/header";
- import FontAwesome, { Icons } from "react-native-fontawesome";
- const window = Dimensions.get("window");
- import { connect } from "react-redux";
- import Actions from "../../internal/modules/Actions";
- import Sidebar from "../../Uicomponents/sidebar";
- import SearchInput from "../../Uicomponents/NearbyLists/SearchInput";
- import NearByList from "../../Uicomponents/NearbyLists/NearbyList"
- class RestaurantList extends Component {
- constructor(props) {
- super(props);
- this.state = {
- favRest:null,
- selectedRest: null,
- NearbyRestaurants: null,
- loading: true,
- SnacksLoading: this.props.SnacksLoading,
- RestaurantLoading: this.props.RestLoading,
- fetchRestaurantsError: this.props.fetchRestaurantsError,
- fetchSnacksError:this.props.fetchSnacksError
- };
- this.props.getNearbyrestaurants(50.8507855, 4.3539655);
- this.props.getNearbySnacks(50.8507855, 4.3539655);
- }
- componentWillMount() {
- let x= this.props.favList
- if (x) {
- this.setState({
- favRest: x
- })
- }
- }
- componentWillReceiveProps(next) {
- console.log('sajhdgjahs',next)
- if (next.Snacks) {
- this.setState({
- Snacks: next.Snacks,
- SnacksLoading: next.SnacksLoading,
- fetchSnacksError: next.fetchSnacksError
- });
- }
- if (next.favList) {
- this.setState({ favRest: next.favList });
- }
- if (next.Nearby) {
- this.setState({
- NearbyRestaurants: next.Nearby,
- RestaurantLoading: next.RestaurantLoading,
- fetchRestaurantsError: next.fetchRestaurantsError
- });
- }
- if (next.fetchRestaurantsError) {
- this.setState({ fetchRestaurantsError: next.fetchRestaurantsError })
- }
- }
- render() {
- return (
- <DrawerLayoutAndroid
- ref={'DRAWER_REF'}
- drawerWidth={250}
- drawerPosition={DrawerLayoutAndroid.positions.Left}
- renderNavigationView={() => <Sidebar close={()=>
- {this.refs['DRAWER_REF'].closeDrawer();}}
- navigation={this.props.navigation}/>}>
- <View style={{ flex: 1, backgroundColor: this.props.data.theme }}>
- <Header menu={()=>this.refs['DRAWER_REF'].openDrawer()} navigation=
- {this.props.navigation} title={"Restaurants"} />
- <Container style={{backgroundColor:'black'}}>
- <Tabs style={{backgroundColor:'black'}}>
- <Tab style={{backgroundColor:'black'}}
- heading={
- <TabHeading style={{backgroundColor:'black'}}>
- <Text style={{color:'white'}}>Restaurants</Text>
- </TabHeading>}>
- <NearByList
- FavListofUser={this.state.favRest}
- address={'RestaurantDetail'}
- navigation={this.props.navigation}
- addfav={(id)=>{ this.props.addfav(this.props.User_id,id)}}
- removeFav={(id)=>{this.props.removeFav(this.props.User_id,id)}}
- loading={this.state.RestaurantLoading}
- error={this.state.fetchRestaurantsError}
- okok={'jshdjs'}
- ListData={this.state.NearbyRestaurants} />
- </Tab>
- <Tab style={{backgroundColor:'black'}}
- heading={
- <TabHeading style={{backgroundColor:'black'}}>
- <Text style={{color:'white'}}>Snacks</Text>
- </TabHeading>}>
- <NearByList
- FavListofUser={this.state.favRest}
- navigation={this.props.navigation}
- loading={this.state.SnacksLoading}
- address={'SnackDetail'}
- addfav={(id)=>{ this.props.addfav(this.props.User_id,id)}}
- removeFav={(id)=>{this.props.removeFav(this.props.User_id,id)}}
- error={this.state.fetchSnacksError}
- ListData={this.state.Snacks} />
- </Tab>
- </Tabs>
- </Container>
- </View>
- </DrawerLayoutAndroid>
- );
- }
- }
- export default connect(
- state => ({
- data: state.common.get('data'),
- Nearby: state.signin.get('NearbyRest'),
- Snacks: state.signin.get('Snacks'),
- favList: state.common.get('favList'),
- User_id: state.signin.get('User_id'),
- RestLoading: state.signin.get('RestLoading'),
- fetchRestaurantsError: state.signin.get('fetchRestaurantsError'),
- SnacksLoading: state.signin.get('SnacksLoading'),
- fetchSnacksError: state.signin.get('fetchSnacksError')
- }),
- dispatch => ({
- getData: data => dispatch(Actions.common.getData(data)),
- getUserData: data => dispatch(Actions.main.getUserData(data)),
- addfav: (user, place) => dispatch(Actions.common.addFavourite(user,
- place)),
- removeFav: (user, index) => dispatch(Actions.common.removeFavourite(user,
- index)),
- getNearbyrestaurants: (latitude, longitude) =>
- dispatch(Actions.signin.getNearbyrestaurants(latitude, longitude)),
- getNearbySnacks: (latitude, longitude) =>
- dispatch(Actions.signin.getNearbySnacks(latitude, longitude)),
- })
- )(RestaurantList);
Add Comment
Please, Sign In to add comment