You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-07 22:03:09 +02:00
Applied prettier to code base
This commit is contained in:
@ -1,17 +1,17 @@
|
||||
const React = require('react'); const Component = React.Component;
|
||||
const { Platform, TouchableOpacity, Linking, View, Switch, Slider, StyleSheet, Text, Button, ScrollView, TextInput } = require('react-native');
|
||||
const { connect } = require('react-redux');
|
||||
const { ScreenHeader } = require('lib/components/screen-header.js');
|
||||
const { _, setLocale } = require('lib/locale.js');
|
||||
const { BaseScreenComponent } = require('lib/components/base-screen.js');
|
||||
const { Dropdown } = require('lib/components/Dropdown.js');
|
||||
const { themeStyle } = require('lib/components/global-style.js');
|
||||
const Setting = require('lib/models/Setting.js');
|
||||
const shared = require('lib/components/shared/config-shared.js');
|
||||
const SyncTargetRegistry = require('lib/SyncTargetRegistry');
|
||||
const React = require("react");
|
||||
const Component = React.Component;
|
||||
const { Platform, TouchableOpacity, Linking, View, Switch, Slider, StyleSheet, Text, Button, ScrollView, TextInput } = require("react-native");
|
||||
const { connect } = require("react-redux");
|
||||
const { ScreenHeader } = require("lib/components/screen-header.js");
|
||||
const { _, setLocale } = require("lib/locale.js");
|
||||
const { BaseScreenComponent } = require("lib/components/base-screen.js");
|
||||
const { Dropdown } = require("lib/components/Dropdown.js");
|
||||
const { themeStyle } = require("lib/components/global-style.js");
|
||||
const Setting = require("lib/models/Setting.js");
|
||||
const shared = require("lib/components/shared/config-shared.js");
|
||||
const SyncTargetRegistry = require("lib/SyncTargetRegistry");
|
||||
|
||||
class ConfigScreenComponent extends BaseScreenComponent {
|
||||
|
||||
static navigationOptions(options) {
|
||||
return { header: null };
|
||||
}
|
||||
@ -24,7 +24,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
||||
|
||||
this.checkSyncConfig_ = async () => {
|
||||
await shared.checkSyncConfig(this, this.state.settings);
|
||||
}
|
||||
};
|
||||
|
||||
this.saveButton_press = () => {
|
||||
return shared.saveSettings(this);
|
||||
@ -45,13 +45,13 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
||||
let styles = {
|
||||
body: {
|
||||
flex: 1,
|
||||
justifyContent: 'flex-start',
|
||||
flexDirection: 'column',
|
||||
justifyContent: "flex-start",
|
||||
flexDirection: "column",
|
||||
},
|
||||
settingContainer: {
|
||||
flex: 1,
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: theme.dividerColor,
|
||||
paddingTop: theme.marginTop,
|
||||
@ -60,7 +60,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
||||
paddingRight: theme.marginRight,
|
||||
},
|
||||
settingText: {
|
||||
fontWeight: 'bold',
|
||||
fontWeight: "bold",
|
||||
color: theme.color,
|
||||
fontSize: theme.fontSize,
|
||||
flex: 1,
|
||||
@ -74,25 +74,25 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
||||
color: theme.color,
|
||||
flex: 1,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
if (Platform.OS === 'ios') {
|
||||
if (Platform.OS === "ios") {
|
||||
styles.settingControl.borderBottomWidth = 1;
|
||||
styles.settingControl.borderBottomColor = theme.dividerColor;
|
||||
}
|
||||
|
||||
styles.switchSettingText = Object.assign({}, styles.settingText);
|
||||
styles.switchSettingText.width = '80%';
|
||||
styles.switchSettingText.width = "80%";
|
||||
|
||||
styles.switchSettingContainer = Object.assign({}, styles.settingContainer);
|
||||
styles.switchSettingContainer.flexDirection = 'row';
|
||||
styles.switchSettingContainer.justifyContent = 'space-between';
|
||||
styles.switchSettingContainer.flexDirection = "row";
|
||||
styles.switchSettingContainer.justifyContent = "space-between";
|
||||
|
||||
styles.linkText = Object.assign({}, styles.settingText);
|
||||
styles.linkText.borderBottomWidth = 1;
|
||||
styles.linkText.borderBottomColor = theme.color;
|
||||
styles.linkText.flex = 0;
|
||||
styles.linkText.fontWeight = 'normal';
|
||||
styles.linkText.fontWeight = "normal";
|
||||
|
||||
styles.switchSettingControl = Object.assign({}, styles.settingControl);
|
||||
delete styles.switchSettingControl.color;
|
||||
@ -110,7 +110,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
||||
|
||||
const updateSettingValue = (key, value) => {
|
||||
return shared.updateSettingValue(this, key, value);
|
||||
}
|
||||
};
|
||||
|
||||
const md = Setting.settingMetadata(key);
|
||||
|
||||
@ -126,7 +126,9 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
||||
|
||||
return (
|
||||
<View key={key} style={this.styles().settingContainer}>
|
||||
<Text key="label" style={this.styles().settingText}>{md.label()}</Text>
|
||||
<Text key="label" style={this.styles().settingText}>
|
||||
{md.label()}
|
||||
</Text>
|
||||
<Dropdown
|
||||
key="control"
|
||||
style={this.styles().settingControl}
|
||||
@ -143,29 +145,37 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
||||
color: theme.color,
|
||||
fontSize: theme.fontSize,
|
||||
}}
|
||||
onValueChange={(itemValue, itemIndex) => { updateSettingValue(key, itemValue); }}
|
||||
onValueChange={(itemValue, itemIndex) => {
|
||||
updateSettingValue(key, itemValue);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
} else if (md.type == Setting.TYPE_BOOL) {
|
||||
return (
|
||||
<View key={key} style={this.styles().switchSettingContainer}>
|
||||
<Text key="label" style={this.styles().switchSettingText}>{md.label()}</Text>
|
||||
<Switch key="control" style={this.styles().switchSettingControl} value={value} onValueChange={(value) => updateSettingValue(key, value)} />
|
||||
<Text key="label" style={this.styles().switchSettingText}>
|
||||
{md.label()}
|
||||
</Text>
|
||||
<Switch key="control" style={this.styles().switchSettingControl} value={value} onValueChange={value => updateSettingValue(key, value)} />
|
||||
</View>
|
||||
);
|
||||
} else if (md.type == Setting.TYPE_INT) {
|
||||
return (
|
||||
<View key={key} style={this.styles().settingContainer}>
|
||||
<Text key="label" style={this.styles().settingText}>{md.label()}</Text>
|
||||
<Slider key="control" style={this.styles().settingControl} value={value} onValueChange={(value) => updateSettingValue(key, value)} />
|
||||
<Text key="label" style={this.styles().settingText}>
|
||||
{md.label()}
|
||||
</Text>
|
||||
<Slider key="control" style={this.styles().settingControl} value={value} onValueChange={value => updateSettingValue(key, value)} />
|
||||
</View>
|
||||
);
|
||||
} else if (md.type == Setting.TYPE_STRING) {
|
||||
return (
|
||||
<View key={key} style={this.styles().settingContainer}>
|
||||
<Text key="label" style={this.styles().settingText}>{md.label()}</Text>
|
||||
<TextInput autoCapitalize="none" key="control" style={this.styles().settingControl} value={value} onChangeText={(value) => updateSettingValue(key, value)} secureTextEntry={!!md.secure} />
|
||||
<Text key="label" style={this.styles().settingText}>
|
||||
{md.label()}
|
||||
</Text>
|
||||
<TextInput autoCapitalize="none" key="control" style={this.styles().settingControl} value={value} onChangeText={value => updateSettingValue(key, value)} secureTextEntry={!!md.secure} />
|
||||
</View>
|
||||
);
|
||||
} else {
|
||||
@ -178,77 +188,91 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
||||
render() {
|
||||
const settings = this.state.settings;
|
||||
|
||||
const settingComps = shared.settingsToComponents(this, 'mobile', settings);
|
||||
const settingComps = shared.settingsToComponents(this, "mobile", settings);
|
||||
|
||||
const syncTargetMd = SyncTargetRegistry.idToMetadata(settings['sync.target']);
|
||||
const syncTargetMd = SyncTargetRegistry.idToMetadata(settings["sync.target"]);
|
||||
|
||||
if (syncTargetMd.supportsConfigCheck) {
|
||||
const messages = shared.checkSyncConfigMessages(this);
|
||||
const statusComp = !messages.length ? null : (
|
||||
<View style={{flex:1, marginTop: 10}}>
|
||||
<View style={{ flex: 1, marginTop: 10 }}>
|
||||
<Text style={this.styles().descriptionText}>{messages[0]}</Text>
|
||||
{messages.length >= 1 ? (<View style={{marginTop:10}}><Text style={this.styles().descriptionText}>{messages[1]}</Text></View>) : null}
|
||||
</View>);
|
||||
{messages.length >= 1 ? (
|
||||
<View style={{ marginTop: 10 }}>
|
||||
<Text style={this.styles().descriptionText}>{messages[1]}</Text>
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
);
|
||||
|
||||
settingComps.push(
|
||||
<View key="check_sync_config_button" style={this.styles().settingContainer}>
|
||||
<View style={{flex:1, flexDirection: 'column'}}>
|
||||
<View style={{flex:1}}>
|
||||
<Button title={_('Check synchronisation configuration')} onPress={this.checkSyncConfig_}/>
|
||||
<View style={{ flex: 1, flexDirection: "column" }}>
|
||||
<View style={{ flex: 1 }}>
|
||||
<Button title={_("Check synchronisation configuration")} onPress={this.checkSyncConfig_} />
|
||||
</View>
|
||||
{ statusComp }
|
||||
{statusComp}
|
||||
</View>
|
||||
</View>);
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
settingComps.push(
|
||||
<View key="donate_link" style={this.styles().settingContainer}>
|
||||
<TouchableOpacity onPress={() => { Linking.openURL('http://joplin.cozic.net/donate/') }}>
|
||||
<Text key="label" style={this.styles().linkText}>{_('Make a donation')}</Text>
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
Linking.openURL("http://joplin.cozic.net/donate/");
|
||||
}}
|
||||
>
|
||||
<Text key="label" style={this.styles().linkText}>
|
||||
{_("Make a donation")}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
|
||||
|
||||
settingComps.push(
|
||||
<View key="website_link" style={this.styles().settingContainer}>
|
||||
<TouchableOpacity onPress={() => { Linking.openURL('http://joplin.cozic.net/') }}>
|
||||
<Text key="label" style={this.styles().linkText}>{_('Joplin website')}</Text>
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
Linking.openURL("http://joplin.cozic.net/");
|
||||
}}
|
||||
>
|
||||
<Text key="label" style={this.styles().linkText}>
|
||||
{_("Joplin website")}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
|
||||
settingComps.push(
|
||||
<View key="privacy_link" style={this.styles().settingContainer}>
|
||||
<TouchableOpacity onPress={() => { Linking.openURL('http://joplin.cozic.net/privacy/') }}>
|
||||
<Text key="label" style={this.styles().linkText}>Privacy Policy</Text>
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
Linking.openURL("http://joplin.cozic.net/privacy/");
|
||||
}}
|
||||
>
|
||||
<Text key="label" style={this.styles().linkText}>
|
||||
Privacy Policy
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
|
||||
return (
|
||||
<View style={this.rootStyle(this.props.theme).root}>
|
||||
<ScreenHeader
|
||||
title={_('Configuration')}
|
||||
showSaveButton={true}
|
||||
saveButtonDisabled={!this.state.changedSettingKeys.length}
|
||||
onSaveButtonPress={this.saveButton_press}
|
||||
/>
|
||||
<ScrollView >
|
||||
{ settingComps }
|
||||
</ScrollView>
|
||||
<ScreenHeader title={_("Configuration")} showSaveButton={true} saveButtonDisabled={!this.state.changedSettingKeys.length} onSaveButtonPress={this.saveButton_press} />
|
||||
<ScrollView>{settingComps}</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const ConfigScreen = connect(
|
||||
(state) => {
|
||||
return {
|
||||
settings: state.settings,
|
||||
theme: state.settings.theme,
|
||||
};
|
||||
}
|
||||
)(ConfigScreenComponent)
|
||||
const ConfigScreen = connect(state => {
|
||||
return {
|
||||
settings: state.settings,
|
||||
theme: state.settings.theme,
|
||||
};
|
||||
})(ConfigScreenComponent);
|
||||
|
||||
module.exports = { ConfigScreen };
|
||||
module.exports = { ConfigScreen };
|
||||
|
Reference in New Issue
Block a user