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

Commit

Permalink
Trash options update + Android export directory
Browse files Browse the repository at this point in the history
  • Loading branch information
moughxyz committed Mar 25, 2019
1 parent f781158 commit d4769af
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/lib/BackupsManager.js
Expand Up @@ -102,7 +102,7 @@ export default class BackupsManager {
}

async _exportAndroid(filename, data) {
let filepath = `${RNFS.DocumentDirectoryPath}/${filename}`;
let filepath = `${RNFS.ExternalDirectoryPath}/${filename}`;
return RNFS.writeFile(filepath, data).then(() => {
return filepath;
})
Expand Down
62 changes: 27 additions & 35 deletions src/screens/SideMenu/NoteSideMenu.js
Expand Up @@ -193,38 +193,35 @@ export default class NoteSideMenu extends AbstractSideMenu {
options.push(option);
}

return options;
}

buildOptionsForTrash() {
if(!this.note.content.trashed) {
return [];
if(this.note.content.trashed) {
options = options.concat([
{
text: "Restore",
textClass: "info",
key: "restore-note",
onSelect: () => {
this.runAction(ItemActionManager.RestoreEvent);
}
},
{
text: "Delete Forever",
textClass: "danger",
key: "delete-forever",
onSelect: () => {
this.runAction(ItemActionManager.DeleteEvent);
}
},
{
text: "Empty Trash",
textClass: "danger",
key: "empty trash",
onSelect: () => {
this.runAction(ItemActionManager.EmptyTrashEvent);
}
},
]);
}

let options = [
{
text: "Restore Note",
key: "restore-note",
onSelect: () => {
this.runAction(ItemActionManager.RestoreEvent);
}
},
{
text: "Delete Forever",
key: "delete-forever",
onSelect: () => {
this.runAction(ItemActionManager.DeleteEvent);
}
},
{
text: "Empty Trash",
key: "empty trash",
onSelect: () => {
this.runAction(ItemActionManager.EmptyTrashEvent);
}
},
]

return options;
}

Expand Down Expand Up @@ -285,7 +282,6 @@ export default class NoteSideMenu extends AbstractSideMenu {
}

let noteOptions = this.buildOptionsForNoteManagement();
let trashOptions = this.buildOptionsForTrash();
let editorOptions = this.buildOptionsForEditors();
let selectedTags = this.handler.getSelectedTags();

Expand All @@ -296,10 +292,6 @@ export default class NoteSideMenu extends AbstractSideMenu {

<SideMenuSection title="Options" options={noteOptions} />

{trashOptions.length > 0 &&
<SideMenuSection title="Trash" options={trashOptions} />
}

<SideMenuSection title="Editors" options={editorOptions} collapsed={true} />

<SideMenuSection title="Tags">
Expand Down
12 changes: 11 additions & 1 deletion src/screens/SideMenu/SideMenuCell.js
Expand Up @@ -68,9 +68,19 @@ export default class SideMenuCell extends ThemedComponent {
}
}

colorForTextClass = (textClass) => {
if(!textClass) {return null;}
return {
"info" : StyleKit.variables.stylekitInfoColor,
"danger" : StyleKit.variables.stylekitDangerColor,
"warning" : StyleKit.variables.stylekitWarningColor,
}[textClass];
}

render() {
let hasIcon = this.props.iconDesc;
let iconSide = (hasIcon && this.props.iconDesc.side) ? this.props.iconDesc.side : (hasIcon ? "left" : null);
let textColor = this.colorForTextClass(this.props.textClass);
return (
<TouchableOpacity style={this.styles.cell} onPress={this.onPress} onLongPress={this.onLongPress}>
<View style={this.styles.cellContent}>
Expand All @@ -87,7 +97,7 @@ export default class SideMenuCell extends ThemedComponent {
<Text style={this.aggregateStyles(this.styles.subtext, this.styles.subtextSelected, this.props.selected)}>{this.props.subtext}</Text>
</View>
}
<Text style={this.aggregateStyles(this.styles.text, this.styles.textSelected, this.props.selected)}>{this.props.text}</Text>
<Text style={[this.aggregateStyles(this.styles.text, this.styles.textSelected, this.props.selected), (textColor ? {color: textColor} : null)]}>{this.props.text}</Text>
</View>


Expand Down
5 changes: 3 additions & 2 deletions src/screens/SideMenu/SideMenuSection.js
Expand Up @@ -8,8 +8,8 @@ import ThemedComponent from "@Components/ThemedComponent";

export default class SideMenuSection extends ThemedComponent {

static BuildOption({text, subtext, key, iconDesc, dimmed, selected, onSelect, onLongPress}) {
return { text, subtext, key, iconDesc, dimmed, selected, onSelect, onLongPress };
static BuildOption({text, subtext, textClass, key, iconDesc, dimmed, selected, onSelect, onLongPress}) {
return { text, subtext, textClass, key, iconDesc, dimmed, selected, onSelect, onLongPress };
}

constructor(props) {
Expand Down Expand Up @@ -46,6 +46,7 @@ export default class SideMenuSection extends ThemedComponent {
{options.map((option) => {
return <SideMenuCell
text={option.text}
textClass={option.textClass}
subtext={option.subtext}
key={option.text + option.subtext + option.key}
iconDesc={option.iconDesc}
Expand Down

0 comments on commit d4769af

Please sign in to comment.