From d984a9c836d707fccbcffc74ec6041dad50985a0 Mon Sep 17 00:00:00 2001 From: Ronyell Henrique Date: Sun, 22 Apr 2018 18:35:12 -0300 Subject: [PATCH] #164 - Composing items for scheduled visits and counselors related to it Co-authored-by: Ronyell Co-authored-by: ThalissonMelo --- src/components/Button.js | 16 ++-- src/components/ScheduleCard.js | 83 +++++++++++++++++++ .../startInspection/StartExpiredInspection.js | 4 +- .../startInspection/StartPendingInspection.js | 8 +- 4 files changed, 100 insertions(+), 11 deletions(-) create mode 100644 src/components/ScheduleCard.js diff --git a/src/components/Button.js b/src/components/Button.js index 946d2c1..b904178 100644 --- a/src/components/Button.js +++ b/src/components/Button.js @@ -6,15 +6,21 @@ import styles from '../Styles/GeneralStyles'; class Button extends React.Component { defineStyle() { - if (this.props.enabled) { + if(this.props.style === undefined){ + this.props.style.text = styles.buttonText; + if (this.props.enabled) { + return ( + styles.bigButton + ); + } return ( - styles.bigButton + styles.disabledBigButton ); } - return ( - styles.disabledBigButton + this.props.style.design ); + } render() { @@ -26,7 +32,7 @@ class Button extends React.Component { disabled={!this.props.enabled} onPress={() => this.props.onPress()} > - {this.props.text} + {this.props.text} ); diff --git a/src/components/ScheduleCard.js b/src/components/ScheduleCard.js new file mode 100644 index 0000000..7303480 --- /dev/null +++ b/src/components/ScheduleCard.js @@ -0,0 +1,83 @@ +import React from 'react'; +import { Text, View, TouchableOpacity, StyleSheet } from 'react-native'; +import { Actions } from 'react-native-router-flux'; +import PropTypes from 'prop-types'; + +const styles = StyleSheet.create({ + listSchedule: { + flex: 1, + marginHorizontal: 15, + marginVertical: 10, + borderColor: 'black', + borderWidth: 1, + borderRadius: 3, + backgroundColor: '#FAFAFA', + justifyContent: 'space-between', + flexDirection: 'row', + alignItems: 'center', + }, + + textBox: { + flex: 4, + paddingLeft: 4, + justifyContent: 'flex-start', + marginRight: 15, + }, + + text: { + fontSize: 15, + paddingVertical: 2, + }, +}); + +class ScheduleCard extends React.Component { + constructor(props) { + super(props); + this.state = { + data: {}, + counselor: this.props.counselor, + }; + } + + render(){ + return( + + + { + this.props.data.map( (item) =>( + + {item.label} + {item.value} + + ) + )} + + {this.props.children} + + ); + } +} + +ScheduleCard.propTypes = { + data: PropTypes.arrayOf(PropTypes.shape({ + label: PropTypes.string.isRequired, + value: PropTypes.string.isRequired + })).isRequired, + keyProp: PropTypes.string.isRequired, + counselor: PropTypes.shape({ + name: PropTypes.string.isRequired, + email: PropTypes.string.isRequired, + token: PropTypes.string.isRequired, + nuvemCode: PropTypes.number.isRequired, + profile: PropTypes.shape({ + cpf: PropTypes.string.isRequired, + phone: PropTypes.string.isRequired, + isPresident: PropTypes.bool.isRequired, + segment: PropTypes.string.isRequired, + CAE: PropTypes.string.isRequired, + CAE_Type: PropTypes.string, + }).isRequired, + }).isRequired, +}; + +export default ScheduleCard; \ No newline at end of file diff --git a/src/screens/startInspection/StartExpiredInspection.js b/src/screens/startInspection/StartExpiredInspection.js index d414ce6..26d1df8 100644 --- a/src/screens/startInspection/StartExpiredInspection.js +++ b/src/screens/startInspection/StartExpiredInspection.js @@ -63,7 +63,7 @@ class StartExpiredInspection extends React.Component { @@ -87,7 +87,7 @@ class StartExpiredInspection extends React.Component { } } - getData(visitSchedule) { + getVisitData(visitSchedule) { let data = [ { label: 'Escola:', diff --git a/src/screens/startInspection/StartPendingInspection.js b/src/screens/startInspection/StartPendingInspection.js index 636efd5..b356089 100644 --- a/src/screens/startInspection/StartPendingInspection.js +++ b/src/screens/startInspection/StartPendingInspection.js @@ -267,7 +267,7 @@ class StartPendingInspection extends React.Component { } } - getData(visitSchedule) { + getVisitData(visitSchedule) { let data = [ { label: 'Escola:', @@ -310,7 +310,7 @@ class StartPendingInspection extends React.Component { this.props.listOfPendingScheduleInAGroup.map(visitSchedule => ( @@ -351,7 +351,7 @@ class StartPendingInspection extends React.Component { } } - getDataCounselor(counselor){ + getCounselorData(counselor){ let data = [ { label: "Nome:", @@ -383,7 +383,7 @@ class StartPendingInspection extends React.Component { this.state.invitees.map(counselor => ( ))