locaft_mobile/components/UserProfile.js

236 lines
6.0 KiB
JavaScript
Raw Normal View History

2022-05-09 10:21:05 -07:00
import React, {useState, useEffect} from 'react';
2022-05-25 21:15:54 -07:00
import {Icon, SearchBar} from 'react-native-elements';
2022-05-26 10:55:04 -07:00
import {
StatusBar,
Dimensions,
StyleSheet,
Text,
View,
TouchableHighlight,
FlatList,
} from 'react-native';
2022-05-25 21:15:54 -07:00
import HouseCard from './helpers/HouseCard';
2022-05-09 10:21:05 -07:00
2022-05-14 09:26:15 -07:00
const deviceWidth = Math.round(Dimensions.get('window').width);
const homes = [
{
name: 'Prestiage Villas',
categories: 'Desserts, Cakes and Bakery',
deliveryTime: '35 min',
distance: '3.7 km',
image: require('../assets/house_1.jpg'),
id: 1,
},
{
name: 'lakeView Apartment 203',
categories: 'Beverages, Desserts, Cakes and Bakery',
deliveryTime: '45 min',
distance: '4.3 km',
image: require('../assets/house_2.jpg'),
id: 2,
},
{
name: 'Central Villas',
categories: 'Cakes and Bakery, American, Sandwiches, Burgers',
deliveryTime: '25 min',
distance: '3 km',
image: require('../assets/house_1.jpg'),
id: 3,
},
{
2022-05-25 21:15:54 -07:00
name: 'grand flat 405',
2022-05-14 09:26:15 -07:00
categories: 'Fast Food, Burgers, Desserts',
deliveryTime: '20 min',
distance: '2.5 km',
image: require('../assets/house_2.jpg'),
id: 4,
},
{
name: 'exlusive villa',
categories: 'Fast Food, Burgers, Desserts',
deliveryTime: '25 min',
distance: '3.1 km',
image: require('../assets/house_1.jpg'),
id: 5,
},
];
const UserProfile = ({navigation}) => {
2022-05-26 10:55:04 -07:00
const [search, setSearch] = React.useState('');;
const [loading, setLoading] = React.useState(false);;
const [searchData, setSearchData] = React.useState([]);;
const [tempSearchData, setTempSearchData] = React.useState([]);;
const [error, setError] = React.useState(null);;
2022-05-25 21:15:54 -07:00
const renderHeader = () => {
return (
<SearchBar
placeholder="Search Here..."
lightTheme
round
editable={true}
value={search}
onChangeText={setSearch}
2022-05-26 10:55:04 -07:00
platform="android"
2022-05-25 21:15:54 -07:00
/>
);
};
2022-05-26 10:55:04 -07:00
const updateSearch = search => {
this.setState({search}, () => {
if (search == '') {
this.setState({
data: [...this.state.temp],
2022-05-25 21:15:54 -07:00
});
2022-05-26 10:55:04 -07:00
return;
}
this.state.data = this.state.temp
.filter(function (item) {
return item.name.includes(search);
})
.map(function ({id, name, email}) {
return {id, name, email};
});
});
2022-05-25 21:15:54 -07:00
};
2022-05-09 10:21:05 -07:00
return (
<>
<StatusBar backgroundColor="#ffffff" barStyle="dark-content" />
<View style={styles.viewRoot}>
2022-05-14 09:26:15 -07:00
<View style={styles.iconContainer}>
2022-05-09 10:21:05 -07:00
<TouchableHighlight
onPress={() => navigation.goBack()}
2022-05-26 10:55:04 -07:00
underlayColor="white"
activeOpacity={0.5}>
2022-05-09 10:21:05 -07:00
<Icon name="arrow-back" type="ionicon" size={36} color="#206ba5" />
</TouchableHighlight>
2022-05-14 09:26:15 -07:00
<TouchableHighlight
onPress={() => navigation.goBack()}
2022-05-26 10:55:04 -07:00
underlayColor="white"
activeOpacity={0.5}>
2022-05-25 21:15:54 -07:00
<Icon
name="settings-outline"
type="ionicon"
size={36}
color="#206ba5"
/>
2022-05-14 09:26:15 -07:00
</TouchableHighlight>
</View>
2022-05-25 21:15:54 -07:00
<View style={styles.headingContainer}>
<Text style={styles.heading}>John Doe</Text>
<Text style={styles.subHeading}>Tenant</Text>
2022-05-14 09:26:15 -07:00
2022-05-25 21:15:54 -07:00
<View style={{flexDirection: 'row', marginTop: 30}}>
<Icon name="card-outline" type="ionicon" size={36} color="brown" />
<Text style={[styles.pricingHeading]}>Basic Member</Text>
</View>
2022-05-26 10:55:04 -07:00
<View style={{flexDirection: 'row', marginTop: 30,justifyContent: "space-evenly"}}>
<View style={styles.twoColContainer}>
<Text style={[styles.twoColHeading]}>Past Houses</Text>
<Text style={[styles.twoColNumber]}>3</Text>
</View>
<View style={styles.verticalLine} />
<View style={styles.twoColContainer}>
<Text style={[styles.twoColHeading]}>Requested</Text>
<Text style={[styles.twoColNumber]}>5</Text>
</View>
</View>
2022-05-25 21:15:54 -07:00
</View>
2022-05-14 09:26:15 -07:00
<View style={styles.cardContainer}>
{/* <Card /> */}
<StatusBar barStyle="dark-content" />
<FlatList
data={homes}
renderItem={({item}) => {
return <HouseCard info={item} />;
}}
2022-05-25 21:15:54 -07:00
keyExtractor={house => house.id.toString()}
2022-05-14 09:26:15 -07:00
showsVerticalScrollIndicator={false}
/>
2022-05-09 10:21:05 -07:00
</View>
</View>
</>
);
};
const styles = StyleSheet.create({
viewRoot: {
backgroundColor: '#ffffff',
justifyContent: 'center',
height: '100%',
flex: 1,
},
2022-05-14 09:26:15 -07:00
iconContainer: {
width: deviceWidth,
height: 60,
backgroundColor: 'white',
justifyContent: 'space-between',
paddingBottom: 20,
paddingLeft: 5,
paddingRight: 5,
flexDirection: 'row',
},
labelStyle: {
fontSize: 24,
fontWeight: '700',
},
headingContainer: {
2022-05-25 21:15:54 -07:00
marginLeft: 20,
},
2022-05-09 10:21:05 -07:00
heading: {
color: '#1C254E',
fontSize: 60,
2022-05-14 09:26:15 -07:00
textAlign: 'left',
2022-05-09 10:21:05 -07:00
fontFamily: 'Ubuntu-Bold',
},
2022-05-14 09:26:15 -07:00
subHeading: {
color: '#1C254E',
fontSize: 30,
textAlign: 'left',
fontFamily: 'Ubuntu-Regular',
},
pricingHeading: {
color: 'brown',
fontSize: 30,
2022-05-26 10:55:04 -07:00
textAlign: 'center',
2022-05-14 09:26:15 -07:00
fontFamily: 'Ubuntu-Regular',
paddingLeft: 10,
},
2022-05-09 10:21:05 -07:00
icon: {
alignSelf: 'flex-start',
marginLeft: '28%',
flexDirection: 'row',
},
2022-05-26 10:55:04 -07:00
twoColContainer: {
flexDirection: 'column',
alignItems: 'center',
marginLeft: -40,
},
twoColHeading: {
color: '#1C254E',
fontSize: 28,
textAlign: 'left',
fontFamily: 'Ubuntu-Regular',
},
twoColNumber: {
textAlign: 'center',
fontSize: 55,
textAlign: 'left',
fontFamily: 'Ubuntu-Regular',
color: '#206ba5',
},
2022-05-14 09:26:15 -07:00
cardContainer: {
flex: 1,
backgroundColor: 'white',
2022-05-09 10:21:05 -07:00
alignItems: 'center',
2022-05-14 09:26:15 -07:00
// justifyContent: 'center',
2022-05-09 10:21:05 -07:00
},
2022-05-26 10:55:04 -07:00
verticalLine: {
marginLeft: -40,
height: '100%',
width: 5,
backgroundColor: '#206ba5',
},
2022-05-09 10:21:05 -07:00
});
export default UserProfile;