Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import {
- AppRegistry,
- StyleSheet,
- Text,
- View,
- ListView,
- Image,
- ActivityIndicator,
- TouchableHighlight,
- Platform,
- dismissKeyboard,
- Dimensions,
- TouchableOpacity,
- ScrollView
- } from 'react-native';
- import {Navigation} from 'react-native-navigation';
- import LoadMore from './LoadMore';
- import Header from './Header';
- import { Bubbles, DoubleBounce, Bars, Pulse } from 'react-native-loader';
- const background = require('../../../img/OTP-bg.png');
- import { Card , COLOR, TYPO} from 'react-native-material-design';
- import { Container, Content, Button, Icon } from 'native-base';
- import {TextInputMask} from 'react-native-masked-text';
- const HomeSlider = require('../../../img/slider_02.png');
- const affroadbleRates = require('../../../img/a_03.png');
- const logoPng = require('../../../img/sdad_03.png');
- const ac_rooms = require('../../../img/a_19.png');
- const breakfast = require('../../../img/a_07.png');
- const freewifi = require('../../../img/a_22.png');
- const tv = require('../../../img/a_16.png');
- const linen = require('../../../img/a_13.png');
- const wshroom = require('../../../img/a_10.png');
- const { width, he0ight } = Dimensions.get("window");
- var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
- export default class HomeGadget extends Component {
- constructor(props) {
- super(props);
- this.onPressRow = this.onPressRow.bind(this)
- this.renderRow = this.renderRow.bind(this)
- }
- componentWillMount() {
- this.setState({
- Top_destinations: ds.cloneWithRows([]),
- featured_property: ds.cloneWithRows([]),
- hot_deals: ds.cloneWithRows([]),
- Property_Type : ds.cloneWithRows([]),
- isLoading : false,
- });
- }
- componentDidMount() {
- this.DestinationsAsync(this.props.DesURL);
- }
- onPressRow = (rowData) => {
- this.props.navigator.push({
- title: rowData.name,
- screen: "yohobed.Search_Component",
- passProps: {
- lat : rowData.latitude,
- lon : rowData.longitude,
- id : rowData.id,
- city : rowData.name,
- },
- navigatorStyle: {
- navBarTextColor: '#fff', // change the text color of the title (remembered across pushes)
- navBarBackgroundColor: '#00b0bf', // change the background color of the nav bar (remembered across pushes)
- navBarButtonColor: '#fff',
- },
- });
- }
- onPressRow2 = (rowData) => {
- this.props.navigator.push({
- screen: "yohobed.Single_Property",
- passProps: {
- image : rowData.thumbnail_url,
- City : rowData.city,
- id : rowData.id,
- name : rowData.name,
- price : rowData.min_price_LKR
- },
- navigatorStyle: {
- navBarTextColor: '#fff', // change the text color of the title (remembered across pushes)
- navBarBackgroundColor: '#00b0bf', // change the background color of the nav bar (remembered across pushes)
- navBarButtonColor: '#fff',
- },
- });
- }
- onPressRow3 = (rowData) => {
- this.props.navigator.push({
- title: rowData.city_name,
- screen: "yohobed.Tiles",
- passProps: {
- image : rowData.thumbnail,
- name : rowData.name,
- id : rowData.id,
- title : rowData.title,
- },
- });
- }
- onPressRow4 = (rowData) => {
- this.props.navigator.push({
- title: rowData.name,
- screen: "yohobed.Search_Component",
- passProps: {
- Type : rowData.name,
- },
- navigatorStyle: {
- navBarTextColor: '#fff',
- navBarBackgroundColor: '#00b0bf',
- navBarButtonColor: '#fff',
- },
- });
- }
- async DestinationsAsync(url) {
- let response = await fetch(url);
- let body = await response.json();
- this.setState({
- Top_destinations: this.state.Top_destinations.cloneWithRows(body.top_destinations),
- featured_property: this.state.featured_property.cloneWithRows(body.featured_property),
- Property_Type: this.state.Property_Type.cloneWithRows(body.featued_property_types),
- //hot_deals: this.state.hot_deals.cloneWithRows(jsonData.hot_deals),
- isLoading : true,
- });
- }
- renderLoadingView() {
- return (
- <View style={{flex:1, justifyContent:'center', alignItems:'center'}}>
- <Bars size={20} color="#00b0bf"/>
- </View>
- );
- }
- renderPropertyType(rowData: {}, sectionID: number, rowID: number){
- return (
- <View>
- <TouchableOpacity underlayColor={'#eaeaea'} onPress ={() => this.onPressRow4(rowData)} style={styles.touchableViewOpacity}>
- <Card style={{width:200, shadowColor:"#ccc", shadowOffset:{width:1, height:1}, shadowOpacity:0.8}}>
- <Card.Media
- image={<Image source={{uri:'https://www.yohobed.com/images/propertytype/'+rowData.thumbnail}} style={styles.touchableImage}/>}
- overlay
- >
- </Card.Media>
- <Card.Body>
- <View>
- <Text style={{fontSize:12, fontFamily: 'Lato-Regular', color:'#666'}}>{rowData.name}</Text>
- </View>
- </Card.Body>
- </Card>
- </TouchableOpacity>
- </View>
- );
- }
- renderRow(rowData: {}, sectionID: number, rowID: number){
- return (
- <View>
- <TouchableOpacity underlayColor={'#eaeaea'} onPress ={() => this.onPressRow(rowData)} style={styles.touchableViewOpacity}>
- <Card style={{width:200, shadowColor:"#ccc", shadowOffset:{width:1, height:1}, shadowOpacity:0.8}}>
- <Card.Media
- image={<Image source={{uri:'https://www.yohobed.com/images/cities/'+rowData.thumbnail_url}} style={styles.touchableImage}/>}
- overlay
- >
- </Card.Media>
- <Card.Body>
- <View>
- <Text style={{fontSize:12, fontFamily: 'Lato-Regular', color:'#666'}}>{rowData.name}</Text>
- </View>
- </Card.Body>
- </Card>
- </TouchableOpacity>
- </View>
- );
- }
- renderProperty(rowData: {}, sectionID: number, rowID: number){
- return (
- <TouchableOpacity style={styles.touchableViewOpacity} underlayColor={'#eaeaea'} onPress ={() => this.onPressRow2(rowData)}>
- <Card style={{width:200, shadowColor:"#ccc", shadowOffset:{width:1, height:1}, shadowOpacity:0.8}}>
- <Card.Media
- image={<Image source={{uri:'https://www.yohobed.com/images/property/thumbnail/'+rowData.thumbnail_url}} style={styles.touchableImage}/>}
- >
- <View style={{position:'absolute', bottom:0, left:0,backgroundColor:'#00b0bf'}}>
- <Text style={{color:'#fff', fontSize:11, width:100, fontFamily: 'Lato-Regular', paddingLeft:10, paddingTop:3}}>Starting</Text>
- <TextInputMask
- style={{color:'#fff', fontSize:12, width:100, fontFamily: 'Lato-Regular', padding:10}}
- value={rowData.min_price_LKR}
- editable ={false}
- type={'money'}
- options={{
- precision: 0,
- unit : 'LKR ',
- delimiter: ','
- }}
- />
- </View>
- </Card.Media>
- <Card.Body>
- <View>
- <View style={{}}>
- <Text style={{color:'#666', fontSize:12, fontSize:12, fontFamily: 'Lato-Regular'}}>{rowData.name}</Text>
- </View>
- </View>
- <Text style={{color:'#666', fontSize:12, fontSize:12, fontFamily: 'Lato-Light', marginTop:5}}>{rowData.city}</Text>
- </Card.Body>
- </Card>
- </TouchableOpacity>
- );
- }
- renderdeals(rowData: {}, sectionID: number, rowID: number){
- return (
- <TouchableHighlight style={styles.touchableViewOpacity} underlayColor={'#eaeaea'} onPress ={() => this.onPressRow3(rowData)}>
- <View style={styles.touchableViewWrapr}>
- <Image
- source={{uri:'https://www.yohobed.com/images/cities/'+rowData.thumbnail_url}} resizeMode="cover" style={styles.touchableImage}/>
- <View style={styles.bottomContainer}>
- <Text style={styles.touchableTxt}>{rowData.id}</Text>
- <Text style={styles.touchableTxt}>{rowData.name}</Text>
- <Text style={styles.touchableTxt}>{rowData.title}</Text>
- </View>
- </View>
- </TouchableHighlight>
- );
- }
- render(){
- if(!this.state.isLoading){
- return this.renderLoadingView();
- }
- return (
- <View style={{flex:1}}>
- <ScrollView>
- <View style={styles.mainImageWrpr}>
- <Image source={HomeSlider} style={styles.topImage}>
- </Image>
- <View style={styles.logoCenter}>
- <Image source={logoPng} style={styles.logoImage}>
- </Image>
- </View>
- <View style={styles.motoCenter}>
- <Image source={affroadbleRates} style={styles.motoImage}>
- </Image>
- </View>
- </View>
- <View style={styles.amenintiesWrpr}>
- <Text style={styles.amentiesMainText}>FEATURES IN ALL ROOMS</Text>
- <View style={{width:100, height:2, backgroundColor:'#fff', position:'absolute', left:10, top:16, opacity:0.8}}></View>
- <View style={{width:100, height:2, backgroundColor:'#fff', position:'absolute', right:10, top:16, opacity:0.8}}></View>
- <View style={styles.amentiesIconWrpr}>
- <View style={{width:35, justifyContent:'center', alignItems:'center', marginRight:15, marginTop:4}}>
- <Image source={ac_rooms} style={{width:22, resizeMode:'contain', height:18}}>
- </Image>
- <Text style={{textAlign:'center', fontFamily:'Lato-Bold', color:'#fff', fontSize:11, marginTop:2}}>AC {"\n"}Rooms</Text>
- </View>
- <View style={{width:50, justifyContent:'center', alignItems:'center', marginRight:15, marginTop:-8}}>
- <Image source={breakfast} style={{width:12, resizeMode:'contain', height:20}}>
- </Image>
- <Text style={{textAlign:'center', fontFamily:'Lato-Bold', color:'#fff', fontSize:11, marginTop:2}}>Breakfast</Text>
- </View>
- <View style={{width:35, justifyContent:'center', alignItems:'center', marginRight:15}}>
- <Image source={freewifi} style={{width:16, resizeMode:'contain', height:20}}>
- </Image>
- <Text style={{textAlign:'center', fontFamily:'Lato-Bold', color:'#fff', fontSize:11}}>Free {"\n"}Wi-Fi</Text>
- </View>
- <View style={{width:35, justifyContent:'center', alignItems:'center', marginRight:15, marginTop:-10}}>
- <Image source={tv} style={{width:19, resizeMode:'contain', height:20}}>
- </Image>
- <Text style={{textAlign:'center', fontFamily:'Lato-Bold', color:'#fff', fontSize:11}}>TV</Text>
- </View>
- <View style={{width:50, justifyContent:'center', alignItems:'center', marginRight:15, marginTop:6}}>
- <Image source={linen} style={{width:22, resizeMode:'contain', height:16}}>
- </Image>
- <Text style={{textAlign:'center', fontFamily:'Lato-Bold', color:'#fff', fontSize:11, marginTop:2}}>Spotless {"\n"}Linen</Text>
- </View>
- <View style={{width:60, justifyContent:'center', alignItems:'center'}}>
- <Image source={wshroom} style={{width:13, resizeMode:'contain', height:18}}>
- </Image>
- <Text style={{textAlign:'center', fontFamily:'Lato-Bold', color:'#fff', fontSize:11, marginTop:2}}>Clean {"\n"}Washrooms</Text>
- </View>
- </View>
- </View>
- <Text style={styles.MainTextWrprMain}>Top Destinations</Text>
- <ListView
- dataSource={this.state.Top_destinations}
- renderRow={(rowData) => this.renderRow(rowData)}
- style={styles.container}
- navigator={this.props.navigator}
- horizontal = {true}
- />
- <Text style={styles.MainTextWrpr}>Featured Properties</Text>
- <ListView
- dataSource={this.state.featured_property}
- renderRow={(rowData) => this.renderProperty(rowData)}
- style={styles.container}
- navigator={this.props.navigator}
- horizontal = {true}
- />
- {/*<Text style={styles.MainTextWrpr}>Property Types</Text>
- <ListView
- dataSource={this.state.Property_Type}
- renderRow={(rowData) => this.renderPropertyType(rowData)}
- style={styles.container}
- navigator={this.props.navigator}
- horizontal = {true}
- />*/}
- </ScrollView>
- </View>
- );
- }
- }
- const styles = StyleSheet.create({
- container: {
- backgroundColor: '#fff',
- paddingLeft:10,
- paddingRight:10
- },
- amentiesIconWrpr:{
- justifyContent:'center',
- alignItems:'center',
- flexDirection:'row',
- position:'relative'
- },
- amentiesMainText:{
- fontFamily:'Lato-Bold',
- color:'#fff',
- textAlign:'center',
- fontSize:11,
- marginBottom:5
- },
- amenintiesWrpr:{
- backgroundColor:'#00b0bf',
- opacity:0.8,
- padding:10
- },
- topImage:{
- height:134,
- resizeMode:'contain',
- width:width
- },
- logoCenter:{
- position: 'absolute',
- top: 0,
- left: 0,
- right: 0,
- justifyContent: 'center',
- alignItems: 'center',
- },
- motoCenter:{
- position: 'absolute',
- top: 50,
- left: 0,
- right: 0,
- justifyContent: 'center',
- alignItems: 'center',
- },
- logoImage:{
- width:80,
- resizeMode:'contain'
- },
- motoImage:{
- width:180,
- resizeMode:'contain'
- },
- mainImageWrpr:{
- position:'relative',
- },
- homeWrpr:{
- paddingLeft:10,
- paddingRight:10,
- paddingTop:15,
- backgroundColor: '#fff',
- },
- bottomContainerMain:{
- flexDirection:'row'
- },
- textInnerWrpr:{
- },
- bottomContainer:{
- padding:10
- },
- MainTextWrprMain:{
- color:'#666',
- backgroundColor:'#fff',
- paddingLeft:20,
- paddingTop:20,
- fontFamily: 'Lato-Regular',
- fontSize:17
- },
- MainTextWrpr:{
- color:'#666',
- backgroundColor:'#fff',
- paddingLeft:20,
- fontFamily: 'Lato-Regular',
- fontSize:17,
- paddingTop:15
- },
- thumb: {
- backgroundColor: '#ffffff',
- marginBottom: 5,
- elevation: 1,
- },
- img: {
- height: 300
- },
- txt: {
- margin: 10,
- fontSize: 12,
- textAlign: 'left'
- },
- touchableViewOpacity:{
- backgroundColor:'#FFFFFF',
- marginTop:10,
- marginBottom:10,
- flexDirection:'row'
- },
- touchableViewWrapr:{
- width:200
- },
- touchableViewWraprMain:{
- width:200,
- },
- touchableImage:{
- width: null,
- height:150
- },
- touchableTxt:{
- width:width,
- backgroundColor:'transparent',
- color:'#666',
- fontSize:12
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement