Created
February 11, 2019 15:38
-
-
Save iiagodias/54ea43653b72542573c5dbf54cd132d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component} from 'react'; | |
import {Text, View, Image, TouchableOpacity, AsyncStorage, Alert} from 'react-native'; | |
import styles from './styles'; | |
import Icon from 'react-native-vector-icons/FontAwesome5'; | |
import Loading from '../../components/Loading'; | |
export default class Inicio extends Component { | |
state ={ | |
info: [], | |
modalVisible: false, | |
} | |
async componentDidMount(){ | |
this.setState({modalVisible: true}); | |
try { | |
const dados = await AsyncStorage.getItem("@BuscaBelem:usuario"); | |
const result = JSON.parse(dados); | |
const body = new FormData(); | |
body.append('id', result.data.resultado.id); | |
const response = await fetch('https://www.buscabelem.com.br/api/empresa_total.php', { | |
method: 'POST', | |
headers:{ | |
token: result.data.resultado.token | |
}, | |
body | |
}); | |
const json = await response.json(); | |
if(json.status){ | |
this.setState({info: json.resultado}); | |
this.setState({modalVisible: false}); | |
}else{ | |
this.setState({modalVisible: false}); | |
Alert.alert("Erro", "Verifique sua conexão."); | |
} | |
} catch (error) { | |
this.setState({modalVisible: false}); | |
Alert.alert("Erro", "Verifique sua conexão."); | |
} | |
} | |
render() { | |
return ( | |
<View style={styles.container} > | |
<Loading visible={this.state.modalVisible} /> | |
<View style={styles.Header}> | |
<View> | |
<Icon onPress={() => this.props.navigation.openDrawer()} name="bars" size={18} color="#fff" /> | |
</View> | |
<View> | |
<Image | |
style={{width: 40, height: 40}} | |
source={require('../../imagem/marca.png')} | |
/> | |
</View> | |
<View></View> | |
</View> | |
<View style={styles.corpoContain}> | |
<View style={styles.boxCatego}> | |
<TouchableOpacity onPress={() => this.props.navigation.navigate("Empresa")} style={[styles.bntCategoria, styles.coloBlue, styles.containDisable]} activeOpacity={0.5} disabled> | |
<Icon name="building" size={18} color="#fff" /> | |
<Text ellipsizeMode='tail' numberOfLines={1} style={styles.txtBntCat}>Institucional</Text> | |
<View style={[styles.boxQuanti, styles.radiusBlue]}> | |
<Text ellipsizeMode='tail' numberOfLines={1} style={[styles.txtQuantidade, styles.txtBlue]}> | |
0 | |
</Text> | |
</View> | |
</TouchableOpacity> | |
<TouchableOpacity style={[styles.bntCategoria, styles.coloRed, styles.containDisable]} activeOpacity={0.5} disabled> | |
<Icon name="shipping-fast" size={18} color="#fff" /> | |
<Text style={styles.txtBntCat}>Delivery</Text> | |
<View style={[styles.boxQuanti, styles.radiusRed]}> | |
<Text style={[styles.txtQuantidade, styles.txtRed]}> | |
{console.log(this.state.info.institucional)} | |
</Text> | |
</View> | |
</TouchableOpacity> | |
<TouchableOpacity style={[styles.bntCategoria, styles.coloOrange]} activeOpacity={0.5} > | |
<Icon name="home" size={18} color="#fff" /> | |
<Text style={styles.txtBntCat}>Imoveis</Text> | |
<View style={[styles.boxQuanti, styles.radiusOrange]}> | |
<Text style={[styles.txtQuantidade, styles.txtOrange]}> | |
0 | |
</Text> | |
</View> | |
</TouchableOpacity> | |
<TouchableOpacity style={[styles.bntCategoria, styles.coloGreen]} activeOpacity={0.5}> | |
<Icon name="car-alt" size={18} color="#fff" /> | |
<Text style={styles.txtBntCat}>Veículo</Text> | |
<View style={[styles.boxQuanti, styles.radiusGreen]}> | |
<Text style={[styles.txtQuantidade, styles.txtGreen]}> | |
0 | |
</Text> | |
</View> | |
</TouchableOpacity> | |
</View> | |
</View> | |
</View> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment