ilink-world/app/screens/configurations/Configurations.js

91 lines
2.7 KiB
JavaScript
Raw Permalink Normal View History

2020-11-20 17:06:19 +00:00
import React from 'react'
import {Platform, StatusBar, StyleSheet, Text, View} from 'react-native'
2019-06-16 13:09:54 +00:00
import BaseScreen from "../BaseScreen";
2020-11-20 17:06:19 +00:00
import {responsiveWidth} from 'react-native-responsive-dimensions'
2023-03-12 23:38:33 +00:00
import {Dropdown} from 'react-native-material-dropdown-v2'
2020-11-20 17:06:19 +00:00
import I18n from 'react-native-i18n'
import Configuration from "../../webservice/persistences/Configuration";
import {IlinkEmitter} from "./../../utils/events"
import Icon from 'react-native-vector-icons/MaterialIcons';
import {SafeAreaView} from 'react-navigation';
2020-03-12 15:14:51 +00:00
const theme = require('./../../utils/theme.json');
const route = require('./../../route.json')
2020-11-20 17:06:19 +00:00
2019-06-16 13:09:54 +00:00
require("./../../utils/Translations")
2020-03-12 15:14:51 +00:00
export default class Configurations extends BaseScreen {
2019-06-16 13:09:54 +00:00
2020-11-20 17:06:19 +00:00
static navigationOptions = {
headerTitle: I18n.t('CONFIGURATIONS'),
drawerIcon: ({tintColor}) => (
<Icon
name={'settings'}
size={24}
/>
)
};
2019-06-16 13:09:54 +00:00
2020-11-20 17:06:19 +00:00
constructor(props) {
super(props, true)
this.state = this.initState()
this.configuration = new Configuration();
if (Platform.OS === 'android') {
SafeAreaView.setStatusBarHeight(StatusBar.currentHeight);
}
}
2019-06-16 13:09:54 +00:00
2020-11-20 17:06:19 +00:00
initState() {
let language = [];
language.push({name: I18n.t('langue.english'), value: 'en'});
language.push({name: I18n.t('langue.french'), value: 'fr'});
2019-06-16 13:09:54 +00:00
2020-11-20 17:06:19 +00:00
return {
languages: language
}
2019-06-16 13:09:54 +00:00
2020-11-20 17:06:19 +00:00
}
render() {
console.log(this.state)
return (<View style={styles.container}>
2019-06-16 13:09:54 +00:00
2020-11-20 17:06:19 +00:00
<View
style={{
width: responsiveWidth(90),
marginTop: 20,
alignSelf: 'center',
borderRadius: 10,
paddingLeft: 20,
paddingRight: 20,
backgroundColor: 'white'
}}
2019-06-16 13:09:54 +00:00
2020-11-20 17:06:19 +00:00
>
<Text style={{fontSize: 17,}}>{I18n.t("CHOOSE_LANGUAGE")}</Text>
<Dropdown
label={I18n.t("CHANGE_LANG_LABEL")}
data={this.state.languages}
onChangeText={(value, index, data) => {
I18n.locale = value
this.setState({language: value})
this.configuration.setCurrentLangue(data[index])
IlinkEmitter.emit('langueChange')
}}
valueExtractor={(value) => value.value}
labelExtractor={(value) => value.name}
/>
2019-06-16 13:09:54 +00:00
2020-11-20 17:06:19 +00:00
</View>
</View>);
}
2019-06-16 13:09:54 +00:00
}
2020-03-12 15:14:51 +00:00
const styles = StyleSheet.create({
2020-11-20 17:06:19 +00:00
container: {
flex: 1,
backgroundColor: 'white',
},
2019-06-16 13:09:54 +00:00
2023-03-12 23:38:33 +00:00
})