From 04cc22269b9465e72691ece49a824a178ed0bf37 Mon Sep 17 00:00:00 2001 From: WilliamCallao <96638909+WilliamCallao@users.noreply.github.com> Date: Fri, 22 Mar 2024 14:48:49 -0400 Subject: [PATCH] Update BillScreen --- src/screens/FacturaScreen.js | 126 +++++++++++++++++++---------------- src/utils/DualTextView.js | 36 ++++++++++ 2 files changed, 106 insertions(+), 56 deletions(-) create mode 100644 src/utils/DualTextView.js diff --git a/src/screens/FacturaScreen.js b/src/screens/FacturaScreen.js index 763aba8..89fc86b 100644 --- a/src/screens/FacturaScreen.js +++ b/src/screens/FacturaScreen.js @@ -1,20 +1,20 @@ import React, { useRef } from 'react'; -import { View, Text, StyleSheet, TouchableOpacity, Alert } from 'react-native'; +import { View, StyleSheet, Alert, TouchableOpacity } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; import { captureRef } from 'react-native-view-shot'; import * as Sharing from 'expo-sharing'; -import SimpleButton from '../utils/SimpleButton'; import StyledText from '../utils/StyledText'; +import DualTextView from '../utils/DualTextView'; +import SimpleButton from '../utils/SimpleButton'; const cliente = "John Doe"; const numeroCliente = "20102353001"; -const fecha = "06/08/2023"; +const fechaEmision = "06/08/2024"; const pagosRealizados = [ - { numeroNota: "215", fechaNota: "11/07/23", total: "520", pagado: "210" }, - { numeroNota: "221", fechaNota: "05/10/23", total: "340", pagado: "340" } + { numeroNota: "215", fechaNota: "11/07/2024", total: "520.00", pagado: "210.00" }, + { numeroNota: "221", fechaNota: "05/08/2024", total: "340.00", pagado: "340.00" } ]; -const totalPagado = "350"; - +const totalPagado = pagosRealizados.reduce((acc, pago) => acc + parseFloat(pago.pagado), 0).toFixed(2); const SimpleScreen = () => { const viewRef = useRef(); @@ -25,46 +25,64 @@ const SimpleScreen = () => { format: 'png', quality: 0.8, }); - await Sharing.shareAsync(uri,{dialogTitle: 'Comprobante de pago'}); + await Sharing.shareAsync(uri, { dialogTitle: 'Comparte tu comprobante de pago' }); } catch (error) { Alert.alert("Error", "No se pudo capturar o compartir el comprobante: " + error.message); } }; - return ( - COMPROBANTE DE PAGO - - Cliente: - {cliente} - - - N° Cliente: - {numeroCliente} - - {pagosRealizados.map((pago, index) => ( - - - Numero de Nota: - {pago.numeroNota} - - - Fecha de nota: - {pago.fechaNota} - - - Total: {pago.total} Bs - Pagado: {pago.pagado} Bs - - - ))} - - Total Pagado: - {totalPagado} Bs - + COMPROBANTE DE PAGO + Cliente :} + rightChild={ {cliente}} + /> + N° Cliente :} + rightChild={ {numeroCliente}} + /> + Fecha de Emisión :} + rightChild={ {fechaEmision}} + /> + {pagosRealizados.map((pago, index) => ( + + N° Nota :} + rightChild={ {pago.numeroNota}} + /> + Fecha Nota :} + rightChild={ {pago.fechaNota}} + /> + Total :} + rightChild={ {`${pago.total} Bs`}} + /> + Pagado :} + rightChild={ {`${pago.pagado} Bs`}} + /> + + ))} + Total Pagado :} + rightChild={ {`${totalPagado} Bs`}} + /> - + ); }; @@ -76,26 +94,22 @@ const styles = StyleSheet.create({ justifyContent: 'center', }, container: { - alignItems: 'center', - justifyContent: 'center', + margin: 20, padding: 20, - backgroundColor: '#f9f9f9', - }, - text: { - fontSize: 18, - margin: 5, + alignSelf: 'stretch', + borderWidth: 1, + borderColor: '#ddd', + backgroundColor: '#fff', }, - textLine: { - flexDirection: "row", - justifyContent: "space-between", - alignItems: "center", + title: { + fontSize: 22, + fontWeight: 'bold', + marginBottom: 20, + textAlign: 'center', }, - dottedLine: { - borderBottomWidth: 3, - borderBottomColor: "black", - borderStyle: "dotted", - marginVertical: 8, + notaSection: { + marginBottom: 15, }, }); -export default SimpleScreen; \ No newline at end of file +export default SimpleScreen; diff --git a/src/utils/DualTextView.js b/src/utils/DualTextView.js new file mode 100644 index 0000000..5c822d1 --- /dev/null +++ b/src/utils/DualTextView.js @@ -0,0 +1,36 @@ +// DualTextView.js +import React from 'react'; +import { View, Text, StyleSheet } from 'react-native'; + +const DualTextView = ({ leftChild, rightChild, separation }) => { + return ( + + + {leftChild} + + + {rightChild} + + + ); +}; + +const styles = StyleSheet.create({ + container: { + flexDirection: 'row', + justifyContent: 'space-between', + alignItems: 'center', + width: '100%', + }, + child: { + flex: 1, + }, + leftChild: { + alignItems: 'flex-end', + }, + rightChild: { + alignItems: 'flex-start', + }, +}); + +export default DualTextView; \ No newline at end of file