mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Mobile: Edit and delete notebooks by long-pressing them, and removed context menu on note lists
This commit is contained in:
parent
e7e0264411
commit
d96c58d192
@ -385,7 +385,7 @@ class ScreenHeaderComponent extends Component {
|
|||||||
const sortButtonComp = this.props.sortButton_press ? sortButton(this.styles(), () => this.props.sortButton_press()) : null;
|
const sortButtonComp = this.props.sortButton_press ? sortButton(this.styles(), () => this.props.sortButton_press()) : null;
|
||||||
const windowHeight = Dimensions.get('window').height - 50;
|
const windowHeight = Dimensions.get('window').height - 50;
|
||||||
|
|
||||||
const menuComp = !showContextMenuButton ? null : (
|
const menuComp = !menuOptionComponents.length || !showContextMenuButton ? null : (
|
||||||
<Menu onSelect={(value) => this.menu_select(value)} style={this.styles().contextMenu}>
|
<Menu onSelect={(value) => this.menu_select(value)} style={this.styles().contextMenu}>
|
||||||
<MenuTrigger style={{ paddingTop: PADDING_V, paddingBottom: PADDING_V }}>
|
<MenuTrigger style={{ paddingTop: PADDING_V, paddingBottom: PADDING_V }}>
|
||||||
<Icon name='md-more' style={this.styles().contextMenuTrigger} />
|
<Icon name='md-more' style={this.styles().contextMenuTrigger} />
|
||||||
|
@ -155,8 +155,8 @@ class NotesScreenComponent extends BaseScreenComponent {
|
|||||||
if (!folder) return [];
|
if (!folder) return [];
|
||||||
|
|
||||||
let output = [];
|
let output = [];
|
||||||
if (!folder.encryption_applied) output.push({ title: _('Edit notebook'), onPress: () => { this.editFolder_onPress(this.props.selectedFolderId); } });
|
// if (!folder.encryption_applied) output.push({ title: _('Edit notebook'), onPress: () => { this.editFolder_onPress(this.props.selectedFolderId); } });
|
||||||
output.push({ title: _('Delete notebook'), onPress: () => { this.deleteFolder_onPress(this.props.selectedFolderId); } });
|
// output.push({ title: _('Delete notebook'), onPress: () => { this.deleteFolder_onPress(this.props.selectedFolderId); } });
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const React = require('react'); const Component = React.Component;
|
const React = require('react'); const Component = React.Component;
|
||||||
const { TouchableOpacity , Button, Text, Image, StyleSheet, ScrollView, View } = require('react-native');
|
const { TouchableOpacity , Button, Text, Image, StyleSheet, ScrollView, View, Alert } = require('react-native');
|
||||||
const { connect } = require('react-redux');
|
const { connect } = require('react-redux');
|
||||||
const Icon = require('react-native-vector-icons/Ionicons').default;
|
const Icon = require('react-native-vector-icons/Ionicons').default;
|
||||||
const Tag = require('lib/models/Tag.js');
|
const Tag = require('lib/models/Tag.js');
|
||||||
@ -28,6 +28,7 @@ class SideMenuContentComponent extends Component {
|
|||||||
this.newFolderButton_press = this.newFolderButton_press.bind(this);
|
this.newFolderButton_press = this.newFolderButton_press.bind(this);
|
||||||
this.synchronize_press = this.synchronize_press.bind(this);
|
this.synchronize_press = this.synchronize_press.bind(this);
|
||||||
this.configButton_press = this.configButton_press.bind(this);
|
this.configButton_press = this.configButton_press.bind(this);
|
||||||
|
this.renderFolderItem = this.renderFolderItem.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
styles() {
|
styles() {
|
||||||
@ -94,6 +95,59 @@ class SideMenuContentComponent extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async folder_longPress(folder) {
|
||||||
|
const buttons = [];
|
||||||
|
|
||||||
|
Alert.alert(
|
||||||
|
'',
|
||||||
|
_('Notebook: %s', folder.title), [
|
||||||
|
{
|
||||||
|
text: _('Rename'),
|
||||||
|
onPress: () => {
|
||||||
|
if (folder.encryption_applied) {
|
||||||
|
alert(_('Encrypted notebooks cannot be renamed'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });
|
||||||
|
|
||||||
|
this.props.dispatch({
|
||||||
|
type: 'NAV_GO',
|
||||||
|
routeName: 'Folder',
|
||||||
|
folderId: folder.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: _('Delete'),
|
||||||
|
onPress: () => {
|
||||||
|
Alert.alert('', _('Delete notebook "%s"?\n\nAll notes and sub-notebooks within this notebook will also be deleted.', folder.title), [
|
||||||
|
{
|
||||||
|
text: _('OK'),
|
||||||
|
onPress: () => {
|
||||||
|
Folder.delete(folder.id);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: _('Cancel'),
|
||||||
|
onPress: () => {},
|
||||||
|
style: 'cancel',
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
style: 'destructive',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: _('Cancel'),
|
||||||
|
onPress: () => {},
|
||||||
|
style: 'cancel',
|
||||||
|
}
|
||||||
|
], {
|
||||||
|
cancelable: false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
folder_togglePress(folder) {
|
folder_togglePress(folder) {
|
||||||
this.props.dispatch({
|
this.props.dispatch({
|
||||||
type: 'FOLDER_TOGGLE',
|
type: 'FOLDER_TOGGLE',
|
||||||
@ -130,7 +184,7 @@ class SideMenuContentComponent extends Component {
|
|||||||
if (actionDone === 'auth') this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });
|
if (actionDone === 'auth') this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });
|
||||||
}
|
}
|
||||||
|
|
||||||
folderItem(folder, selected, hasChildren, depth) {
|
renderFolderItem(folder, selected, hasChildren, depth) {
|
||||||
const theme = themeStyle(this.props.theme);
|
const theme = themeStyle(this.props.theme);
|
||||||
|
|
||||||
const folderButtonStyle = {
|
const folderButtonStyle = {
|
||||||
@ -158,7 +212,7 @@ class SideMenuContentComponent extends Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View key={folder.id} style={{ flex: 1, flexDirection: 'row' }}>
|
<View key={folder.id} style={{ flex: 1, flexDirection: 'row' }}>
|
||||||
<TouchableOpacity style={{ flex: 1 }} onPress={() => { this.folder_press(folder) }}>
|
<TouchableOpacity style={{ flex: 1 }} onPress={() => { this.folder_press(folder) }} onLongPress={() => { this.folder_longPress(folder) }}>
|
||||||
<View style={folderButtonStyle}>
|
<View style={folderButtonStyle}>
|
||||||
<Text numberOfLines={1} style={this.styles().folderButtonText}>{Folder.displayTitle(folder)}</Text>
|
<Text numberOfLines={1} style={this.styles().folderButtonText}>{Folder.displayTitle(folder)}</Text>
|
||||||
</View>
|
</View>
|
||||||
@ -244,7 +298,7 @@ class SideMenuContentComponent extends Component {
|
|||||||
items.push(<View style={{ height: globalStyle.marginTop }} key='bottom_top_hack'/>);
|
items.push(<View style={{ height: globalStyle.marginTop }} key='bottom_top_hack'/>);
|
||||||
|
|
||||||
if (this.props.folders.length) {
|
if (this.props.folders.length) {
|
||||||
const result = shared.renderFolders(this.props, this.folderItem.bind(this));
|
const result = shared.renderFolders(this.props, this.renderFolderItem);
|
||||||
const folderItems = result.items;
|
const folderItems = result.items;
|
||||||
items = items.concat(folderItems);
|
items = items.concat(folderItems);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user