From 6cf85ca802b754fa7a53285e63a7ae511633b992 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Sun, 13 Jan 2019 15:39:32 -0600 Subject: [PATCH] Highlight selected note on tablet --- src/screens/Notes/NoteCell.js | 27 +++++++++++---------------- src/screens/Notes/NoteList.js | 1 + src/screens/Notes/Notes.js | 5 +++++ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/screens/Notes/NoteCell.js b/src/screens/Notes/NoteCell.js index 8d132302..cb518de8 100644 --- a/src/screens/Notes/NoteCell.js +++ b/src/screens/Notes/NoteCell.js @@ -32,14 +32,6 @@ export default class NoteCell extends ThemedPureComponent { this.setState({selected: false}); }; - noteCellStyle = () => { - if(this.state.selected) { - return [styles.noteCell, styles.noteCellSelected]; - } else { - return styles.noteCell; - } - } - aggregateStyles(base, addition, condition) { if(condition) { return [base, addition]; @@ -150,7 +142,7 @@ export default class NoteCell extends ThemedPureComponent { flagElement = (flag) => { let bgColor = flag.color; let textColor = StyleKit.variables.stylekitInfoContrastColor; - if(this.state.selected) { + if(this.state.selected || this.props.highlighted) { bgColor = StyleKit.variables.stylekitInfoContrastColor; textColor = flag.color } @@ -180,9 +172,12 @@ export default class NoteCell extends ThemedPureComponent { var note = this.props.item; let showPreview = !this.state.options.hidePreviews && !note.content.protected && !note.content.hidePreview; let flags = this.getFlags(note); + + let highlight = this.state.selected || this.props.highlighted; + return ( - + {note.deleted && Deleting... @@ -205,26 +200,26 @@ export default class NoteCell extends ThemedPureComponent { {"Password Required."} - + {"Please sign in to restore your decryption keys and notes."} } {note.safeTitle().length > 0 && - + {note.title} } {(note.content.preview_plain != null && showPreview) && - + {note.content.preview_plain} } {(!note.content.preview_plain && showPreview && note.safeText().length > 0) && - + {note.text} } @@ -232,14 +227,14 @@ export default class NoteCell extends ThemedPureComponent { {!this.state.options.hideDates && + style={this.aggregateStyles(this.styles.noteDate, this.styles.noteDateSelected, highlight)}> {this.props.sortType == "client_updated_at" ? "Modified " + note.updatedAtString() : note.createdAtString()} } {this.props.renderTags && !this.state.options.hideTags && note.tags.length > 0 && - + {this.props.tagsString} diff --git a/src/screens/Notes/NoteList.js b/src/screens/Notes/NoteList.js index b8dacb39..4be9f0f0 100644 --- a/src/screens/Notes/NoteList.js +++ b/src/screens/Notes/NoteList.js @@ -50,6 +50,7 @@ export default class NoteList extends ThemedComponent { sortType={this.props.sortType} renderTags={renderTags} options={this.props.options} + highlighted={item.uuid == this.props.selectedNoteId} pinned={item.pinned /* extraData */} deleted={item.deleted /* extraData */} diff --git a/src/screens/Notes/Notes.js b/src/screens/Notes/Notes.js index 7b28fa7e..e81a2469 100644 --- a/src/screens/Notes/Notes.js +++ b/src/screens/Notes/Notes.js @@ -265,6 +265,10 @@ export default class Notes extends Abstract { } else { this.presentComposer(note); } + + if(ApplicationState.get().isTablet) { + this.setState({selectedNoteId: note && note.uuid}); + } }); } @@ -317,6 +321,7 @@ export default class Notes extends Abstract { loading={this.state.loading} selectedTags={this.state.tags} options={this.options.displayOptions} + selectedNoteId={this.state.selectedNoteId} /> }