Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import {
- StyleSheet,
- View,
- Text,
- TouchableOpacity,
- BackHandler,
- Image,
- ScrollView,
- ActivityIndicator,
- FlatList
- } from 'react-native';
- import {
- Container,
- Header,
- CardItem,
- Left,
- Body,
- Thumbnail,
- } from 'native-base';
- import { withNavigation } from 'react-navigation';
- import Axios from 'axios';
- class Home extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- isLoading: false,
- id: '',
- card_member:'',
- member_code: '',
- referral_code: '',
- name: '',
- place: '',
- date_of_birth: '',
- religion: '',
- address:'',
- phone_number: '',
- phone_home: '',
- phone_office: '',
- image: '',
- email: '',
- password: '',
- data: [],
- renders: []
- };
- }
- static navigationOptions = {
- headerStyle: {
- headerTintColor: '#E91E63',
- },
- headerTitleStyle: {
- fontWeight: 'bold',
- },
- };
- // async componentDidMount(){
- // const token = await AsyncStorage.getItem('token')
- // // api profile
- // const url = 'http://192.168.56.1/vzuu/public/api/members'
- // headers = {'Authorization': 'Bearer ' + token,}
- // fetch(url, headers, {method:'GET'})
- // .then(data=>data.json())
- // .then(res=> {
- // console.log(res.results.members);
- // // dari selesai fetching api profile
- // setTimeout(()=>{this.setState({isLoading:false})},100)
- // this.setState({memberSource: res.results.members})
- // })
- // .catch(err=>console.warn({err}))
- // }
- ComponentWillMount() {
- BackHandler.addEventListener('hardwareBackPress', () => {
- if (!this.onMainScreen()) {
- this.goBack();
- return true;
- }
- return false;
- });
- }
- async componentDidMount(){
- const token = await AsyncStorage.getItem('token')
- headers = {'Authorization': 'Bearer ' + token }
- this.makeRemoteRequest();
- }
- makeRemoteRequest = () => {
- // api profile
- const url = 'http://192.168.56.1/vzuu/public/api/members'
- // headers = {'Authorization': 'Bearer ' + token }
- fetch(url, headers, {method:'GET'})
- .then(data=>data.json())
- .then(res=> {
- console.log(res.results.members);
- // dari selesai fetching api profile
- setTimeout(()=>{this.setState({loading:false})},1000)
- this.setState({
- data: res.results.members,
- renders: res.results.members.data,
- })
- console.log(this.state.data);
- })
- .catch(err=>console.warn({err}))
- }
- render() {
- return (
- <Container>
- <View>
- <Header style={{ backgroundColor: '#E91E63' }} />
- {this.state.isLoading
- ? <ActivityIndicator color='#E91E63' size='large' />
- :
- <ScrollView>
- <View style={{ flex: 1, alignItems: 'center' }}>
- <Text style={{ fontSize: 16 }}>{this.state.curTime}</Text>
- </View>
- <CardItem>
- <View style={{ marginHorizontal: 10 }}></View>
- <FlatList
- data={this.state.renders}
- renderItem={({ item }) => (
- <Left>
- {/* <Thumbnail
- style={{ width: 80, height: 80 }}
- source={{uri : this.state.image}}
- /> */}
- <Body>
- <Text style={styles.text}>{item.name}</Text>
- <Text style={styles.text}>{item.phone_number}</Text>
- {/* <Text>Jumlah Point</Text> */}
- </Body>
- </Left>
- )}
- />
- </CardItem>
- <View
- style={{
- flexDirection: 'row',
- flexWrap: 'wrap',
- marginHorizontal: 50,
- marginTop: 50,
- }}></View>
- <View
- style={{
- flexDirection: 'row',
- flexWrap: 'wrap',
- marginHorizontal: 18,
- marginTop: 18,
- }}>
- <View
- style={{
- justifyContent: 'space-between',
- flexDirection: 'row',
- width: '100%',
- marginBottom: 18,
- }}>
- <View>
- <TouchableOpacity onPress={() => this.props.navigation.navigate('treatment')}>
- <View
- style={{
- width: 100,
- height: 100,
- borderWidth: 1,
- borderColor: '#EFEFEF',
- borderRadius: 18,
- }}>
- <Image
- source={require('../asset/images/color/service.png')}
- style={{ height: 80, width: 100, flex: 1 }}
- />
- </View>
- <Text
- style={{
- fontSize: 12,
- fontWeight: 'bold',
- textAlign: 'center',
- color: '#E91E63',
- }}>
- Treatment
- </Text>
- </TouchableOpacity>
- </View>
- <View>
- <TouchableOpacity onPress={() => this.props.navigation.navigate('booking')}>
- <View
- style={{
- width: 100,
- height: 100,
- borderWidth: 1,
- borderColor: '#EFEFEF',
- borderRadius: 18,
- }}>
- <Image
- source={require('../asset/images/color/booking.png')}
- style={{ height: 80, width: 100, flex: 1 }}
- />
- </View>
- <Text
- style={{
- fontSize: 12,
- fontWeight: 'bold',
- textAlign: 'center',
- color: '#E91E63',
- }}>
- Booking
- </Text>
- </TouchableOpacity>
- </View>
- <View>
- <TouchableOpacity onPress={() => this.props.navigation.navigate('promotion')}>
- <View
- style={{
- width: 100,
- height: 100,
- borderWidth: 1,
- borderColor: '#EFEFEF',
- borderRadius: 18,
- }}>
- <Image
- source={require('../asset/images/color/promo.png')}
- style={{ height: 80, width: 100, flex: 1 }}
- />
- </View>
- <Text
- style={{
- fontSize: 12,
- fontWeight: 'bold',
- textAlign: 'center',
- color: '#E91E63',
- }}>
- Promotion
- </Text>
- </TouchableOpacity>
- </View>
- </View>
- </View>
- <View
- style={{
- flexDirection: 'row',
- flexWrap: 'wrap',
- marginHorizontal: 18,
- marginTop: 18,
- }}>
- <View
- style={{
- justifyContent: 'space-between',
- flexDirection: 'row',
- width: '100%',
- marginBottom: 18,
- }}>
- <View>
- <TouchableOpacity onPress={() => this.props.navigation.navigate('point')}>
- <View
- style={{
- width: 100,
- height: 100,
- borderWidth: 1,
- borderColor: '#EFEFEF',
- borderRadius: 18,
- }}>
- <Image
- source={require('../asset/images/color/point.png')}
- style={{ height: 80, width: 100, flex: 1 }}
- />
- </View>
- <Text
- style={{
- fontSize: 12,
- fontWeight: 'bold',
- textAlign: 'center',
- color: '#E91E63',
- }}>
- Point
- </Text>
- </TouchableOpacity>
- </View>
- <View>
- <TouchableOpacity>
- <View
- style={{
- width: 100,
- height: 100,
- borderWidth: 1,
- borderColor: '#EFEFEF',
- borderRadius: 18,
- }}>
- <Image
- source={require('../asset/images/color/spin.png')}
- style={{ height: 80, width: 100, flex: 1 }}
- />
- </View>
- <Text
- style={{
- fontSize: 12,
- fontWeight: 'bold',
- textAlign: 'center',
- color: '#E91E63',
- }}>
- Spin
- </Text>
- </TouchableOpacity>
- </View>
- <View>
- <TouchableOpacity onPress={() => this.props.navigation.navigate('contact')}>
- <View
- style={{
- width: 100,
- height: 100,
- borderWidth: 1,
- borderColor: '#EFEFEF',
- borderRadius: 18,
- }}>
- <Image
- source={require('../asset/images/color/contact.png')}
- style={{ height: 80, width: 100, flex: 1 }}
- />
- </View>
- <Text
- style={{
- fontSize: 12,
- fontWeight: 'bold',
- textAlign: 'center',
- color: '#E91E63',
- }}>
- Contact
- </Text>
- </TouchableOpacity>
- </View>
- </View>
- </View>
- </ScrollView>
- }
- </View>
- </Container>
- );
- }
- }
- export default withNavigation(Home);
- const styles = StyleSheet.create({
- container: {
- flex: 1,
- justifyContent: 'center',
- alignItems: 'center',
- },
- text: { fontSize: 18, fontWeight:'bold', color: '#E91E63', alignItems: 'center', justifyContent: 'center' }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement