Skip to content

Commit

Permalink
Merge pull request #3 from polijrorg/Feat/edite-question
Browse files Browse the repository at this point in the history
Feat/edite question
  • Loading branch information
pedrogomes18 authored Jun 26, 2024
2 parents b256d3a + 7ef01ec commit fe27356
Show file tree
Hide file tree
Showing 44 changed files with 1,968 additions and 1,420 deletions.
46 changes: 23 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,56 +26,56 @@
"@expo/ngrok": "^4.1.0",
"@expo/vector-icons": "^14.0.0",
"@expo/webpack-config": "~19.0.1",
"@react-native-async-storage/async-storage": "1.21.0",
"@react-native-community/datetimepicker": "^8.0.0",
"@react-native-community/slider": "4.4.2",
"@react-native-picker/picker": "2.6.1",
"@react-native-async-storage/async-storage": "1.23.1",
"@react-native-community/datetimepicker": "8.0.1",
"@react-native-community/slider": "4.5.2",
"@react-native-picker/picker": "2.7.5",
"@react-navigation/bottom-tabs": "^6.5.12",
"@react-navigation/material-top-tabs": "^6.6.6",
"@react-navigation/native": "^6.1.10",
"@react-navigation/native-stack": "^6.9.17",
"axios": "^1.6.7",
"date-fns": "^3.6.0",
"expo": "^50.0.0",
"expo-dev-client": "~3.3.11",
"expo-font": "~11.10.3",
"expo-linear-gradient": "~12.7.2",
"expo-splash-screen": "~0.26.4",
"expo-status-bar": "~1.11.1",
"expo-updates": "~0.24.12",
"expo": "^51.0.0",
"expo-dev-client": "~4.0.13",
"expo-font": "~12.0.5",
"expo-linear-gradient": "~13.0.2",
"expo-splash-screen": "~0.27.4",
"expo-status-bar": "~1.12.1",
"expo-updates": "~0.25.12",
"moti": "^0.19.0",
"nookies": "^2.5.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.73.6",
"react-native": "0.74.1",
"react-native-chart-kit": "^6.12.0",
"react-native-gesture-handler": "~2.14.0",
"react-native-gesture-handler": "~2.16.1",
"react-native-modal": "^13.0.1",
"react-native-pager-view": "6.2.3",
"react-native-reanimated": "~3.6.2",
"react-native-pager-view": "6.3.0",
"react-native-reanimated": "~3.10.1",
"react-native-reanimated-carousel": "^3.5.1",
"react-native-safe-area-context": "4.8.2",
"react-native-screens": "~3.29.0",
"react-native-svg": "14.1.0",
"react-native-safe-area-context": "4.10.1",
"react-native-screens": "3.31.1",
"react-native-svg": "15.2.0",
"react-native-svg-charts": "^5.4.0",
"react-native-tab-view": "^3.5.2",
"react-native-toast-notifications": "^3.4.0",
"react-native-web": "~0.19.6",
"react-native-web": "~0.19.10",
"styled-components": "^5.3.5"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/core": "^7.24.0",
"@react-native-community/eslint-config": "^3.1.0",
"@types/axios": "^0.14.0",
"@types/react-dom": "~18.0.10",
"@types/react-dom": "~18.2.25",
"@types/react-native": "~0.69.1",
"@types/styled-components": "^5.1.26",
"@types/styled-components-react-native": "^5.1.3",
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"babel-loader": "^8.2.5",
"babel-plugin-module-resolver": "^5.0.0",
"babel-preset-expo": "^10.0.0",
"babel-preset-expo": "~11.0.0",
"eslint": "^9.1.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
Expand All @@ -86,7 +86,7 @@
"husky": "^8.0.1",
"lint-staged": "15.2.0",
"prettier": "^3.2.4",
"typescript": "^5.3.0"
"typescript": "~5.3.3"
},
"private": true
}
201 changes: 133 additions & 68 deletions src/components/AccordionVisit/index.tsx
Original file line number Diff line number Diff line change
@@ -1,93 +1,158 @@
/* eslint-disable react-native/no-inline-styles */
import React, { useState } from 'react';
import { View, Text, TouchableWithoutFeedback } from 'react-native';
import { View, Text, TouchableWithoutFeedback, StyleSheet } from 'react-native';
import { FontAwesome } from '@expo/vector-icons';

