From e5d4c649ad1600fecc883a7bb4af198ca22edef0 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Mon, 31 Jul 2017 18:19:58 +0000 Subject: [PATCH] Added save icon, fixed search ordering bug and fixed html rendering bug --- ReactNativeClient/lib/components/SaveIcon.png | Bin 0 -> 344 bytes .../lib/components/note-body-viewer.js | 7 ++- .../lib/components/screen-header.js | 48 +++++++++++------- ReactNativeClient/lib/models/note.js | 2 +- 4 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 ReactNativeClient/lib/components/SaveIcon.png diff --git a/ReactNativeClient/lib/components/SaveIcon.png b/ReactNativeClient/lib/components/SaveIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..f6c9ada749baa2c820f7ce85ac672ff4f4975467 GIT binary patch literal 344 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H3?#oinD`S&NtU=qlmzFem6RtIr7}3C&mCr)gZI8bu+mvwtx*TgFZ>k7=0g{odXXSwxDo$1%FY{uTdOB>Gp z>pI~4|Hj0t%VgfgbDd)rW7_uB|GNGAISc~qs8FH7qQQcJkwZYip@D&siG@R8L*R$7 zYrGa8+V}E0?6@b9++#TZti`O7|J(=fGq*vMz||r%8ln?_ozvjaaI@RZpI|FmwPk

@7Ziba&p|J?qZxD*Unc-!%!vgI9kGCotr!R`e|8wcZW%C4;A{pUXO@geCxt CJb~u` literal 0 HcmV?d00001 diff --git a/ReactNativeClient/lib/components/note-body-viewer.js b/ReactNativeClient/lib/components/note-body-viewer.js index 2c095095c..9a37af10c 100644 --- a/ReactNativeClient/lib/components/note-body-viewer.js +++ b/ReactNativeClient/lib/components/note-body-viewer.js @@ -134,7 +134,12 @@ class NoteBodyViewer extends Component { return '[Image: ' + htmlentities(r.title) + '(' + htmlentities(r.mime) + ')]'; } - let html = body ? '' + marked(body, { gfm: true, breaks: true, renderer: renderer }) : ''; + let html = body ? '' + marked(body, { + gfm: true, + breaks: true, + renderer: renderer, + sanitize: true, + }) : ''; let elementId = 1; while (html.indexOf('°°JOP°') >= 0) { diff --git a/ReactNativeClient/lib/components/screen-header.js b/ReactNativeClient/lib/components/screen-header.js index 9ca3b276f..b50776b8d 100644 --- a/ReactNativeClient/lib/components/screen-header.js +++ b/ReactNativeClient/lib/components/screen-header.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import { connect } from 'react-redux' -import { View, Text, Button, StyleSheet, TouchableOpacity, Picker } from 'react-native'; +import { View, Text, Button, StyleSheet, TouchableOpacity, Picker, Image } from 'react-native'; import Icon from 'react-native-vector-icons/Ionicons'; import { Log } from 'lib/log.js'; import { Menu, MenuOptions, MenuOption, MenuTrigger } from 'react-native-popup-menu'; @@ -11,18 +11,21 @@ import { FileApiDriverOneDrive } from 'lib/file-api-driver-onedrive.js'; import { reg } from 'lib/registry.js' import { globalStyle } from 'lib/components/global-style.js'; +// Rather than applying a padding to the whole bar, it is applied to each +// individual component (button, picker, etc.) so that the touchable areas +// are widder and to give more room to the picker component which has a larger +// default height. +const PADDING_V = 10; + let styleObject = { container: { flexDirection: 'row', - paddingTop: 10, - paddingBottom: 10, backgroundColor: globalStyle.raisedBackgroundColor, alignItems: 'center', shadowColor: '#000000', elevation: 5, }, folderPicker: { - height: 30, flex:1, color: globalStyle.raisedHighlightedColor, // Note: cannot set backgroundStyle as that would remove the arrow in the component @@ -39,33 +42,41 @@ let styleObject = { paddingLeft: globalStyle.marginLeft, paddingRight: 5, marginRight: 2, + paddingTop: PADDING_V, + paddingBottom: PADDING_V, }, iconButton: { flex: 1, backgroundColor: globalStyle.raisedBackgroundColor, paddingLeft: 15, paddingRight: 15, + paddingTop: PADDING_V, + paddingBottom: PADDING_V, }, saveButton: { - flex: 1, + flex: 0, flexDirection: 'row', alignItems: 'center', - paddingLeft: 15, - paddingRight: 15, - marginRight: 10, + padding: 10, borderWidth: 1, borderColor: globalStyle.raisedHighlightedColor, borderRadius: 4, + marginRight: 8, }, saveButtonText: { textAlignVertical: 'center', color: globalStyle.raisedHighlightedColor, fontWeight: 'bold', }, - saveButtonIcon: { + savedButtonIcon: { fontSize: 20, color: globalStyle.raisedHighlightedColor, - marginRight: 5, + width: 18, + height: 18, + }, + saveButtonIcon: { + width: 18, + height: 18, }, contextMenuTrigger: { fontSize: 25, @@ -181,13 +192,12 @@ class ScreenHeaderComponent extends Component { function saveButton(styles, onPress, disabled, show) { if (!show) return null; - const title = disabled ? _('Saved') : _('Save'); + const icon = disabled ? : ; return ( - + - { disabled && } - {title} + { icon } ); @@ -245,9 +255,11 @@ class ScreenHeaderComponent extends Component { items.push(); } return ( - { if (p.onValueChange) p.onValueChange(itemValue, itemIndex); }}> - { items } - + + { if (p.onValueChange) p.onValueChange(itemValue, itemIndex); }}> + { items } + + ); } else { let title = 'title' in this.props && this.props.title !== null ? this.props.title : ''; @@ -265,7 +277,7 @@ class ScreenHeaderComponent extends Component { { titleComp } { searchButton(styles, () => this.searchButton_press()) }

this.menu_select(value)} style={styles.contextMenu}> - + diff --git a/ReactNativeClient/lib/models/note.js b/ReactNativeClient/lib/models/note.js index 919f1d662..6e4eb2f57 100644 --- a/ReactNativeClient/lib/models/note.js +++ b/ReactNativeClient/lib/models/note.js @@ -114,7 +114,7 @@ class Note extends BaseItem { // is used to sort already loaded notes. if (!options) options = {}; - if (!options.order) options.order = { by: 'updated_time', dir: 'DESC' }; + if (!options.order) options.order = [{ by: 'updated_time', dir: 'DESC' }]; if (!options.conditions) options.conditions = []; if (!options.conditionsParams) options.conditionsParams = []; if (!options.fields) options.fields = this.previewFields();