content: import React, { Component } from 'react';
  import {
      View,
      Text,
      TouchableOpacity,
      StyleSheet,
      Linking,
      ToastAndroid,
  } from 'react-native';
  import RNRF, { Actions } from 'react-native-router-flux';
  import Button from 'react-native-button';
  import BilheteService from '../../services/BilheteService';
  
  class SharedBilheteView extends Component {
  
      _onPressButton() {
          Actions.pop();
      }
  
  
      _onCancelarBilhete() {
          let { codigo } = this.props.bilhete;
          this.props.CancelarBilheteAction(codigo)
              .then(response => {
                  if(response.status === 204) {
                      ToastAndroid.show('Bilhete canceado com sucesso', 2000);
                  } else {
                      ToastAndroid.show('Problemas ao cancelar o bilhete', 2000);
                  }
              });
          Actions.pop();
      }
      _onCompartilharWhatsapp() {
  
          let {id, codigo} = this.props.bilhete;
          let texto = encodeURIComponent(`Estamos confirmando seu bilhete ${codigo}. Confira em: http://www.picosdasorte.com/consultaBilhete.aspx`);
          let url = `whatsapp://send?text=${texto}`;
          Linking.canOpenURL(url).then(supported => {
              if (!supported) {
                  ToastAndroid.show('Sem aplicativo instalado', 2000);
              } else {
                  return Linking.openURL(url);
              }
          }).catch(err => console.error('An error occurred', err));
      }
  
      _onImprimirButton() {
  
          let {id, codigo} = this.props.bilhete;
          let callback = encodeURIComponent(`http://www.picosdasorte.com/consultaBilhete.aspx/GetBilhete?idbilhete=${id}`);
          let url = `imprimirep://www.picosdasorte.com/imprimir?idbilhete=${callback}`;
  
          Linking.canOpenURL(url).then(supported => {
              if (!supported) {
                  ToastAndroid.show('Sem o aplicativo de impressao instalado', 2000);
              } else {
                  return Linking.openURL(url);
              }
          }).catch(err => console.error('An error occurred', err));
      }
  
      render() {
  
          let { codigo } = this.props.bilhete;
  
          return (
              <View style={[styles.modal, {flex: 1 , justifyContent: 'center', alignItems: 'center',}]} >
                  <Text>{codigo}</Text>
                  <Button style={styles.btnShared} onPress={this._onImprimirButton.bind(this)}>
                      IMPRIMIR
                  </Button>
                  <Button onPress={this._onCompartilharWhatsapp.bind(this)} style={styles.btnShared} >
                      WHATSAPP
                  </Button>
                  <Button onPress={this._onCancelarBilhete.bind(this)} style={styles.btnShared} >
                      CANCELAR
                  </Button>
                  <View style={{flex: 1,justifyContent: 'flex-end'}} >
                  <Button onPress={this._onPressButton.bind(this)} style={styles.btnShared} >
                      FECHAR
                  </Button>
                  </View>
              </View>
          );
      }
  }
  
  const styles = StyleSheet.create({
      btnShared: {
          height: 48,
          borderWidth: 1,
          borderColor: '#c3c3c3',
          paddingBottom: 8,
          paddingTop: 8,
          alignItems: 'center',
          justifyContent: 'center'
      },
      modal: {
          margin: 8,
          paddingTop: 24,
          padding: 12,
      }
  });
  
  export default SharedBilheteView
  