diff --git a/.vs/LEARNIHON/FileContentIndex/ae2e6dd4-98b8-42d0-8ba6-f2bd60e1aa88.vsidx b/.vs/LEARNIHON/FileContentIndex/1fb9654d-948f-4d7d-ae61-45de3c3d81a5.vsidx similarity index 100% rename from .vs/LEARNIHON/FileContentIndex/ae2e6dd4-98b8-42d0-8ba6-f2bd60e1aa88.vsidx rename to .vs/LEARNIHON/FileContentIndex/1fb9654d-948f-4d7d-ae61-45de3c3d81a5.vsidx diff --git a/.vs/LEARNIHON/FileContentIndex/557933d0-6b8c-4497-bc88-e464b14ac614.vsidx b/.vs/LEARNIHON/FileContentIndex/557933d0-6b8c-4497-bc88-e464b14ac614.vsidx new file mode 100644 index 0000000..321a19a Binary files /dev/null and b/.vs/LEARNIHON/FileContentIndex/557933d0-6b8c-4497-bc88-e464b14ac614.vsidx differ diff --git a/.vs/LEARNIHON/FileContentIndex/8b62d542-6a90-4e8e-911c-376b5df63c5a.vsidx b/.vs/LEARNIHON/FileContentIndex/8b62d542-6a90-4e8e-911c-376b5df63c5a.vsidx deleted file mode 100644 index 3c60d02..0000000 Binary files a/.vs/LEARNIHON/FileContentIndex/8b62d542-6a90-4e8e-911c-376b5df63c5a.vsidx and /dev/null differ diff --git a/.vs/LEARNIHON/FileContentIndex/d3547d75-a692-4b0c-a286-04b099bcd097.vsidx b/.vs/LEARNIHON/FileContentIndex/d3547d75-a692-4b0c-a286-04b099bcd097.vsidx deleted file mode 100644 index f0d1dce..0000000 Binary files a/.vs/LEARNIHON/FileContentIndex/d3547d75-a692-4b0c-a286-04b099bcd097.vsidx and /dev/null differ diff --git a/.vs/LEARNIHON/v17/.wsuo b/.vs/LEARNIHON/v17/.wsuo index 17ea5fa..024cac4 100644 Binary files a/.vs/LEARNIHON/v17/.wsuo and b/.vs/LEARNIHON/v17/.wsuo differ diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json index 834b9e4..86e7fb7 100644 --- a/.vs/VSWorkspaceState.json +++ b/.vs/VSWorkspaceState.json @@ -10,6 +10,6 @@ "\\redux\\reducers", "\\redux\\thunks" ], - "SelectedNode": "\\components\\KanjiListSearchPanel.tsx", + "SelectedNode": "\\redux\\store.ts", "PreviewInSolutionExplorer": false } \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index baf150b..ea5513f 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/App.tsx b/App.tsx index 32822ee..aec1ad1 100644 --- a/App.tsx +++ b/App.tsx @@ -6,8 +6,6 @@ import { Provider, useDispatch } from 'react-redux'; import { StatusBar } from 'expo-status-bar'; import { Keyboard, SafeAreaView, StyleSheet, TouchableWithoutFeedback} from 'react-native'; -import Header from './components/Header'; -import TabBar from './navigation/TabBar'; import { InitStack } from './navigation/Startup'; export default function App() { diff --git a/components/GradeChip.tsx b/components/GradeChip.tsx index 8b36830..9bac4e8 100644 --- a/components/GradeChip.tsx +++ b/components/GradeChip.tsx @@ -19,8 +19,9 @@ const GradeChip = (props: gradeChipProps) => { }, [isSelected]); const select = () => { - props.onSelect("Grade "+props.grade, isSelected); setIsSelected(!isSelected); + props.onSelect("Grade " + props.grade, isSelected); + } return ( diff --git a/components/KanjiAnswerField.tsx b/components/KanjiAnswerField.tsx index 84fdfb2..d645df1 100644 --- a/components/KanjiAnswerField.tsx +++ b/components/KanjiAnswerField.tsx @@ -2,24 +2,20 @@ import React from 'react'; import { Animated, StyleSheet, TextInput } from 'react-native'; import { startAnimation, stopAnimation, animatedStyles } from '../assets/animations/answerAnimation' -const KanjiAnswerField = () => { +interface kanjiAnswerFieldProps { + answer: string, + setAnswer: React.Dispatch> +} - const options = { - method: 'GET', - headers: { - 'X-RapidAPI-Key': '19516a9900mshce10de76f99976bp10f192jsn8c8d82222baa', - 'X-RapidAPI-Host': 'kanjialive-api.p.rapidapi.com' - } - } +const KanjiAnswerField = (props: kanjiAnswerFieldProps) => { - const [answer, onChangeText] = React.useState(""); return ( { - const kanjiCardStyle = useColorScheme() == 'light' ? kanjiCardStyle_light : kanjiCardStyle_dark; - + var kanjiCardStyle = useColorScheme() == 'light' ? kanjiCardStyle_light : kanjiCardStyle_dark; + const [answerTextColor, setAnswerTextColor] = useState(kanjiCardStyle.text.color); + var textAnswerStyle = StyleSheet.create({ + text: { + color: answerTextColor, + fontWeight: "bold", + fontSize: "20em" + } + }) - const options = { - method: 'GET', - headers: { - 'X-RapidAPI-Key': '19516a9900mshce10de76f99976bp10f192jsn8c8d82222baa', - 'X-RapidAPI-Host': 'kanjialive-api.p.rapidapi.com' - } - } + const nextKanji = () => allKanjis[Math.floor(Math.random() * allKanjis.length)]; const [kanji, setKanji] = useState((): Kanji | null => { return null }); const [imgXml, setImgXml] = useState(''); - + const [hasAnswered, setHasAnswered] = useState(false); + const [answer, setAnswer] = React.useState(""); var kanjis: KanjiListByGrade = useSelector(state => state.kanjiReducer.kanjis); const allKanjis: Kanji[] = [].concat(...Object.values(kanjis)) - const selectedKanji = allKanjis[Math.floor(Math.random() * allKanjis.length)] - const fetchXml = async () => { @@ -44,7 +44,7 @@ const KanjiCard = (props: KanjiProps) => { } useEffect(() => { - setKanji(selectedKanji); + setKanji(nextKanji()); }, []); useEffect(() => { @@ -52,6 +52,22 @@ const KanjiCard = (props: KanjiProps) => { }); }, [kanji]); + const computeAnswer = () => { + setAnswerTextColor(isAnswerRight() ? "green" : "red"); + setHasAnswered(true); + } + const computeNext = () => { + setKanji(nextKanji()); + setAnswer(""); + setHasAnswered(false); + } + + const isAnswerRight = () => { + const arr1 = answer.toLowerCase().split(',').map(word => word.trim()).sort(); + const arr2 = kanji?.meaning.toLowerCase().split(',').map(word => word.trim()).sort(); + return JSON.stringify(arr1) === JSON.stringify(arr2); + } + return ( @@ -62,9 +78,19 @@ const KanjiCard = (props: KanjiProps) => { width="200" height="200" /> - {kanji?.meaning} - -