You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
Set locale of RN app
This commit is contained in:
@@ -2,13 +2,27 @@ import React, { Component } from 'react';
|
||||
import { View, StyleSheet, Picker, Text, Button } from 'react-native';
|
||||
import { connect } from 'react-redux'
|
||||
import { ScreenHeader } from 'lib/components/screen-header.js';
|
||||
import { _ } from 'lib/locale.js';
|
||||
import { _, setLocale } from 'lib/locale.js';
|
||||
import { BaseScreenComponent } from 'lib/components/base-screen.js';
|
||||
import { globalStyle } from 'lib/components/global-style.js';
|
||||
import { Setting } from 'lib/models/setting.js';
|
||||
|
||||
let styles = {
|
||||
body: {}
|
||||
settingContainer: {
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: globalStyle.dividerColor,
|
||||
paddingTop: globalStyle.marginTop,
|
||||
paddingBottom: globalStyle.marginBottom,
|
||||
paddingLeft: globalStyle.marginLeft,
|
||||
paddingRight: globalStyle.marginRight,
|
||||
},
|
||||
settingText: {
|
||||
fontWeight: 'bold',
|
||||
color: globalStyle.color,
|
||||
},
|
||||
settingControl: {
|
||||
color: globalStyle.color,
|
||||
},
|
||||
}
|
||||
|
||||
styles = StyleSheet.create(styles);
|
||||
@@ -45,6 +59,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
||||
let values = this.state.values;
|
||||
values[key] = value;
|
||||
this.setState({ values: values });
|
||||
this.saveSettings();
|
||||
}
|
||||
|
||||
const value = this.state.values[key];
|
||||
@@ -58,9 +73,9 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
||||
}
|
||||
|
||||
return (
|
||||
<View key={key}>
|
||||
<Text key="label">{setting.label()}</Text>
|
||||
<Picker key="control" selectedValue={value} onValueChange={(itemValue, itemIndex) => updateSettingValue(key, itemValue)} >
|
||||
<View key={key} style={styles.settingContainer}>
|
||||
<Text key="label" style={styles.settingText}>{setting.label()}</Text>
|
||||
<Picker key="control" style={styles.settingControl} selectedValue={value} onValueChange={(itemValue, itemIndex) => updateSettingValue(key, itemValue)} >
|
||||
{ items }
|
||||
</Picker>
|
||||
</View>
|
||||
@@ -72,13 +87,15 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
||||
return output;
|
||||
}
|
||||
|
||||
saveButton_press() {
|
||||
saveSettings() {
|
||||
const values = this.state.values;
|
||||
for (let key in values) {
|
||||
if (!values.hasOwnProperty(key)) continue;
|
||||
Setting.setValue(key, values[key]);
|
||||
}
|
||||
Setting.saveAll();
|
||||
|
||||
setLocale(Setting.value('locale'));
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -86,6 +103,8 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
||||
|
||||
let settingComps = [];
|
||||
for (let key in settings) {
|
||||
if (key == 'sync.target') continue;
|
||||
|
||||
if (!settings.hasOwnProperty(key)) continue;
|
||||
const comp = this.settingToComponent(key, settings[key]);
|
||||
if (!comp) continue;
|
||||
@@ -98,7 +117,6 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
||||
<View style={styles.body}>
|
||||
{ settingComps }
|
||||
</View>
|
||||
<Button title={_('Save')} onPress={() => this.saveButton_press()} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user