mirror of
https://github.com/laurent22/joplin.git
synced 2025-04-14 11:18:47 +02:00
Various RN changes
This commit is contained in:
parent
d92f1c7eba
commit
bde42a80b6
@ -90,8 +90,8 @@ android {
|
|||||||
applicationId "net.cozic.joplin"
|
applicationId "net.cozic.joplin"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 22
|
targetSdkVersion 22
|
||||||
versionCode 10
|
versionCode 11
|
||||||
versionName "0.8.8"
|
versionName "0.8.9"
|
||||||
ndk {
|
ndk {
|
||||||
abiFilters "armeabi-v7a", "x86"
|
abiFilters "armeabi-v7a", "x86"
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import { Log } from 'lib/log.js'
|
|||||||
import { Folder } from 'lib/models/folder.js'
|
import { Folder } from 'lib/models/folder.js'
|
||||||
import { BaseModel } from 'lib/base-model.js'
|
import { BaseModel } from 'lib/base-model.js'
|
||||||
import { ScreenHeader } from 'lib/components/screen-header.js';
|
import { ScreenHeader } from 'lib/components/screen-header.js';
|
||||||
|
import { NotesScreenUtils } from 'lib/components/screens/notes-utils.js'
|
||||||
|
|
||||||
class FolderScreenComponent extends React.Component {
|
class FolderScreenComponent extends React.Component {
|
||||||
|
|
||||||
@ -51,11 +52,7 @@ class FolderScreenComponent extends React.Component {
|
|||||||
this.originalFolder = await Folder.save(toSave);
|
this.originalFolder = await Folder.save(toSave);
|
||||||
this.setState({ folder: this.originalFolder });
|
this.setState({ folder: this.originalFolder });
|
||||||
|
|
||||||
this.props.dispatch({
|
await NotesScreenUtils.openDefaultNoteList();
|
||||||
type: 'Navigation/NAVIGATE',
|
|
||||||
routeName: 'Notes',
|
|
||||||
folderId: toSave.id,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Note } from 'lib/models/note.js'
|
import { Note } from 'lib/models/note.js'
|
||||||
|
import { Folder } from 'lib/models/folder.js'
|
||||||
import { Log } from 'lib/log.js'
|
import { Log } from 'lib/log.js'
|
||||||
|
|
||||||
class NotesScreenUtils {
|
class NotesScreenUtils {
|
||||||
@ -20,6 +21,18 @@ class NotesScreenUtils {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async openDefaultNoteList() {
|
||||||
|
const selectedFolder = await Folder.defaultFolder();
|
||||||
|
if (selectedFolder) {
|
||||||
|
this.openNoteList(selectedFolder.id);
|
||||||
|
} else {
|
||||||
|
this.dispatch({
|
||||||
|
type: 'Navigation/NAVIGATE',
|
||||||
|
routeName: 'Loading',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { NotesScreenUtils }
|
export { NotesScreenUtils }
|
@ -8,6 +8,8 @@ import { ScreenHeader } from 'lib/components/screen-header.js';
|
|||||||
import { MenuOption, Text } from 'react-native-popup-menu';
|
import { MenuOption, Text } from 'react-native-popup-menu';
|
||||||
import { _ } from 'lib/locale.js';
|
import { _ } from 'lib/locale.js';
|
||||||
import { ActionButton } from 'lib/components/action-button.js';
|
import { ActionButton } from 'lib/components/action-button.js';
|
||||||
|
import { dialogs } from 'lib/dialogs.js';
|
||||||
|
import { NotesScreenUtils } from 'lib/components/screens/notes-utils.js'
|
||||||
import DialogBox from 'react-native-dialogbox';
|
import DialogBox from 'react-native-dialogbox';
|
||||||
|
|
||||||
class NotesScreenComponent extends React.Component {
|
class NotesScreenComponent extends React.Component {
|
||||||
@ -17,16 +19,15 @@ class NotesScreenComponent extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteFolder_onPress(folderId) {
|
deleteFolder_onPress(folderId) {
|
||||||
let ok = confirm(_('Delete notebook?'));
|
dialogs.confirm(this, _('Delete notebook?')).then((ok) => {
|
||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
|
|
||||||
Folder.delete(folderId).then(() => {
|
|
||||||
this.props.dispatch({
|
Folder.delete(folderId).then(() => {
|
||||||
type: 'Navigation/NAVIGATE',
|
return NotesScreenUtils.openDefaultNoteList();
|
||||||
routeName: 'Folders',
|
}).catch((error) => {
|
||||||
|
alert(error.message);
|
||||||
});
|
});
|
||||||
}).catch((error) => {
|
|
||||||
alert(error.message);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,12 +50,16 @@ class NotesScreenComponent extends React.Component {
|
|||||||
let folder = Folder.byId(this.props.folders, this.props.selectedFolderId);
|
let folder = Folder.byId(this.props.folders, this.props.selectedFolderId);
|
||||||
let title = folder ? folder.title : null;
|
let title = folder ? folder.title : null;
|
||||||
|
|
||||||
|
console.info('FOLDER', folder);
|
||||||
|
|
||||||
const { navigate } = this.props.navigation;
|
const { navigate } = this.props.navigation;
|
||||||
return (
|
return (
|
||||||
<View style={{flex: 1}}>
|
<View style={{flex: 1}}>
|
||||||
<ScreenHeader title={title} navState={this.props.navigation.state} menuOptions={this.menuOptions()} />
|
<ScreenHeader title={title} navState={this.props.navigation.state} menuOptions={this.menuOptions()} />
|
||||||
<NoteList noItemMessage={_('There are currently no notes. Create one by clicking on the (+) button.')} style={{flex: 1}}/>
|
<NoteList noItemMessage={_('There are currently no notes. Create one by clicking on the (+) button.')} style={{flex: 1}}/>
|
||||||
<ActionButton parentFolderId={this.props.selectedFolderId}></ActionButton>
|
<ActionButton parentFolderId={this.props.selectedFolderId}></ActionButton>
|
||||||
|
|
||||||
|
<DialogBox ref={dialogbox => { this.dialogbox = dialogbox }}/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
32
ReactNativeClient/lib/dialogs.js
Normal file
32
ReactNativeClient/lib/dialogs.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import DialogBox from 'react-native-dialogbox';
|
||||||
|
|
||||||
|
// Add this at the bottom of the component:
|
||||||
|
//
|
||||||
|
// <DialogBox ref={dialogbox => { this.dialogbox = dialogbox }}/>
|
||||||
|
|
||||||
|
let dialogs = {};
|
||||||
|
|
||||||
|
dialogs.confirm = (parentComponent, message) => {
|
||||||
|
if (!'dialogbox' in parentComponent) throw new Error('A "dialogbox" component must be defined on the parent component!');
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
parentComponent.dialogbox.confirm({
|
||||||
|
content: message,
|
||||||
|
|
||||||
|
ok: {
|
||||||
|
callback: () => {
|
||||||
|
resolve(true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
cancel: {
|
||||||
|
callback: () => {
|
||||||
|
resolve(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export { dialogs };
|
@ -168,7 +168,7 @@ class OneDriveApi {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// TEMPORARY: To try to find where uncaught error comes from
|
// TEMPORARY: To try to find where uncaught error comes from
|
||||||
let error = new Error('OneDrive API caught: ' + error.message);
|
let error = new Error('OneDrive API caught: ' + JSON.stringify(error));
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,10 +283,7 @@ async function initialize(dispatch, backButtonHandler) {
|
|||||||
type: 'APPLICATION_LOADING_DONE',
|
type: 'APPLICATION_LOADING_DONE',
|
||||||
});
|
});
|
||||||
|
|
||||||
if (initialFolders.length) {
|
await NotesScreenUtils.openDefaultNoteList();
|
||||||
const selectedFolder = await Folder.defaultFolder();
|
|
||||||
if (selectedFolder) NotesScreenUtils.openNoteList(selectedFolder.id);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reg.logger().error('Initialization error:', error);
|
reg.logger().error('Initialization error:', error);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user