type AccordionProps = {
title?: string;
media?: number | string;
questions?: string[];
questions?: { question: string; grade: string }[];
questionGrades?: number[];
};

const formatNumber = (number: number | string) => {
if (typeof number === 'number') {
return number.toLocaleString('pt-BR', {
minimumFractionDigits: 1,
maximumFractionDigits: 1,
});
}
return '';
};

const AccordionHeader: React.FC<{
title: string;
media: number | string;
isExpanded: boolean;
toggleExpand: () => void;
}> = ({ title, media, isExpanded, toggleExpand }) => (
<TouchableWithoutFeedback onPress={toggleExpand}>
<View style={styles.header}>
<Text style={styles.title}>{title}</Text>
<Text style={styles.media}>
{media !== 0 ? formatNumber(media) : 'N.A'}
</Text>
<FontAwesome
name={isExpanded ? 'angle-up' : 'angle-down'}
size={24}
color="black"
/>
</View>
</TouchableWithoutFeedback>
);

type AccordionContentProps = {
isExpanded: boolean;
questions?: { question: string; grade: string }[] | null;
};

const AccordionContent: React.FC<AccordionContentProps> = ({
isExpanded,
questions,
}) => {
const formatNumber = (number: string) => {
const isNumeric = /^\d*\.?\d*$/.test(number);

if (isNumeric) {
return parseFloat(number).toFixed(1).replace('.', ',');
}

return '';
};

return (
isExpanded && (
<View style={styles.content}>
{questions?.map((item, index) => (
<View
key={index}
style={{
display: 'flex',
flexDirection: 'row',
justifyContent: 'space-between',
paddingHorizontal: 4,
}}
>
<Text style={styles.questionText}>{item.question}</Text>
<Text style={styles.gradeText}>
{formatNumber(item.grade) || 'N.A'}
</Text>
</View>
))}
</View>
)
);
};

const AccordionVisit: React.FC<AccordionProps> = ({
title,
media,
questions,
questionGrades,
}) => {
const [isExpanded, setIsExpanded] = useState(false);
const [showText, setShowText] = useState(true);

const toggleExpand = () => {
setIsExpanded(!isExpanded);
};

const formatNumber = (number: number | string) => {
if (number !== undefined) {
return Number(number).toLocaleString('pt-BR', {
minimumFractionDigits: 1,
});
}
return '';
};

return (
<View style={{ marginTop: 16, borderRadius: 8 }}>
<TouchableWithoutFeedback onPress={toggleExpand}>
<View
style={{
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
backgroundColor: '#F1F3F5',
padding: 10,
borderRadius: 8,
}}
>
<Text style={{ flex: 0.9, fontFamily: 'Poppins' }}>{title}</Text>
{showText && (
<Text
style={{
marginRight: 0,
fontFamily: 'PoppinsBold',
backgroundColor: '#E6E8EB',
color: '#687076',
borderRadius: 2,
fontSize: 12,
padding: 2,
}}
>
{formatNumber(media) || 'X,X'}
</Text>
)}
<FontAwesome
name={isExpanded ? 'angle-up' : 'angle-down'}
size={24}
color="black"
/>
</View>
</TouchableWithoutFeedback>

{isExpanded && (
<View
style={{
backgroundColor: '#F1F3F5',
padding: 10,
borderBottomLeftRadius: 8,
borderBottomRightRadius: 8,
}}
>
{questions?.map((element, index) => (
<Text
key={index}
style={{ fontFamily: 'Poppins', color: '#687076' }}
>
{element}
</Text>
))}
</View>
)}
<View style={styles.container}>
<AccordionHeader
title={title}
media={media}
isExpanded={isExpanded}
toggleExpand={toggleExpand}
/>
<AccordionContent isExpanded={isExpanded} questions={questions} />
</View>
);
};

