1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Mobile: Make it clearer when there are no notebooks and added a button create one

This commit is contained in:
Laurent Cozic 2019-07-30 11:36:56 +02:00
parent b9e5c8a387
commit bdd8eab87e

View File

@ -1,7 +1,7 @@
const React = require('react');
const Component = React.Component;
const { connect } = require('react-redux');
const { ListView, Text, StyleSheet } = require('react-native');
const { ListView, Text, StyleSheet, Button, View } = require('react-native');
const { _ } = require('lib/locale.js');
const { NoteItem } = require('lib/components/note-item.js');
const { time } = require('lib/time-utils.js');
@ -22,6 +22,8 @@ class NoteListComponent extends Component {
};
this.rootRef_ = null;
this.styles_ = {};
this.createNotebookButton_click = this.createNotebookButton_click.bind(this);
}
styles() {
@ -39,6 +41,10 @@ class NoteListComponent extends Component {
paddingBottom: theme.marginBottom,
fontSize: theme.fontSize,
color: theme.color,
textAlign: 'center',
},
noNotebookView: {
},
};
@ -46,6 +52,14 @@ class NoteListComponent extends Component {
return this.styles_[themeId];
}
createNotebookButton_click() {
this.props.dispatch({
type: 'NAV_GO',
routeName: 'Folder',
folderId: null,
});
}
filterNotes(notes) {
const todoFilter = 'all'; //Setting.value('todoFilter');
if (todoFilter == 'all') return notes;
@ -98,8 +112,18 @@ class NoteListComponent extends Component {
/>
);
} else {
const noItemMessage = _('There are currently no notes. Create one by clicking on the (+) button.');
return <Text style={this.styles().noItemMessage}>{noItemMessage}</Text>;
if (!this.props.folders.length) {
const noItemMessage = _('You currently have no notebooks.');
return (
<View style={this.styles().noNotebookView}>
<Text style={this.styles().noItemMessage}>{noItemMessage}</Text>
<Button title={_('Create a notebook')} onPress={this.createNotebookButton_click} />
</View>
);
} else {
const noItemMessage = _('There are currently no notes. Create one by clicking on the (+) button.');
return <Text style={this.styles().noItemMessage}>{noItemMessage}</Text>;
}
}
}
}
@ -107,6 +131,7 @@ class NoteListComponent extends Component {
const NoteList = connect(state => {
return {
items: state.notes,
folders: state.folders,
notesSource: state.notesSource,
theme: state.settings.theme,
noteSelectionEnabled: state.noteSelectionEnabled,