Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
  3. import Icon from "react-native-vector-icons/MaterialIcons";
  4. import CheckIcon from "react-native-vector-icons/SimpleLineIcons";
  5. import colors from '../styles/colors';
  6.  
  7. export default class Cobertura extends Component{
  8.  
  9. constructor(props) {
  10. super(props);
  11. this.state = {
  12. data: props.data,
  13. expanded : false,
  14. }
  15. }
  16.  
  17. render() {
  18. const { handleOnPress, is_bichos } = this.props;
  19. const { nome, status, contratado, utilizado, disponivel, carencia_dias } = this.props.itemCobertura;
  20.  
  21. return (
  22. <View style={{marginTop: 5}}>
  23. <TouchableOpacity style={styles.row} onPress={()=>this.toggleExpand()}>
  24. <View style={ { flexDirection: 'row', alignItems: 'center', width: '90%', backgroundColor: 'transparent'}}>
  25. <View style={{flexDirection: 'row', alignItems: 'center', width: '10%', backgroundColor: 'transparent'}}>
  26. {status == 'COMPLETO' ?
  27. <CheckIcon name={'check'} size={24} color={'#76D362'} />
  28. :
  29. status == 'INCOMPLETO' ?
  30. <CheckIcon name={'close'} size={24} color={'#FF4D35'} />
  31. :
  32. <CheckIcon name={'exclamation'} size={24} color={'#FFAE2F'} />
  33. }
  34. </View>
  35. <View style={{flexDirection: 'row', alignItems: 'center', width: '85%', backgroundColor: 'transparent'}}>
  36. <Text numberOfLines={3} style={[styles.title]}>{nome}</Text>
  37. </View>
  38. </View>
  39. <View style={{flexDirection: 'row',backgroundColor: 'transparent', width: '10%', justifyContent: 'flex-end', alignItems: 'center'}}>
  40. <Icon name={this.state.expanded ? 'keyboard-arrow-up' : 'keyboard-arrow-down'} size={30} color={'#9e9e9e'} />
  41. </View>
  42. </TouchableOpacity>
  43. <View style={styles.parentHr}/>
  44. {
  45. this.state.expanded &&
  46. <View style={{flex: 1}}>
  47. <View style={{flex: 1, flexDirection: 'row', justifyContent: 'space-between', alignItems: 'flex-start', margin: 10}}>
  48. <Text style={ styles.labelContratoUtilizadoEDisponivel}>Contratado</Text>
  49. <Text style={[styles.labelContratoUtilizadoEDisponivel, {borderRightWidth: 1, borderLeftWidth: 1, paddingBottom: 7, borderColor: colors.lightGray}]}>Utilizado</Text>
  50. <Text style={ styles.labelContratoUtilizadoEDisponivel}>Disponível</Text>
  51. </View>
  52. <View style={{flex: 1, flexDirection: 'row', justifyContent: 'space-between', alignItems: 'flex-start', margin: 10, marginTop: -16, marginBottom: 20,backgroundColor: 'transparent'}}>
  53. <Text style={ styles.textContratoUtilizadoEDisponivel}>{contratado}</Text>
  54. <Text style={ styles.textContratoUtilizadoEDisponivel}>{utilizado}</Text>
  55. <Text style={ styles.textContratoUtilizadoEDisponivel}>{disponivel}</Text>
  56. </View>
  57. { is_bichos ?
  58. <View style={[styles.childRow]}>
  59. <Text style={[styles.font]}>{carencia_dias}</Text>
  60. </View>
  61. :
  62. <TouchableOpacity style={[styles.childRow, ]} onPress={handleOnPress}>
  63. <Text style={[styles.font]}>Exibir procedimentos e carências</Text>
  64. <Icon name={'arrow-forward'} size={19} color={'#5E5E5E'} />
  65. </TouchableOpacity>
  66. }
  67. </View>
  68. }
  69.  
  70. </View>
  71. )
  72. }
  73.  
  74. onClick=(index)=>{
  75. const temp = this.state.data.slice()
  76. temp[index].value = !temp[index].value
  77. this.setState({data: temp})
  78. }
  79.  
  80. toggleExpand=()=>{
  81. this.setState({expanded : !this.state.expanded})
  82. }
  83.  
  84. }
  85.  
  86. const styles = StyleSheet.create({
  87. textContratoUtilizadoEDisponivel: {
  88. flex: 1,
  89. textAlign: 'center',
  90. fontFamily: 'Poppins-SemiBold',
  91. color: '#686C71',
  92. fontSize: 15,
  93. },
  94. labelContratoUtilizadoEDisponivel: {
  95. flex: 1,
  96. textAlign: 'center',
  97. fontFamily: 'Poppins-SemiBold',
  98. color: colors.gray08,
  99. fontSize: 15,
  100. },
  101. font:{
  102. fontSize: 15,
  103. color: '#4E5053',
  104. fontFamily: 'Poppins-Medium',
  105. marginRight: 5,
  106. },
  107. title:{
  108. fontSize: 16,
  109. textAlign: 'left',
  110. marginLeft: 7,
  111. color: '#686C71',
  112. fontFamily: 'Poppins-SemiBold',
  113. },
  114. row:{
  115. marginBottom: 10,
  116. flexDirection: 'row',
  117. justifyContent:'space-between',
  118. minHeight: 60,
  119. flex: 1,
  120. paddingLeft:15,
  121. paddingRight:18,
  122. alignItems:'center',
  123. marginRight: 2,
  124. marginLeft: 2,
  125. flexDirection: 'row',
  126. zIndex: 1,
  127. backgroundColor: 'white',
  128. shadowColor: '#000',
  129. shadowOffset: { width: 0, height: 4 },
  130. shadowOpacity: 0.2,
  131. shadowRadius: 4,
  132. elevation: 3,
  133. borderTopLeftRadius: 10,
  134. borderBottomLeftRadius: 10,
  135. borderBottomRightRadius: 10,
  136. borderTopRightRadius: 10,
  137. },
  138. childRow:{
  139. alignItems: 'flex-start',
  140. justifyContent: 'flex-start',
  141. flexDirection: 'row',
  142. marginBottom: 15,
  143. },
  144. parentHr:{
  145. height:1,
  146. color: '#ffffff',
  147. width:'100%'
  148. },
  149. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement