Skip to content

Commit

Permalink
refactor(mobile): 💄 Refactor answer buttons in practice
Browse files Browse the repository at this point in the history
Fixes #2232

Signed-off-by: Yunus Andréasson <yunus@edenmind.com>
  • Loading branch information
YunusAndreasson committed Aug 29, 2023
1 parent 73ec56f commit c036ba2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
Binary file modified mobile/.yarn/install-state.gz
Binary file not shown.
Empty file.
2 changes: 1 addition & 1 deletion mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"homepage": "https://openarabic.io",
"repository": "https://github.com/edenmind/OpenArabic",
"version": "1445.2.345",
"version": "1445.2.346",
"authors": [
"Yunus Andreasson <yunus@edenmind.com> (https://github.com/YunusAndreasson)"
],
Expand Down
12 changes: 9 additions & 3 deletions mobile/screens/text-practice-words.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ const AnimatedButton = ({ word, handlePress }) => {

return (
<Animated.View style={{ opacity: fadeInValue }}>
<AnswerButton text={word.english} onPress={() => handlePress(word.id, word.arabic)} />
<AnswerButton
text={word.english}
onPress={() => handlePress(word.id, word.arabic)}
{...(word.correct ? { correct: true } : { incorrect: true })}
/>
</Animated.View>
)
}
Expand All @@ -44,7 +48,8 @@ AnimatedButton.propTypes = {
word: PropTypes.shape({
english: PropTypes.string.isRequired,
id: PropTypes.number.isRequired,
arabic: PropTypes.string.isRequired
arabic: PropTypes.string.isRequired,
correct: PropTypes.bool.isRequired
}).isRequired,
handlePress: PropTypes.func.isRequired
}
Expand All @@ -55,7 +60,8 @@ TextPracticeWords.propTypes = {
PropTypes.shape({
english: PropTypes.string.isRequired,
id: PropTypes.number.isRequired,
arabic: PropTypes.string.isRequired
arabic: PropTypes.string.isRequired,
correct: PropTypes.bool.isRequired
})
).isRequired
}
9 changes: 8 additions & 1 deletion mobile/screens/text-practice.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ const TextPractice = () => {
const englishWords = sentencesInText[currentSentence].englishWords
const arabicWordId = sentencesInText[currentSentence].arabicWords[currentWord].id

setCurrentEnglishWordsInSentence(getThreeRandomWords(englishWords, arabicWordId, sentencesInText))
const randomWords = getThreeRandomWords(englishWords, arabicWordId, sentencesInText)

const enhancedEnglishWords = randomWords.map((word) => ({
...word,
correct: word.id === currentWord
}))

setCurrentEnglishWordsInSentence(enhancedEnglishWords)
setCurrentArabicWord(sentencesInText[currentSentence].arabicWords[currentWord])
}, [currentSentence, currentWord, sentencesInText, textLoading])

Expand Down

0 comments on commit c036ba2

Please sign in to comment.