ilink-world/screens/configurations/Configurations.js

89 lines
3.1 KiB
JavaScript
Raw Normal View History

2020-03-12 15:14:51 +00:00
import React, { Component } from 'react'
2020-03-20 18:28:22 +00:00
import { StyleSheet, Text, View, Alert, Platform, StatusBar } from 'react-native'
2019-06-16 13:09:54 +00:00
import BaseScreen from "../BaseScreen";
2020-03-12 15:14:51 +00:00
import { responsiveWidth, responsiveHeight } from 'react-native-responsive-dimensions'
import { Dropdown } from 'react-native-material-dropdown'
import { disconnect } from './../../webservice/AuthApi'
const theme = require('./../../utils/theme.json');
const route = require('./../../route.json')
import I18n, { getLanguages } from 'react-native-i18n'
2019-06-16 13:09:54 +00:00
import Configuration from "../../webservice/persistences/Configuration";
import Button from "apsl-react-native-button"
require("./../../utils/Translations")
2020-03-12 15:14:51 +00:00
import { IlinkEmitter } from "./../../utils/events"
import { Header } from "react-native-elements";
2019-06-16 13:09:54 +00:00
import Icon from 'react-native-vector-icons/MaterialIcons';
2020-03-20 18:28:22 +00:00
import { SafeAreaView } from 'react-navigation';
2019-06-16 13:09:54 +00:00
2020-03-12 15:14:51 +00:00
export default class Configurations extends BaseScreen {
2019-06-16 13:09:54 +00:00
2020-03-12 15:14:51 +00:00
static navigationOptions = {
2020-03-20 18:28:22 +00:00
headerTitle: I18n.t('CONFIGURATIONS'),
2020-03-12 15:14:51 +00:00
drawerIcon: ({ tintColor }) => (
<Icon
name={'settings'}
size={24}
/>
2020-03-20 18:28:22 +00:00
)
2020-03-12 15:14:51 +00:00
};
constructor(props) {
super(props, true)
this.state = this.initState()
this.configuration = new Configuration();
2020-03-20 18:28:22 +00:00
if (Platform.OS === 'android') {
SafeAreaView.setStatusBarHeight(StatusBar.currentHeight);
}
2020-03-12 15:14:51 +00:00
}
2019-06-16 13:09:54 +00:00
2020-03-12 15:14:51 +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-03-12 15:14:51 +00:00
return {
languages: language
}
2019-06-16 13:09:54 +00:00
2020-03-12 15:14:51 +00:00
}
render() {
console.log(this.state)
return (<View style={styles.container}>
2019-06-16 13:09:54 +00:00
2020-03-12 15:14:51 +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-03-12 15:14:51 +00:00
>
2019-06-16 13:09:54 +00:00
2020-03-12 15:14:51 +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-03-12 15:14:51 +00:00
</View>
</View>);
}
2019-06-16 13:09:54 +00:00
}
2020-03-12 15:14:51 +00:00
const styles = StyleSheet.create({
container: {
flex: 1,
2020-03-20 18:28:22 +00:00
backgroundColor: 'white',
2020-03-12 15:14:51 +00:00
},
2019-06-16 13:09:54 +00:00
})