mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-20 02:09:10 +01:00
REF: Language settings to TSX
This commit is contained in:
parent
6c85265e6c
commit
ddf155b996
@ -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<string>(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 (
|
||||
<BlueListItem
|
||||
// @ts-ignore: Fix later
|
||||
onPress={() => {
|
||||
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 (
|
||||
<FlatList
|
||||
style={[styles.flex, stylesHook.flex]}
|
||||
keyExtractor={(_item, index) => `${index}`}
|
||||
data={AvailableLanguages}
|
||||
renderItem={renderItem}
|
||||
initialNumToRender={25}
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
/>
|
||||
<View />
|
||||
);
|
||||
};
|
||||
|
||||
// @ts-ignore: Fix later
|
||||
Language.navigationOptions = navigationStyle({}, opts => ({ ...opts, title: loc.settings.language }));
|
||||
|
||||
export default Language;
|
Loading…
Reference in New Issue
Block a user