diff --git a/screen/settings/language.js b/screen/settings/language.tsx similarity index 68% rename from screen/settings/language.js rename to screen/settings/language.tsx index 8fb003e20..ef9db9f83 100644 --- a/screen/settings/language.js +++ b/screen/settings/language.tsx @@ -1,7 +1,6 @@ import React, { useState, useEffect, useContext } from 'react'; import { FlatList, StyleSheet } from 'react-native'; import { useNavigation, useTheme } from '@react-navigation/native'; - import navigationStyle from '../../components/navigationStyle'; import { BlueListItem } from '../../BlueComponents'; import loc, { saveLanguage } from '../../loc'; @@ -15,9 +14,9 @@ const styles = StyleSheet.create({ }, }); -const Language = () => { +const Language: React.FC = () => { const { setLanguage, language } = useContext(BlueStorageContext); - const [selectedLanguage, setSelectedLanguage] = useState(loc.getLanguage()); + const [selectedLanguage, setSelectedLanguage] = useState(loc.getLanguage()); const { setOptions } = useNavigation(); const { colors } = useTheme(); const stylesHook = StyleSheet.create({ @@ -31,37 +30,31 @@ const Language = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [language]); - const renderItem = item => { + const renderItem = ({ item }: { item: { label: string; value: string; isRTL: boolean } }) => { return ( { const currentLanguage = AvailableLanguages.find(l => l.value === selectedLanguage); - saveLanguage(item.item.value).then(() => { - setSelectedLanguage(item.item.value); + saveLanguage(item.value).then(() => { + setSelectedLanguage(item.value); setLanguage(); - if (currentLanguage.isRTL || item.item.isRTL) { + if (currentLanguage && (currentLanguage.isRTL || item.isRTL)) { alert(loc.settings.language_isRTL); } }); }} - title={item.item.label} - checkmark={selectedLanguage === item.item.value} + title={item.label} + checkmark={selectedLanguage === item.value} /> ); }; return ( - `${index}`} - data={AvailableLanguages} - renderItem={renderItem} - initialNumToRender={25} - contentInsetAdjustmentBehavior="automatic" - /> + ); }; - +// @ts-ignore: Fix later Language.navigationOptions = navigationStyle({}, opts => ({ ...opts, title: loc.settings.language })); export default Language;