You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-12-14 23:26:58 +02:00
Applied prettier to code base
This commit is contained in:
@@ -1,41 +1,41 @@
|
||||
const React = require('react'); const Component = React.Component;
|
||||
const { Platform, Keyboard, BackHandler, View, Button, TextInput, WebView, Text, StyleSheet, Linking, Image } = require('react-native');
|
||||
const { connect } = require('react-redux');
|
||||
const { uuid } = require('lib/uuid.js');
|
||||
const { Log } = require('lib/log.js');
|
||||
const RNFS = require('react-native-fs');
|
||||
const Note = require('lib/models/Note.js');
|
||||
const Setting = require('lib/models/Setting.js');
|
||||
const Resource = require('lib/models/Resource.js');
|
||||
const Folder = require('lib/models/Folder.js');
|
||||
const { BackButtonService } = require('lib/services/back-button.js');
|
||||
const NavService = require('lib/services/NavService.js');
|
||||
const BaseModel = require('lib/BaseModel.js');
|
||||
const { ActionButton } = require('lib/components/action-button.js');
|
||||
const Icon = require('react-native-vector-icons/Ionicons').default;
|
||||
const { fileExtension, basename, safeFileExtension } = require('lib/path-utils.js');
|
||||
const mimeUtils = require('lib/mime-utils.js').mime;
|
||||
const { ScreenHeader } = require('lib/components/screen-header.js');
|
||||
const { time } = require('lib/time-utils.js');
|
||||
const { Checkbox } = require('lib/components/checkbox.js');
|
||||
const { _ } = require('lib/locale.js');
|
||||
const { reg } = require('lib/registry.js');
|
||||
const { shim } = require('lib/shim.js');
|
||||
const { BaseScreenComponent } = require('lib/components/base-screen.js');
|
||||
const { dialogs } = require('lib/dialogs.js');
|
||||
const { globalStyle, themeStyle } = require('lib/components/global-style.js');
|
||||
const DialogBox = require('react-native-dialogbox').default;
|
||||
const { NoteBodyViewer } = require('lib/components/note-body-viewer.js');
|
||||
const RNFetchBlob = require('react-native-fetch-blob').default;
|
||||
const { DocumentPicker, DocumentPickerUtil } = require('react-native-document-picker');
|
||||
const ImageResizer = require('react-native-image-resizer').default;
|
||||
const shared = require('lib/components/shared/note-screen-shared.js');
|
||||
const ImagePicker = require('react-native-image-picker');
|
||||
const AlarmService = require('lib/services/AlarmService.js');
|
||||
const { SelectDateTimeDialog } = require('lib/components/select-date-time-dialog.js');
|
||||
const React = require("react");
|
||||
const Component = React.Component;
|
||||
const { Platform, Keyboard, BackHandler, View, Button, TextInput, WebView, Text, StyleSheet, Linking, Image } = require("react-native");
|
||||
const { connect } = require("react-redux");
|
||||
const { uuid } = require("lib/uuid.js");
|
||||
const { Log } = require("lib/log.js");
|
||||
const RNFS = require("react-native-fs");
|
||||
const Note = require("lib/models/Note.js");
|
||||
const Setting = require("lib/models/Setting.js");
|
||||
const Resource = require("lib/models/Resource.js");
|
||||
const Folder = require("lib/models/Folder.js");
|
||||
const { BackButtonService } = require("lib/services/back-button.js");
|
||||
const NavService = require("lib/services/NavService.js");
|
||||
const BaseModel = require("lib/BaseModel.js");
|
||||
const { ActionButton } = require("lib/components/action-button.js");
|
||||
const Icon = require("react-native-vector-icons/Ionicons").default;
|
||||
const { fileExtension, basename, safeFileExtension } = require("lib/path-utils.js");
|
||||
const mimeUtils = require("lib/mime-utils.js").mime;
|
||||
const { ScreenHeader } = require("lib/components/screen-header.js");
|
||||
const { time } = require("lib/time-utils.js");
|
||||
const { Checkbox } = require("lib/components/checkbox.js");
|
||||
const { _ } = require("lib/locale.js");
|
||||
const { reg } = require("lib/registry.js");
|
||||
const { shim } = require("lib/shim.js");
|
||||
const { BaseScreenComponent } = require("lib/components/base-screen.js");
|
||||
const { dialogs } = require("lib/dialogs.js");
|
||||
const { globalStyle, themeStyle } = require("lib/components/global-style.js");
|
||||
const DialogBox = require("react-native-dialogbox").default;
|
||||
const { NoteBodyViewer } = require("lib/components/note-body-viewer.js");
|
||||
const RNFetchBlob = require("react-native-fetch-blob").default;
|
||||
const { DocumentPicker, DocumentPickerUtil } = require("react-native-document-picker");
|
||||
const ImageResizer = require("react-native-image-resizer").default;
|
||||
const shared = require("lib/components/shared/note-screen-shared.js");
|
||||
const ImagePicker = require("react-native-image-picker");
|
||||
const AlarmService = require("lib/services/AlarmService.js");
|
||||
const { SelectDateTimeDialog } = require("lib/components/select-date-time-dialog.js");
|
||||
|
||||
class NoteScreenComponent extends BaseScreenComponent {
|
||||
|
||||
static navigationOptions(options) {
|
||||
return { header: null };
|
||||
}
|
||||
@@ -44,19 +44,19 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
super();
|
||||
this.state = {
|
||||
note: Note.new(),
|
||||
mode: 'view',
|
||||
noteMetadata: '',
|
||||
mode: "view",
|
||||
noteMetadata: "",
|
||||
showNoteMetadata: false,
|
||||
folder: null,
|
||||
lastSavedNote: null,
|
||||
isLoading: true,
|
||||
titleTextInputHeight: 20,
|
||||
alarmDialogShown: false,
|
||||
heightBumpView:0
|
||||
heightBumpView: 0,
|
||||
};
|
||||
|
||||
// iOS doesn't support multiline text fields properly so disable it
|
||||
this.enableMultilineTitle_ = Platform.OS !== 'ios';
|
||||
this.enableMultilineTitle_ = Platform.OS !== "ios";
|
||||
|
||||
this.saveButtonHasBeenShown_ = false;
|
||||
|
||||
@@ -64,22 +64,22 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
|
||||
const saveDialog = async () => {
|
||||
if (this.isModified()) {
|
||||
let buttonId = await dialogs.pop(this, _('This note has been modified:'), [
|
||||
{ text: _('Save changes'), id: 'save' },
|
||||
{ text: _('Discard changes'), id: 'discard' },
|
||||
{ text: _('Cancel'), id: 'cancel' },
|
||||
let buttonId = await dialogs.pop(this, _("This note has been modified:"), [
|
||||
{ text: _("Save changes"), id: "save" },
|
||||
{ text: _("Discard changes"), id: "discard" },
|
||||
{ text: _("Cancel"), id: "cancel" },
|
||||
]);
|
||||
|
||||
if (buttonId == 'cancel') return true;
|
||||
if (buttonId == 'save') await this.saveNoteButton_press();
|
||||
if (buttonId == "cancel") return true;
|
||||
if (buttonId == "save") await this.saveNoteButton_press();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
this.navHandler = async () => {
|
||||
return await saveDialog();
|
||||
}
|
||||
};
|
||||
|
||||
this.backHandler = async () => {
|
||||
const r = await saveDialog();
|
||||
@@ -89,12 +89,12 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.state.mode == 'edit') {
|
||||
Keyboard.dismiss()
|
||||
if (this.state.mode == "edit") {
|
||||
Keyboard.dismiss();
|
||||
|
||||
this.setState({
|
||||
note: Object.assign({}, this.state.lastSavedNote),
|
||||
mode: 'view',
|
||||
mode: "view",
|
||||
});
|
||||
|
||||
return true;
|
||||
@@ -116,7 +116,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
flex: 1,
|
||||
paddingLeft: theme.marginLeft,
|
||||
paddingRight: theme.marginRight,
|
||||
textAlignVertical: 'top',
|
||||
textAlignVertical: "top",
|
||||
color: theme.color,
|
||||
backgroundColor: theme.backgroundColor,
|
||||
fontSize: theme.fontSize,
|
||||
@@ -137,7 +137,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
|
||||
styles.titleContainer = {
|
||||
flex: 0,
|
||||
flexDirection: 'row',
|
||||
flexDirection: "row",
|
||||
paddingLeft: theme.marginLeft,
|
||||
paddingRight: theme.marginRight,
|
||||
borderBottomColor: theme.dividerColor,
|
||||
@@ -174,11 +174,11 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
}
|
||||
|
||||
title_changeText(text) {
|
||||
shared.noteComponent_change(this, 'title', text);
|
||||
shared.noteComponent_change(this, "title", text);
|
||||
}
|
||||
|
||||
body_changeText(text) {
|
||||
shared.noteComponent_change(this, 'body', text);
|
||||
shared.noteComponent_change(this, "body", text);
|
||||
}
|
||||
|
||||
async saveNoteButton_press() {
|
||||
@@ -195,7 +195,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
let note = this.state.note;
|
||||
if (!note.id) return;
|
||||
|
||||
let ok = await dialogs.confirm(this, _('Delete note?'));
|
||||
let ok = await dialogs.confirm(this, _("Delete note?"));
|
||||
if (!ok) return;
|
||||
|
||||
let folderId = note.parent_id;
|
||||
@@ -203,19 +203,19 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
await Note.delete(note.id);
|
||||
|
||||
this.props.dispatch({
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Notes',
|
||||
type: "NAV_GO",
|
||||
routeName: "Notes",
|
||||
folderId: folderId,
|
||||
});
|
||||
}
|
||||
|
||||
async pickDocument() {
|
||||
return new Promise((resolve, reject) => {
|
||||
DocumentPicker.show({ filetype: [DocumentPickerUtil.allFiles()] }, (error,res) => {
|
||||
DocumentPicker.show({ filetype: [DocumentPickerUtil.allFiles()] }, (error, res) => {
|
||||
if (error) {
|
||||
// Also returns an error if the user doesn't pick a file
|
||||
// so just resolve with null.
|
||||
console.info('pickDocument error:', error);
|
||||
console.info("pickDocument error:", error);
|
||||
resolve(null);
|
||||
return;
|
||||
}
|
||||
@@ -227,15 +227,21 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
|
||||
async imageDimensions(uri) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Image.getSize(uri, (width, height) => {
|
||||
resolve({ width: width, height: height });
|
||||
}, (error) => { reject(error) });
|
||||
Image.getSize(
|
||||
uri,
|
||||
(width, height) => {
|
||||
resolve({ width: width, height: height });
|
||||
},
|
||||
error => {
|
||||
reject(error);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
showImagePicker(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
ImagePicker.showImagePicker(options, (response) => {
|
||||
ImagePicker.showImagePicker(options, response => {
|
||||
resolve(response);
|
||||
});
|
||||
});
|
||||
@@ -246,43 +252,43 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
|
||||
let dimensions = await this.imageDimensions(localFilePath);
|
||||
|
||||
reg.logger().info('Original dimensions ', dimensions);
|
||||
reg.logger().info("Original dimensions ", dimensions);
|
||||
if (dimensions.width > maxSize || dimensions.height > maxSize) {
|
||||
dimensions.width = maxSize;
|
||||
dimensions.height = maxSize;
|
||||
}
|
||||
reg.logger().info('New dimensions ', dimensions);
|
||||
reg.logger().info("New dimensions ", dimensions);
|
||||
|
||||
const format = mimeType == 'image/png' ? 'PNG' : 'JPEG';
|
||||
reg.logger().info('Resizing image ' + localFilePath);
|
||||
const format = mimeType == "image/png" ? "PNG" : "JPEG";
|
||||
reg.logger().info("Resizing image " + localFilePath);
|
||||
const resizedImage = await ImageResizer.createResizedImage(localFilePath, dimensions.width, dimensions.height, format, 85); //, 0, targetPath);
|
||||
|
||||
const resizedImagePath = resizedImage.uri;
|
||||
reg.logger().info('Resized image ', resizedImagePath);
|
||||
reg.logger().info('Moving ' + resizedImagePath + ' => ' + targetPath);
|
||||
reg.logger().info("Resized image ", resizedImagePath);
|
||||
reg.logger().info("Moving " + resizedImagePath + " => " + targetPath);
|
||||
|
||||
await RNFS.copyFile(resizedImagePath, targetPath);
|
||||
|
||||
try {
|
||||
await RNFS.unlink(resizedImagePath);
|
||||
} catch (error) {
|
||||
reg.logger().warn('Error when unlinking cached file: ', error);
|
||||
reg.logger().warn("Error when unlinking cached file: ", error);
|
||||
}
|
||||
}
|
||||
|
||||
async attachFile(pickerResponse, fileType) {
|
||||
if (!pickerResponse) {
|
||||
reg.logger().warn('Got no response from picker');
|
||||
reg.logger().warn("Got no response from picker");
|
||||
return;
|
||||
}
|
||||
|
||||
if (pickerResponse.error) {
|
||||
reg.logger().warn('Got error from picker', pickerResponse.error);
|
||||
reg.logger().warn("Got error from picker", pickerResponse.error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pickerResponse.didCancel) {
|
||||
reg.logger().info('User cancelled picker');
|
||||
reg.logger().info("User cancelled picker");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -294,41 +300,41 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
mimeType = mimeUtils.fromFileExtension(ext);
|
||||
}
|
||||
|
||||
if (!mimeType && fileType === 'image') {
|
||||
if (!mimeType && fileType === "image") {
|
||||
// Assume JPEG if we couldn't determine the file type. It seems to happen with the image picker
|
||||
// when the file path is something like content://media/external/images/media/123456
|
||||
// If the image is not a JPEG, something will throw an error below, but there's a good chance
|
||||
// it will work.
|
||||
reg.logger().info('Missing file type and could not detect it - assuming image/jpg');
|
||||
mimeType = 'image/jpg';
|
||||
reg.logger().info("Missing file type and could not detect it - assuming image/jpg");
|
||||
mimeType = "image/jpg";
|
||||
}
|
||||
|
||||
reg.logger().info('Got file: ' + localFilePath);
|
||||
reg.logger().info('Got type: ' + mimeType);
|
||||
reg.logger().info("Got file: " + localFilePath);
|
||||
reg.logger().info("Got type: " + mimeType);
|
||||
|
||||
let resource = Resource.new();
|
||||
resource.id = uuid.create();
|
||||
resource.mime = mimeType;
|
||||
resource.title = pickerResponse.fileName ? pickerResponse.fileName : _('Untitled');
|
||||
resource.title = pickerResponse.fileName ? pickerResponse.fileName : _("Untitled");
|
||||
resource.file_extension = safeFileExtension(fileExtension(pickerResponse.fileName));
|
||||
|
||||
if (!resource.mime) resource.mime = 'application/octet-stream';
|
||||
if (!resource.mime) resource.mime = "application/octet-stream";
|
||||
|
||||
let targetPath = Resource.fullPath(resource);
|
||||
|
||||
try {
|
||||
if (mimeType == 'image/jpeg' || mimeType == 'image/jpg' || mimeType == 'image/png') {
|
||||
if (mimeType == "image/jpeg" || mimeType == "image/jpg" || mimeType == "image/png") {
|
||||
await this.resizeImage(localFilePath, targetPath, pickerResponse.mime);
|
||||
} else {
|
||||
if (fileType === 'image') {
|
||||
dialogs.error(this, _('Unsupported image type: %s', mimeType));
|
||||
if (fileType === "image") {
|
||||
dialogs.error(this, _("Unsupported image type: %s", mimeType));
|
||||
return;
|
||||
} else {
|
||||
await RNFetchBlob.fs.cp(localFilePath, targetPath);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
reg.logger().warn('Could not attach file:', error);
|
||||
reg.logger().warn("Could not attach file:", error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -343,15 +349,15 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
|
||||
async attachImage_onPress() {
|
||||
const options = {
|
||||
mediaType: 'photo',
|
||||
mediaType: "photo",
|
||||
};
|
||||
const response = await this.showImagePicker(options);
|
||||
await this.attachFile(response, 'image');
|
||||
await this.attachFile(response, "image");
|
||||
}
|
||||
|
||||
async attachFile_onPress() {
|
||||
const response = await this.pickDocument();
|
||||
await this.attachFile(response, 'all');
|
||||
await this.attachFile(response, "all");
|
||||
}
|
||||
|
||||
toggleIsTodo_onPress() {
|
||||
@@ -366,7 +372,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
let newNote = Object.assign({}, this.state.note);
|
||||
newNote.todo_due = date ? date.getTime() : 0;
|
||||
|
||||
await this.saveOneProperty('todo_due', date ? date.getTime() : 0);
|
||||
await this.saveOneProperty("todo_due", date ? date.getTime() : 0);
|
||||
|
||||
this.setState({ alarmDialogShown: false });
|
||||
}
|
||||
@@ -400,29 +406,65 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
// The file attachement modules only work in Android >= 5 (Version 21)
|
||||
// https://github.com/react-community/react-native-image-picker/issues/606
|
||||
let canAttachPicture = true;
|
||||
if (Platform.OS === 'android' && Platform.Version < 21) canAttachPicture = false;
|
||||
if (Platform.OS === "android" && Platform.Version < 21) canAttachPicture = false;
|
||||
if (canAttachPicture) {
|
||||
output.push({ title: _('Attach photo'), onPress: () => { this.attachImage_onPress(); } });
|
||||
output.push({ title: _('Attach any file'), onPress: () => { this.attachFile_onPress(); } });
|
||||
output.push({
|
||||
title: _("Attach photo"),
|
||||
onPress: () => {
|
||||
this.attachImage_onPress();
|
||||
},
|
||||
});
|
||||
output.push({
|
||||
title: _("Attach any file"),
|
||||
onPress: () => {
|
||||
this.attachFile_onPress();
|
||||
},
|
||||
});
|
||||
output.push({ isDivider: true });
|
||||
}
|
||||
|
||||
if (isTodo) {
|
||||
output.push({ title: _('Set alarm'), onPress: () => { this.setState({ alarmDialogShown: true }) }});;
|
||||
output.push({
|
||||
title: _("Set alarm"),
|
||||
onPress: () => {
|
||||
this.setState({ alarmDialogShown: true });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
output.push({ title: isTodo ? _('Convert to note') : _('Convert to todo'), onPress: () => { this.toggleIsTodo_onPress(); } });
|
||||
output.push({
|
||||
title: isTodo ? _("Convert to note") : _("Convert to todo"),
|
||||
onPress: () => {
|
||||
this.toggleIsTodo_onPress();
|
||||
},
|
||||
});
|
||||
output.push({ isDivider: true });
|
||||
if (this.props.showAdvancedOptions) output.push({ title: this.state.showNoteMetadata ? _('Hide metadata') : _('Show metadata'), onPress: () => { this.showMetadata_onPress(); } });
|
||||
output.push({ title: _('View on map'), onPress: () => { this.showOnMap_onPress(); } });
|
||||
if (this.props.showAdvancedOptions)
|
||||
output.push({
|
||||
title: this.state.showNoteMetadata ? _("Hide metadata") : _("Show metadata"),
|
||||
onPress: () => {
|
||||
this.showMetadata_onPress();
|
||||
},
|
||||
});
|
||||
output.push({
|
||||
title: _("View on map"),
|
||||
onPress: () => {
|
||||
this.showOnMap_onPress();
|
||||
},
|
||||
});
|
||||
output.push({ isDivider: true });
|
||||
output.push({ title: _('Delete'), onPress: () => { this.deleteNote_onPress(); } });
|
||||
output.push({
|
||||
title: _("Delete"),
|
||||
onPress: () => {
|
||||
this.deleteNote_onPress();
|
||||
},
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
async todoCheckbox_change(checked) {
|
||||
await this.saveOneProperty('todo_completed', checked ? time.unixMs() : 0);
|
||||
await this.saveOneProperty("todo_completed", checked ? time.unixMs() : 0);
|
||||
}
|
||||
|
||||
titleTextInput_contentSizeChange(event) {
|
||||
@@ -436,7 +478,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
if (this.state.isLoading) {
|
||||
return (
|
||||
<View style={this.styles().screen}>
|
||||
<ScreenHeader/>
|
||||
<ScreenHeader />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -448,12 +490,21 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
const isNew = !note.id;
|
||||
|
||||
let bodyComponent = null;
|
||||
if (this.state.mode == 'view') {
|
||||
const onCheckboxChange = (newBody) => {
|
||||
this.saveOneProperty('body', newBody);
|
||||
if (this.state.mode == "view") {
|
||||
const onCheckboxChange = newBody => {
|
||||
this.saveOneProperty("body", newBody);
|
||||
};
|
||||
|
||||
bodyComponent = <NoteBodyViewer style={this.styles().noteBodyViewer} webViewStyle={theme} note={note} onCheckboxChange={(newBody) => { onCheckboxChange(newBody) }}/>
|
||||
bodyComponent = (
|
||||
<NoteBodyViewer
|
||||
style={this.styles().noteBodyViewer}
|
||||
webViewStyle={theme}
|
||||
note={note}
|
||||
onCheckboxChange={newBody => {
|
||||
onCheckboxChange(newBody);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
const focusBody = !isNew && !!note.title;
|
||||
|
||||
@@ -466,7 +517,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
style={this.styles().bodyTextInput}
|
||||
multiline={true}
|
||||
value={note.body}
|
||||
onChangeText={(text) => this.body_changeText(text)}
|
||||
onChangeText={text => this.body_changeText(text)}
|
||||
blurOnSubmit={false}
|
||||
/>
|
||||
);
|
||||
@@ -476,21 +527,21 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
let buttons = [];
|
||||
|
||||
buttons.push({
|
||||
title: _('Edit'),
|
||||
icon: 'md-create',
|
||||
title: _("Edit"),
|
||||
icon: "md-create",
|
||||
onPress: () => {
|
||||
this.setState({ mode: 'edit' });
|
||||
this.setState({ mode: "edit" });
|
||||
},
|
||||
});
|
||||
|
||||
if (this.state.mode == 'edit') return <ActionButton style={{display:'none'}}/>;
|
||||
if (this.state.mode == "edit") return <ActionButton style={{ display: "none" }} />;
|
||||
|
||||
return <ActionButton multiStates={true} buttons={buttons} buttonIndex={0} />
|
||||
}
|
||||
return <ActionButton multiStates={true} buttons={buttons} buttonIndex={0} />;
|
||||
};
|
||||
|
||||
const actionButtonComp = renderActionButton();
|
||||
|
||||
let showSaveButton = this.state.mode == 'edit' || this.isModified() || this.saveButtonHasBeenShown_;
|
||||
let showSaveButton = this.state.mode == "edit" || this.isModified() || this.saveButtonHasBeenShown_;
|
||||
let saveButtonDisabled = !this.isModified();
|
||||
|
||||
if (showSaveButton) this.saveButtonHasBeenShown_ = true;
|
||||
@@ -502,7 +553,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
paddingLeft: 0,
|
||||
color: theme.color,
|
||||
backgroundColor: theme.backgroundColor,
|
||||
fontWeight: 'bold',
|
||||
fontWeight: "bold",
|
||||
fontSize: theme.fontSize,
|
||||
paddingTop: 10, // Added for iOS (Not needed for Android??)
|
||||
paddingBottom: 10, // Added for iOS (Not needed for Android??)
|
||||
@@ -516,22 +567,30 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
paddingLeft: theme.marginLeft,
|
||||
paddingTop: 10, // Added for iOS (Not needed for Android??)
|
||||
paddingBottom: 10, // Added for iOS (Not needed for Android??)
|
||||
}
|
||||
};
|
||||
|
||||
const dueDate = isTodo && note.todo_due ? new Date(note.todo_due) : null;
|
||||
|
||||
const titleComp = (
|
||||
<View style={titleContainerStyle}>
|
||||
{ isTodo && <Checkbox style={checkboxStyle} checked={!!Number(note.todo_completed)} onChange={(checked) => { this.todoCheckbox_change(checked) }} /> }
|
||||
{isTodo && (
|
||||
<Checkbox
|
||||
style={checkboxStyle}
|
||||
checked={!!Number(note.todo_completed)}
|
||||
onChange={checked => {
|
||||
this.todoCheckbox_change(checked);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<TextInput
|
||||
onContentSizeChange={(event) => this.titleTextInput_contentSizeChange(event)}
|
||||
onContentSizeChange={event => this.titleTextInput_contentSizeChange(event)}
|
||||
autoFocus={isNew}
|
||||
multiline={this.enableMultilineTitle_}
|
||||
underlineColorAndroid="#ffffff00"
|
||||
autoCapitalize="sentences"
|
||||
style={titleTextInputStyle}
|
||||
value={note.title}
|
||||
onChangeText={(text) => this.title_changeText(text)}
|
||||
onChangeText={text => this.title_changeText(text)}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
@@ -560,36 +619,32 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
saveButtonDisabled={saveButtonDisabled}
|
||||
onSaveButtonPress={() => this.saveNoteButton_press()}
|
||||
/>
|
||||
{ titleComp }
|
||||
{ bodyComponent }
|
||||
{ actionButtonComp }
|
||||
{ this.state.showNoteMetadata && <Text style={this.styles().metadata}>{this.state.noteMetadata}</Text> }
|
||||
{titleComp}
|
||||
{bodyComponent}
|
||||
{actionButtonComp}
|
||||
{this.state.showNoteMetadata && <Text style={this.styles().metadata}>{this.state.noteMetadata}</Text>}
|
||||
|
||||
<SelectDateTimeDialog
|
||||
shown={this.state.alarmDialogShown}
|
||||
date={dueDate}
|
||||
onAccept={(date) => this.onAlarmDialogAccept(date) }
|
||||
onReject={() => this.onAlarmDialogReject() }
|
||||
<SelectDateTimeDialog shown={this.state.alarmDialogShown} date={dueDate} onAccept={date => this.onAlarmDialogAccept(date)} onReject={() => this.onAlarmDialogReject()} />
|
||||
|
||||
<DialogBox
|
||||
ref={dialogbox => {
|
||||
this.dialogbox = dialogbox;
|
||||
}}
|
||||
/>
|
||||
|
||||
<DialogBox ref={dialogbox => { this.dialogbox = dialogbox }}/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const NoteScreen = connect(
|
||||
(state) => {
|
||||
return {
|
||||
noteId: state.selectedNoteIds.length ? state.selectedNoteIds[0] : null,
|
||||
folderId: state.selectedFolderId,
|
||||
itemType: state.selectedItemType,
|
||||
folders: state.folders,
|
||||
theme: state.settings.theme,
|
||||
showAdvancedOptions: state.settings.showAdvancedOptions,
|
||||
};
|
||||
}
|
||||
)(NoteScreenComponent)
|
||||
const NoteScreen = connect(state => {
|
||||
return {
|
||||
noteId: state.selectedNoteIds.length ? state.selectedNoteIds[0] : null,
|
||||
folderId: state.selectedFolderId,
|
||||
itemType: state.selectedItemType,
|
||||
folders: state.folders,
|
||||
theme: state.settings.theme,
|
||||
showAdvancedOptions: state.settings.showAdvancedOptions,
|
||||
};
|
||||
})(NoteScreenComponent);
|
||||
|
||||
module.exports = { NoteScreen };
|
||||
module.exports = { NoteScreen };
|
||||
|
||||
Reference in New Issue
Block a user