Desktop, Mobile: Improved config screen with dark theme

pull/1597/head
Laurent Cozic 2019-05-26 19:39:07 +01:00
parent 7b987b5a8f
commit 83682ab513
5 changed files with 79 additions and 50 deletions

View File

@ -567,6 +567,8 @@ class BaseApplication {
this.database_.setLogger(this.dbLogger_);
await this.database_.open({ name: profileDir + '/database.sqlite' });
// if (Setting.value('env') === 'dev') await this.database_.clearForTesting();
reg.setDb(this.database_);
BaseModel.db_ = this.database_;

View File

@ -167,6 +167,10 @@ module.exports = function(style, options) {
.not-loaded-resource img {
width: 1.15em;
height: 1.15em;
background: white;
padding: 2px !important;
border-radius: 2px;
box-shadow: 0 1px 3px #000000aa;
}
a.not-loaded-resource img {

View File

@ -66,12 +66,21 @@ class ConfigScreenComponent extends BaseScreenComponent {
color: theme.color,
fontSize: theme.fontSize,
flex: 1,
paddingRight: 5,
},
descriptionText: {
color: theme.color,
fontSize: theme.fontSize,
flex: 1,
},
settingDescriptionText: {
color: theme.color,
fontSize: theme.fontSize,
flex: 1,
paddingLeft: theme.marginLeft,
paddingRight: theme.marginRight,
paddingBottom: theme.marginBottom,
},
permissionText: {
color: theme.color,
fontSize: theme.fontSize,
@ -84,10 +93,13 @@ class ConfigScreenComponent extends BaseScreenComponent {
},
}
// if (Platform.OS === 'ios') {
styles.settingControl.borderBottomWidth = 1;
styles.settingControl.borderBottomColor = theme.strongDividerColor;
// }
styles.settingContainerNoBottomBorder = Object.assign({}, styles.settingContainer, {
borderBottomWidth: 0,
paddingBottom: theme.marginBottom / 2,
});
styles.settingControl.borderBottomWidth = 1;
styles.settingControl.borderBottomColor = theme.strongDividerColor;
styles.switchSettingText = Object.assign({}, styles.settingText);
styles.switchSettingText.width = '80%';
@ -121,6 +133,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
}
const md = Setting.settingMetadata(key);
const settingDescription = md.description ? md.description() : '';
if (md.isEnum) {
value = value.toString();
@ -132,27 +145,33 @@ class ConfigScreenComponent extends BaseScreenComponent {
items.push({ label: settingOptions[k], value: k.toString() });
}
const descriptionComp = !settingDescription ? null : <Text style={this.styles().settingDescriptionText}>{settingDescription}</Text>
const containerStyle = !settingDescription ? this.styles().settingContainer : this.styles().settingContainerNoBottomBorder;
return (
<View key={key} style={this.styles().settingContainer}>
<Text key="label" style={this.styles().settingText}>{md.label()}</Text>
<Dropdown
key="control"
style={this.styles().settingControl}
items={items}
selectedValue={value}
itemListStyle={{
backgroundColor: theme.backgroundColor,
}}
headerStyle={{
color: theme.color,
fontSize: theme.fontSize,
}}
itemStyle={{
color: theme.color,
fontSize: theme.fontSize,
}}
onValueChange={(itemValue, itemIndex) => { updateSettingValue(key, itemValue); }}
/>
<View style={{flexDirection:'column', borderBottomWidth: 1, borderBottomColor: theme.dividerColor}}>
<View key={key} style={containerStyle}>
<Text key="label" style={this.styles().settingText}>{md.label()}</Text>
<Dropdown
key="control"
style={this.styles().settingControl}
items={items}
selectedValue={value}
itemListStyle={{
backgroundColor: theme.backgroundColor,
}}
headerStyle={{
color: theme.color,
fontSize: theme.fontSize,
}}
itemStyle={{
color: theme.color,
fontSize: theme.fontSize,
}}
onValueChange={(itemValue, itemIndex) => { updateSettingValue(key, itemValue); }}
/>
</View>
{descriptionComp}
</View>
);
} else if (md.type == Setting.TYPE_BOOL) {

View File

@ -162,6 +162,35 @@ class JoplinDatabase extends Database {
return output;
}
async clearForTesting() {
const tableNames = [
'notes',
'folders',
'resources',
'tags',
'note_tags',
// 'master_keys',
'item_changes',
'note_resources',
// 'settings',
'deleted_items',
'sync_items',
'notes_normalized',
'revisions',
'resources_to_download',
];
const queries = [];
for (const n of tableNames) {
queries.push('DELETE FROM ' + n);
queries.push('DELETE FROM sqlite_sequence WHERE name="' + n + '"'); // Reset autoincremented IDs
}
queries.push('DELETE FROM settings WHERE key="sync.7.context"');
await this.transactionExecBatch(queries);
}
createDefaultRow(tableName) {
const row = {};
const fields = this.tableFields('resource_local_states');

View File

@ -410,32 +410,7 @@ async function initialize(dispatch) {
} else {
await db.open({ name: 'joplin-68.sqlite' });
const tableNames = [
'notes',
'folders',
'resources',
'tags',
'note_tags',
// 'master_keys',
'item_changes',
'note_resources',
// 'settings',
'deleted_items',
'sync_items',
'notes_normalized',
'revisions',
'resources_to_download',
];
const queries = [];
for (const n of tableNames) {
queries.push('DELETE FROM ' + n);
queries.push('DELETE FROM sqlite_sequence WHERE name="' + n + '"'); // Reset autoincremented IDs
}
queries.push('DELETE FROM settings WHERE key="sync.7.context"');
// await db.transactionExecBatch(queries);
// await db.clearForTesting();
}
reg.logger().info('Database is ready.');