Skip to content

Commit

Permalink
feat: show result of topic
Browse files Browse the repository at this point in the history
  • Loading branch information
heyloh committed Mar 23, 2021
1 parent e136df8 commit b9702d7
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions src/pages/Topics/FinishTopic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,49 @@ import {useNavigation} from '@react-navigation/native';
import {UserContext} from '../../../contexts/UserContext';

import checkCircle from '../../../assets/icons/check-circle.png';
import wrong from '../../../assets/icons/wrong.png';

const FinishTopic = ({route}) => {
const {topic} = route.params;
const {navigate} = useNavigation();
const {resetClickedExercises} = useContext(UserContext);
const {resetClickedExercises, answers, resetAnswers} = useContext(
UserContext,
);

function handleFinish() {
resetClickedExercises();
resetAnswers();
navigate('Home');
}

return (
<View style={styles.container}>
<Image source={checkCircle} style={styles.success} />
<Text style={styles.title}>Parabéns!</Text>
<Text style={styles.text}>
Você acabou de concluir o tópico de {topic}. Siga em frente e continue
aprendendo!
</Text>
<RectButton style={styles.button} onPress={handleFinish}>
<Text style={styles.buttonText}>Continuar</Text>
</RectButton>
{answers.correct > answers.incorrect ? (
<>
<Image source={checkCircle} style={styles.success} />
<Text style={styles.title}>Parabéns!</Text>
<Text style={styles.text}>
Você acabou de concluir o tópico de {topic}. Siga em frente e
continue aprendendo!
</Text>
<RectButton style={styles.button} onPress={handleFinish}>
<Text style={styles.buttonText}>Continuar</Text>
</RectButton>
</>
) : (
<>
<Image source={wrong} style={styles.success} />
<Text style={styles.title}>Que pena!</Text>
<Text style={styles.text}>
Você não conseguiu concluir o tópico de {topic}. Tente novamente,
parece que você errou muitos exercícios, continue praticando até
conseguir.
</Text>
<RectButton style={styles.button} onPress={handleFinish}>
<Text style={styles.buttonText}>Continuar</Text>
</RectButton>
</>
)}
</View>
);
};
Expand Down

0 comments on commit b9702d7

Please sign in to comment.