Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #92 from standardnotes/component-view
Browse files Browse the repository at this point in the history
Component view
  • Loading branch information
moughxyz authored Oct 23, 2018
2 parents fdb89d8 + acd1979 commit 482236c
Show file tree
Hide file tree
Showing 15 changed files with 353 additions and 164 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ android {
applicationId "com.standardnotes"
minSdkVersion 21
targetSdkVersion 25
versionCode 2030700
versionName "2.3.7"
versionCode 2030800
versionName "2.3.8"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "x86"
Expand Down
9 changes: 0 additions & 9 deletions ios/StandardNotes/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>
Expand Down
9 changes: 0 additions & 9 deletions ios/StandardNotes/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
Expand Down
2 changes: 1 addition & 1 deletion ios/StandardNotes/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.3.7</string>
<string>2.3.8</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "StandardNotes",
"version": "2.3.7",
"versionIOS": "2.3.7",
"versionAndroid": "2.3.7",
"version": "2.3.8",
"versionIOS": "2.3.8",
"versionAndroid": "2.3.8",
"license": "AGPL-3.0-or-later",
"private": true,
"scripts": {
Expand All @@ -23,7 +23,7 @@
"react-native-vector-icons": "^4.3.0",
"regenerator": "^0.13.2",
"sn-models": "0.1.8",
"standard-file-js": "0.3.14"
"standard-file-js": "0.3.18"
},
"devDependencies": {
"babel-cli": "^6.26.0",
Expand Down
55 changes: 49 additions & 6 deletions src/OptionsState.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default class OptionsState {
async loadSaved() {
return Storage.get().getItem("options").then(function(result){
_.merge(this, _.omit(JSON.parse(result), ["changeObservers"]));
this.rebuildOptions();
this.notifyObservers();
}.bind(this))
}
Expand All @@ -41,7 +42,10 @@ export default class OptionsState {
}

toJSON() {
return {sortBy: this.sortBy, archivedOnly: this.archivedOnly, selectedTags: this.selectedTags};
return _.merge({
sortBy: this.sortBy,
selectedTags: this.selectedTags
}, this.getDisplayOptionValues());
}

addChangeObserver(callback) {
Expand Down Expand Up @@ -77,13 +81,52 @@ export default class OptionsState {
this.notifyObservers(OptionsState.OptionsStateChangeEventSort);
}

setArchivedOnly(archived) {
this.archivedOnly = archived;
this.notifyObservers(OptionsState.OptionsStateChangeEventViews);
}

setSelectedTags(selectedTags) {
this.selectedTags = selectedTags;
this.notifyObservers(OptionsState.OptionsStateChangeEventTags);
}

getDisplayOptionValues() {
if(!this.displayOptions) {
this.rebuildOptions();
}
return this.displayOptions;
}

rebuildOptions() {
this.displayOptions = {
archivedOnly: this.getDisplayOptionValue("archivedOnly"),
hidePreviews: this.getDisplayOptionValue("hidePreviews"),
hideTags: this.getDisplayOptionValue("hideTags"),
hideDates: this.getDisplayOptionValue("hideDates")
}
}

getDisplayOptionValue(key) {
if(key == "archivedOnly") {
return this.archivedOnly;
} else if(key == "hidePreviews") {
return this.hidePreviews;
} else if(key == "hideDates") {
return this.hideDates;
} else if(key == "hideTags") {
return this.hideTags;
}
}

setDisplayOptionKeyValue(key, value) {
if(key == "archivedOnly") {
this.archivedOnly = value;
} else if(key == "hidePreviews") {
this.hidePreviews = value;
} else if(key == "hideDates") {
this.hideDates = value;
} else if(key == "hideTags") {
this.hideTags = value;
}

this.rebuildOptions();

this.notifyObservers(OptionsState.OptionsStateChangeEventViews);
}
}
6 changes: 5 additions & 1 deletion src/Styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ export default class GlobalStyles {
},

noteText: {
flexGrow: 1,
marginTop: 0,
paddingTop: 10,
color: constants.mainTextColor,
Expand All @@ -460,6 +459,11 @@ export default class GlobalStyles {
paddingRight: constants.paddingLeft - 5,
},

noteTextNoPadding: {
paddingLeft: 0,
paddingRight: 0
},

syncBar: {
position: "absolute",
bottom: 0,
Expand Down
35 changes: 27 additions & 8 deletions src/containers/NoteCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class NoteCell extends React.PureComponent {

constructor(props) {
super(props);
this.state = {selected: false};
this.state = {selected: false, options: props.options || {}};
let Padding = 14;

this.styles = StyleSheet.create({
Expand Down Expand Up @@ -79,6 +79,10 @@ export default class NoteCell extends React.PureComponent {
});
}

componentWillReceiveProps(props) {
this.setState({options: props.options || {}});
}

_onPress = () => {
this.setState({selected: true});
this.props.onPressItem(this.props.item);
Expand Down Expand Up @@ -146,6 +150,15 @@ export default class NoteCell extends React.PureComponent {
});
}

getHTMLStyles = () => {
var html = "";
html += "<style>";
html += `html {font-family: sans-serif;}`
html += `html, body, div, p, h1, h2, h3, h4 {color: ${GlobalStyles.constants().mainTextColor};}`;
html += "</style>";
return html;
}

render() {
var note = this.props.item;
return (
Expand All @@ -167,7 +180,7 @@ export default class NoteCell extends React.PureComponent {
</View>
}

{this.props.renderTags && note.tags.length > 0 &&
{this.props.renderTags && !this.state.options.hideTags && note.tags.length > 0 &&
<View style={this.styles.noteTags}>
<Text numberOfLines={1} style={this.aggregateStyles(this.styles.noteTag)}>
{this.props.tagsString}
Expand All @@ -190,15 +203,21 @@ export default class NoteCell extends React.PureComponent {
<Text style={this.aggregateStyles(this.styles.noteTitle, this.styles.noteTitleSelected, this.state.selected)}>{note.title}</Text>
}

{note.safeText().length > 0 &&
{note.content.preview_plain && !this.state.options.hidePreviews &&
<Text style={this.aggregateStyles(this.styles.noteText, this.styles.noteTextSelected, this.state.selected)}>{note.content.preview_plain}</Text>
}

{!note.content.preview_plain && !this.state.options.hidePreviews && note.safeText().length > 0 &&
<Text numberOfLines={2} style={this.aggregateStyles(this.styles.noteText, this.styles.noteTextSelected, this.state.selected)}>{note.text}</Text>
}

<Text
numberOfLines={1}
style={this.aggregateStyles(this.styles.noteDate, this.styles.noteDateSelected, this.state.selected)}>
{this.props.sortType == "client_updated_at" ? "Modified " + note.updatedAtString() : note.createdAtString()}
</Text>
{!this.state.options.hideDates &&
<Text
numberOfLines={1}
style={this.aggregateStyles(this.styles.noteDate, this.styles.noteDateSelected, this.state.selected)}>
{this.props.sortType == "client_updated_at" ? "Modified " + note.updatedAtString() : note.createdAtString()}
</Text>
}

<ActionSheet
ref={o => this.actionSheet = o}
Expand Down
3 changes: 3 additions & 0 deletions src/containers/NoteList.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default class NoteList extends Component {
archived={item.archived}
sortType={this.props.sortType}
renderTags={renderTags}
options={this.props.options}
/>
)
}
Expand All @@ -82,6 +83,7 @@ export default class NoteList extends Component {
} else if(this.props.notes.length == 0) {
placeholderText = "No notes.";
}

return (
<View style={{backgroundColor: GlobalStyles.constants().mainBackgroundColor}}>

Expand All @@ -104,6 +106,7 @@ export default class NoteList extends Component {
/>
}
data={this.props.notes}
options={this.props.options}
renderItem={this._renderItem}
ListHeaderComponent={this.renderHeader}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Account.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ export default class Account extends Abstract {
}
} else if(action == "friend") {
let title = "Standard Notes";
var message = "Check out Standard Notes. It's a simple and private notes app. Thought you'd find it useful.";
var message = "Check out Standard Notes, a free, open-source, and completely encrypted notes app.";
let url = "https://standardnotes.org";
// Android ignores url. iOS ignores title.
if(App.isAndroid) {
Expand Down
Loading

0 comments on commit 482236c

Please sign in to comment.