daily pastebin goal
47%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from "react";
  2. import {
  3.  Text,
  4.  StyleSheet,
  5.  Dimensions,
  6.  DrawerLayoutAndroid
  7.  } from "react-native";
  8.  import { View, Input, Item,Container, Tab, Tabs, TabHeading } from "native-
  9.  base";
  10.  import Header from "../../Uicomponents/header";
  11.  import FontAwesome, { Icons } from "react-native-fontawesome";
  12.   const window = Dimensions.get("window");
  13.  import { connect } from "react-redux";
  14.  import Actions from "../../internal/modules/Actions";
  15.  import Sidebar from "../../Uicomponents/sidebar";
  16.  import SearchInput from "../../Uicomponents/NearbyLists/SearchInput";
  17.  import NearByList from "../../Uicomponents/NearbyLists/NearbyList"
  18.  class RestaurantList extends Component {
  19.  
  20.    constructor(props) {
  21. super(props);
  22. this.state = {
  23.   favRest:null,
  24.   selectedRest: null,
  25.   NearbyRestaurants: null,
  26.   loading: true,
  27.   SnacksLoading: this.props.SnacksLoading,
  28.   RestaurantLoading: this.props.RestLoading,
  29.   fetchRestaurantsError: this.props.fetchRestaurantsError,
  30.   fetchSnacksError:this.props.fetchSnacksError
  31. };
  32. this.props.getNearbyrestaurants(50.8507855, 4.3539655);
  33. this.props.getNearbySnacks(50.8507855, 4.3539655);
  34.    }
  35.  
  36.    componentWillMount() {
  37.  
  38. let x= this.props.favList
  39. if (x) {
  40.   this.setState({
  41.     favRest: x
  42.   })
  43. }
  44. }
  45.  
  46.  componentWillReceiveProps(next) {
  47. console.log('sajhdgjahs',next)
  48. if (next.Snacks) {
  49.   this.setState({
  50.     Snacks: next.Snacks,
  51.     SnacksLoading: next.SnacksLoading,
  52.     fetchSnacksError: next.fetchSnacksError
  53.   });
  54. }
  55. if (next.favList) {
  56.     this.setState({ favRest: next.favList });
  57.   }
  58.  
  59. if (next.Nearby) {
  60.   this.setState({
  61.     NearbyRestaurants: next.Nearby,
  62.     RestaurantLoading: next.RestaurantLoading,
  63.     fetchRestaurantsError: next.fetchRestaurantsError
  64.   });
  65. }
  66. if (next.fetchRestaurantsError) {
  67.   this.setState({ fetchRestaurantsError: next.fetchRestaurantsError })
  68. }
  69. }
  70.  
  71. render() {
  72. return (
  73.   <DrawerLayoutAndroid
  74.   ref={'DRAWER_REF'}
  75.   drawerWidth={250}
  76.   drawerPosition={DrawerLayoutAndroid.positions.Left}
  77.   renderNavigationView={() => <Sidebar  close={()=>      
  78.  {this.refs['DRAWER_REF'].closeDrawer();}}
  79.   navigation={this.props.navigation}/>}>
  80.   <View style={{ flex: 1, backgroundColor: this.props.data.theme }}>
  81.     <Header menu={()=>this.refs['DRAWER_REF'].openDrawer()} navigation=
  82.   {this.props.navigation} title={"Restaurants"} />
  83.     <Container style={{backgroundColor:'black'}}>
  84.     <Tabs  style={{backgroundColor:'black'}}>
  85.     <Tab style={{backgroundColor:'black'}}
  86.       heading={
  87.       <TabHeading style={{backgroundColor:'black'}}>
  88.       <Text style={{color:'white'}}>Restaurants</Text>
  89.       </TabHeading>}>
  90.  
  91.       <NearByList
  92.       FavListofUser={this.state.favRest}
  93.       address={'RestaurantDetail'}
  94.       navigation={this.props.navigation}
  95.       addfav={(id)=>{ this.props.addfav(this.props.User_id,id)}}
  96.       removeFav={(id)=>{this.props.removeFav(this.props.User_id,id)}}
  97.       loading={this.state.RestaurantLoading}
  98.       error={this.state.fetchRestaurantsError}
  99.       okok={'jshdjs'}
  100.       ListData={this.state.NearbyRestaurants} />
  101.  
  102.       </Tab>
  103.       <Tab style={{backgroundColor:'black'}}
  104.        heading={
  105.       <TabHeading style={{backgroundColor:'black'}}>
  106.       <Text style={{color:'white'}}>Snacks</Text>
  107.       </TabHeading>}>
  108.  
  109.       <NearByList
  110.       FavListofUser={this.state.favRest}
  111.       navigation={this.props.navigation}
  112.       loading={this.state.SnacksLoading}
  113.       address={'SnackDetail'}
  114.       addfav={(id)=>{ this.props.addfav(this.props.User_id,id)}}
  115.       removeFav={(id)=>{this.props.removeFav(this.props.User_id,id)}}
  116.       error={this.state.fetchSnacksError}
  117.       ListData={this.state.Snacks} />
  118.  
  119.       </Tab>
  120.     </Tabs>
  121.     </Container>
  122.    </View>
  123.   </DrawerLayoutAndroid>
  124. );
  125.     }
  126.   }
  127.  
  128.  export default connect(
  129.    state => ({
  130.      data: state.common.get('data'),
  131.      Nearby: state.signin.get('NearbyRest'),
  132.      Snacks: state.signin.get('Snacks'),
  133.      favList: state.common.get('favList'),
  134.      User_id: state.signin.get('User_id'),
  135.      RestLoading: state.signin.get('RestLoading'),
  136.      fetchRestaurantsError: state.signin.get('fetchRestaurantsError'),
  137.      SnacksLoading: state.signin.get('SnacksLoading'),
  138.      fetchSnacksError: state.signin.get('fetchSnacksError')
  139.  
  140.    }),
  141.    dispatch => ({
  142.      getData: data => dispatch(Actions.common.getData(data)),
  143.      getUserData: data => dispatch(Actions.main.getUserData(data)),
  144.      addfav: (user, place) => dispatch(Actions.common.addFavourite(user,                                                    
  145.     place)),
  146.       removeFav: (user, index) => dispatch(Actions.common.removeFavourite(user,      
  147.   index)),
  148.             getNearbyrestaurants: (latitude, longitude) =>      
  149.    dispatch(Actions.signin.getNearbyrestaurants(latitude, longitude)),
  150.   getNearbySnacks: (latitude, longitude) =>
  151.  dispatch(Actions.signin.getNearbySnacks(latitude, longitude)),
  152.  
  153.  })
  154.  )(RestaurantList);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top