From 35eb2180e10c0a6701922b99deee1937621750ef Mon Sep 17 00:00:00 2001 From: art1505 Date: Mon, 27 Nov 2023 19:17:42 -0300 Subject: [PATCH 1/6] =?UTF-8?q?(#205)=20Adiciona=20componente=20de=20cart?= =?UTF-8?q?=C3=B5es=20de=20m=C3=A9tricas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: gabryelns --- src/app/components/CardMetricas.tsx | 81 ++++++++++++++++++++++++++ src/app/interfaces/metric.interface.ts | 3 + 2 files changed, 84 insertions(+) create mode 100644 src/app/components/CardMetricas.tsx create mode 100644 src/app/interfaces/metric.interface.ts diff --git a/src/app/components/CardMetricas.tsx b/src/app/components/CardMetricas.tsx new file mode 100644 index 00000000..feff0480 --- /dev/null +++ b/src/app/components/CardMetricas.tsx @@ -0,0 +1,81 @@ +import React from 'react'; +import { View, Text, StyleSheet } from 'react-native'; +import Icon from 'react-native-vector-icons/FontAwesome'; // ou qualquer outro ícone disponível + +interface MetricCardProps { + title: string; + content: string; + unit: string; + time: string; +} + +const MetricCard: React.FC = ({ title, content, unit, time }) => { + let titleColor = '#000'; // Cor padrão + + if (title.toLowerCase().includes('pressão sanguínea') || title.toLowerCase().includes('frequência cardíaca')) { + titleColor = '#FF7D7D'; // Vermelho + } else if (title.toLowerCase().includes('temperatura')) { + titleColor = '#FFAC7D'; // Laranja + } else if (title.toLowerCase().includes('hidratação')) { + titleColor = '#5ABCD8'; // Azul + } + + const textColor = '#888'; // Cor do texto do horário e unidades + + return ( + + {title} + + {content} + {unit} + + {time} + + + ); +}; + +const styles = StyleSheet.create({ + card: { + borderWidth: 1, + borderRadius: 8, + padding: 16, + margin: 8, + width: '45%', // Adjust width for two cards in a row + shadowColor: '#000', + shadowOffset: { width: 0, height: 2 }, + shadowOpacity: 0.2, + shadowRadius: 4, + elevation: 3, // For Android shadow + }, + title: { + fontWeight: 'bold', + fontSize: 16, + marginBottom: 8, + }, + content: { + fontSize: 14, + marginTop: 8, + }, + number: { + fontWeight: 'bold', + fontSize: 24, // Adjust font size for the content (number) + }, + units: { + fontSize: 18, // Adjust font size for units + }, + time: { + color: '#888', + fontSize: 12, + marginTop: 8, + }, + chevron: { + position: 'absolute', + top: 12, + right: 12, + }, + +}); + +export default MetricCard; + diff --git a/src/app/interfaces/metric.interface.ts b/src/app/interfaces/metric.interface.ts new file mode 100644 index 00000000..606348a5 --- /dev/null +++ b/src/app/interfaces/metric.interface.ts @@ -0,0 +1,3 @@ +export interface IMetric { + metricName: string; + } \ No newline at end of file From 9a0a32b07bfd57a33e58f5c65b70c38df975408b Mon Sep 17 00:00:00 2001 From: gabryelns Date: Mon, 27 Nov 2023 20:46:55 -0300 Subject: [PATCH 2/6] (#205) adiciona metricas na tela de registros --- src/app/private/tabs/registros.tsx | 204 +++++++++++++++-------------- 1 file changed, 103 insertions(+), 101 deletions(-) diff --git a/src/app/private/tabs/registros.tsx b/src/app/private/tabs/registros.tsx index e2a1623c..6dcb048f 100644 --- a/src/app/private/tabs/registros.tsx +++ b/src/app/private/tabs/registros.tsx @@ -1,21 +1,14 @@ -import React, { useEffect, useState } from "react"; -import AsyncStorage from "@react-native-async-storage/async-storage"; -import { IUser } from "../../interfaces/user.interface"; +import React, { useEffect, useState } from 'react'; +import { View, StyleSheet, ScrollView, Text, Image, TouchableOpacity } from 'react-native'; +import Icon from 'react-native-vector-icons/FontAwesome'; +import MetricCard from '../../components/CardMetricas'; +import AsyncStorage from '@react-native-async-storage/async-storage'; +import { IUser } from '../../interfaces/user.interface'; import NaoAutenticado from "../../components/NaoAutenticado"; -import EmConstrucao from "../../components/EmConstrucao"; -import { - View, - StyleSheet, - Pressable, - Text, - Image, - TouchableOpacity, - Platform, -} from "react-native"; -import Icon from "react-native-vector-icons/FontAwesome"; export default function Registros() { - const [user, setUser] = useState(undefined); + + const [user, setUser] = useState(undefined); const handleUser = () => { AsyncStorage.getItem("usuario").then((response) => { @@ -26,95 +19,104 @@ export default function Registros() { useEffect(() => handleUser(), []); - const novaMetrica = () => { - // Adicione a lógica para criar uma nova métrica - }; - - return !user?.id ? : ( - - - - + ) : ( + + {/* Header */} + + - Nome do idoso - - {/* - {/* Adicione o conteúdo desejado dentro do TouchableOpacity} - */} - - - - - - - Nova Métrica - - - - -); + /> + Nome do idoso + + + {/* Button to create a new metric (simplified) */} + + console.log('Button pressed')}> + + Nova Métrica + + + + {/* Display metric cards in two columns */} + + + + + + + + ); } const styles = StyleSheet.create({ -header: { - backgroundColor: "#2CCDB5", - width: "100%", - padding: 10, - height: 100, - flexDirection: "column", - alignItems: "center", - justifyContent: "center", -}, - -botaoCriarMetricas: { - flexDirection: "row", - alignItems: "center", - backgroundColor: "#B4026D", - paddingHorizontal: 10, - paddingVertical: 5, - borderRadius: 10, - marginLeft: "auto", - marginRight: 10, - marginVertical: 10, -}, - -textoBotaoCriarMetricas: { - color: "white", - fontWeight: "600", - fontSize: 14, - marginLeft: 5, -}, - -nameBar: { - // Estilo para nameBar -}, - -imagem: { - width: 45, - height: 45, - borderRadius: 30, -}, - -name: { - color: "white", - fontWeight: "bold", - fontSize: 16, - marginTop: 5, -}, - -button: { - // Estilo para button -}, - -buttonIOS: { - // Estilo específico para iOS, se necessário -}, + container: { + flexGrow: 1, + }, + header: { + backgroundColor: '#2CCDB5', + width: '100%', + padding: 10, + height: 100, + flexDirection: 'column', + alignItems: 'center', + justifyContent: 'center', + }, + botaoCriarMetricas: { + flexDirection: 'row', + alignItems: 'center', + backgroundColor: '#B4026D', + paddingHorizontal: 10, + paddingVertical: 5, + borderRadius: 10, + marginLeft: 'auto', + marginRight: 10, + marginVertical: 10, + }, + textoBotaoCriarMetricas: { + color: 'white', + fontWeight: '600', + fontSize: 14, + marginLeft: 5, + }, + imagem: { + width: 45, + height: 45, + borderRadius: 30, + }, + name: { + color: 'white', + fontWeight: 'bold', + fontSize: 16, + marginTop: 5, + }, + metricsContainer: { + flexDirection: 'row', + justifyContent: 'space-between', + flexWrap: 'wrap', + padding: 10, + }, }); From ce5e0b2ababad930b40606ab0248e022f4466802 Mon Sep 17 00:00:00 2001 From: gabryelns Date: Mon, 27 Nov 2023 21:10:03 -0300 Subject: [PATCH 3/6] (#205) corrige caminho de imagem e coment errado --- src/app/private/tabs/registros.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app/private/tabs/registros.tsx b/src/app/private/tabs/registros.tsx index 6dcb048f..36f435e0 100644 --- a/src/app/private/tabs/registros.tsx +++ b/src/app/private/tabs/registros.tsx @@ -23,17 +23,21 @@ export default function Registros() { ) : ( - {/* Header */} + { + + } Nome do idoso - {/* Button to create a new metric (simplified) */} + { + + } console.log('Button pressed')}> @@ -41,7 +45,9 @@ export default function Registros() { - {/* Display metric cards in two columns */} + { + + } Date: Mon, 27 Nov 2023 21:22:59 -0300 Subject: [PATCH 4/6] corrige erro de caminho de imagem de idoso --- src/app/index.tsx | 1 + src/app/private/tabs/registros.tsx | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/app/index.tsx b/src/app/index.tsx index 54a19e82..34878e04 100644 --- a/src/app/index.tsx +++ b/src/app/index.tsx @@ -10,6 +10,7 @@ export default function Home() { Seja um GEROcuidador! + { - } @@ -36,7 +35,6 @@ export default function Registros() { { - } console.log('Button pressed')}> @@ -46,7 +44,6 @@ export default function Registros() { { - } Date: Thu, 30 Nov 2023 15:55:43 -0300 Subject: [PATCH 5/6] (#205) adiciona arquivo de testes inicial --- src/app/__tests__/visualizarMetricas.spec.tsx | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/app/__tests__/visualizarMetricas.spec.tsx diff --git a/src/app/__tests__/visualizarMetricas.spec.tsx b/src/app/__tests__/visualizarMetricas.spec.tsx new file mode 100644 index 00000000..e79a10ba --- /dev/null +++ b/src/app/__tests__/visualizarMetricas.spec.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { render } from '@testing-library/react-native'; +import AsyncStorage, { AsyncStorageStatic } from '@react-native-async-storage/async-storage'; +import Registros from '../private/tabs/registros'; + +// Mock AsyncStorage +jest.mock('@react-native-async-storage/async-storage', () => ({ + getItem: jest.fn(), +})); + +describe('Visualizar registros', () => { + test('The component rendered', () => { + // Mock the response for AsyncStorage.getItem + (AsyncStorage.getItem as jest.Mock).mockImplementation((key) => { + if (key === 'usuario') { + return Promise.resolve(JSON.stringify({ id: 1 })); + } else if (key === 'token') { + return Promise.resolve('mockedToken'); + } + return Promise.resolve(null); + }); + + render(); + }); +}); \ No newline at end of file From 3cadcaefcc524d2be261cc5ba3ba668785e6a45d Mon Sep 17 00:00:00 2001 From: art1505 Date: Fri, 1 Dec 2023 17:00:19 -0300 Subject: [PATCH 6/6] (#205) Corrige teste falhando --- src/app/__tests__/visualizarMetricas.spec.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/__tests__/visualizarMetricas.spec.tsx b/src/app/__tests__/visualizarMetricas.spec.tsx index e79a10ba..2735f559 100644 --- a/src/app/__tests__/visualizarMetricas.spec.tsx +++ b/src/app/__tests__/visualizarMetricas.spec.tsx @@ -1,5 +1,6 @@ import React from 'react'; import { render } from '@testing-library/react-native'; +import { NavigationContainer } from '@react-navigation/native'; import AsyncStorage, { AsyncStorageStatic } from '@react-native-async-storage/async-storage'; import Registros from '../private/tabs/registros'; @@ -20,6 +21,11 @@ describe('Visualizar registros', () => { return Promise.resolve(null); }); - render(); + render( + // Envolve o componente Registros com NavigationContainer durante o teste + + + + ); }); -}); \ No newline at end of file +});