const styles = StyleSheet.create({
container: {
marginTop: 16,
borderRadius: 8,
},
header: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
backgroundColor: '#F1F3F5',
padding: 10,
borderRadius: 8,
},
title: {
flex: 0.9,
fontFamily: 'Poppins',
},
media: {
marginRight: 0,
fontFamily: 'PoppinsBold',
backgroundColor: '#E6E8EB',
color: '#687076',
borderRadius: 2,
fontSize: 12,
padding: 2,
},
content: {
backgroundColor: '#F1F3F5',
padding: 10,
borderBottomLeftRadius: 8,
borderBottomRightRadius: 8,
},
questionRow: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
questionText: {
fontFamily: 'Poppins',
color: '#687076',
},
gradeText: {
fontFamily: 'Poppins',
color: '#687076',
},
});

export default AccordionVisit;
42 changes: 21 additions & 21 deletions src/components/BarChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import * as S from './styles';
import { BarChart } from 'react-native-chart-kit';
import { Dimensions } from 'react-native';

interface BarChartProps {}
interface BarChartProps {
type: string;
}

const BarChartComponent: React.FC<BarChartProps> = ({}) => {
const BarChartComponent: React.FC<BarChartProps> = ({ type }) => {
const data = {
labels: ['6', '7', '8', '9', '10'],
datasets: [
Expand Down Expand Up @@ -35,25 +37,23 @@ const BarChartComponent: React.FC<BarChartProps> = ({}) => {

return (
<S.Container>
<S.TitleSlider>Matriz IC Implementação | Conhecimento</S.TitleSlider>
<S.WrapperChart>
<BarChart
data={data}
// eslint-disable-next-line react-native/no-inline-styles
style={{ borderRadius: 4, padding: 12 }}
width={Dimensions.get('window').width - 90}
height={220}
yAxisLabel=""
yAxisSuffix=""
chartConfig={chartConfig}
verticalLabelRotation={0}
showValuesOnTopOfBars
showBarTops={false}
flatColor
withInnerLines={false}
withCustomBarColorFromData
/>
</S.WrapperChart>
{type === 'modulo' && <S.TitleSlider>Médias por módulo</S.TitleSlider>}
{type === 'competencia' && <S.TitleSlider>Médias por competência</S.TitleSlider>}
{type === 'matrixxz' && <S.TitleSlider>Médias por MatrixXZ</S.TitleSlider>}
<BarChart
data={data}
style={{ borderRadius: 4, padding: 8 }}
width={Dimensions.get('window').width - 50}
height={200}
yAxisLabel=""
yAxisSuffix=""
chartConfig={chartConfig}
showValuesOnTopOfBars
showBarTops={false}
flatColor
withInnerLines={false}
withCustomBarColorFromData
/>
</S.Container>
);
};
Expand Down
10 changes: 1 addition & 9 deletions src/components/BarChart/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,17 @@ import styled from 'styled-components/native';
export const Container = styled(View)`
width: 100%;
height: auto;
flex-direction: row;
align-items: center;
justify-content: center;
border-radius: 8px;
margin: 16px 0;
`;

export const WrapperChart = styled(View)`
width: 100%;
display: flex;
justify-content: center;
align-items: center;
`;

export const TitleSlider = styled(Text)`
color: #687076;
font-size: 16px;
font-weight: 400;
margin: 5px 0;
margin: 16px 32px;
align-self: flex-start;
align-items: flex-start;
`;
Loading

0 comments on commit fe27356

Please sign in to comment.