Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: multi-select export notes

ammarahm-ed68d4a5e56d92
diff --git a/apps/mobile/app/components/list-items/selection-wrapper/selection.js b/apps/mobile/app/components/list-items/selection-wrapper/selection.js
index 2640045d3..1ca57d3be 100644
--- a/apps/mobile/app/components/list-items/selection-wrapper/selection.js
+++ b/apps/mobile/app/components/list-items/selection-wrapper/selection.js
@@ -18,20 +18,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { useEffect, useState } from "react";
-import { TouchableOpacity, View } from "react-native";
+import { View } from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { useSelectionStore } from "../../../stores/use-selection-store";
import { useThemeStore } from "../../../stores/use-theme-store";
import { SIZE } from "../../../utils/size";
-export const SelectionIcon = ({ setActionStrip, item, compactMode }) => {
+export const SelectionIcon = ({ setActionStrip, item }) => {
const colors = useThemeStore((state) => state.colors);
const selectionMode = useSelectionStore((state) => state.selectionMode);
const selectedItemsList = useSelectionStore(
(state) => state.selectedItemsList
);
- const setSelectedItem = useSelectionStore((state) => state.setSelectedItem);
const [selected, setSelected] = useState(false);
useEffect(() => {
@@ -60,43 +59,25 @@ export const SelectionIcon = ({ setActionStrip, item, compactMode }) => {
selected
]);
- const onPress = () => {
- setSelectedItem(item);
- };
-
- return selectionMode ? (
+ return selectionMode && selected ? (
<View
style={{
- display: "flex",
- opacity: 1,
- width: "10%",
- height: compactMode ? 40 : 70,
+ width: 40,
+ height: 40,
justifyContent: "center",
alignItems: "center",
- backgroundColor: colors.bg,
- borderRadius: 5,
marginRight: 10,
borderWidth: 1,
- borderColor: selected ? colors.accent : colors.border
+ borderRadius: 100,
+ borderColor: colors.border
}}
+ pointerEvents="none"
>
- <TouchableOpacity
- activeOpacity={1}
- onPress={onPress}
- style={{
- justifyContent: "center",
- alignItems: "center",
- height: 70
- }}
- >
- {selected && (
- <Icon
- size={SIZE.xl}
- color={selected ? colors.accent : colors.icon}
- name="check"
- />
- )}
- </TouchableOpacity>
+ <Icon
+ size={SIZE.xl}
+ color={selected ? colors.accent : colors.icon}
+ name="check"
+ />
</View>
) : null;
};
diff --git a/apps/mobile/app/components/selection-header/index.js b/apps/mobile/app/components/selection-header/index.js
index eba97aec0..789e1b51a 100644
--- a/apps/mobile/app/components/selection-header/index.js
+++ b/apps/mobile/app/components/selection-header/index.js
@@ -32,6 +32,7 @@ import { tabBarRef } from "../../utils/global-refs";
import { SIZE } from "../../utils/size";
import { sleep } from "../../utils/time";
import { presentDialog } from "../dialog/functions";
+import ExportNotesSheet from "../sheets/export-notes";
import { IconButton } from "../ui/icon-button";
import Heading from "../ui/typography/heading";
@@ -225,19 +226,32 @@ export const SelectionHeader = React.memo(() => {
{screen === "Trash" ||
screen === "Notebooks" ||
screen === "Notebook" ? null : (
- <IconButton
- onPress={async () => {
- //setSelectionMode(false);
- await sleep(100);
- eSendEvent(eOpenMoveNoteDialog);
- }}
- customStyle={{
- marginLeft: 10
- }}
- color={colors.pri}
- name="plus"
- size={SIZE.xl}
- />
+ <>
+ <IconButton
+ onPress={async () => {
+ //setSelectionMode(false);
+ await sleep(100);
+ eSendEvent(eOpenMoveNoteDialog);
+ }}
+ customStyle={{
+ marginLeft: 10
+ }}
+ color={colors.pri}
+ name="plus"
+ size={SIZE.xl}
+ />
+ <IconButton
+ onPress={async () => {
+ ExportNotesSheet.present(selectedItemsList);
+ }}
+ customStyle={{
+ marginLeft: 10
+ }}
+ color={colors.pri}
+ name="export"
+ size={SIZE.xl}
+ />
+ </>
)}
{screen === "TopicNotes" ? (
diff --git a/apps/mobile/app/components/sheets/export-notes/index.js b/apps/mobile/app/components/sheets/export-notes/index.js
index eb9abeb57..e6899d502 100644
--- a/apps/mobile/app/components/sheets/export-notes/index.js
+++ b/apps/mobile/app/components/sheets/export-notes/index.js
@@ -115,7 +115,11 @@ const ExportNotesSheet = ({ notes }) => {
>
<DialogHeader
icon="export"
- title={notes.length > 1 ? "Export Notes" : "Export Note"}
+ title={
+ notes.length > 1
+ ? `Export ${notes.length} Notes`
+ : "Export Note"
+ }
paragraph={`All exports are saved in ${
Platform.OS === "android"
? "the selected"
@@ -221,7 +225,9 @@ const ExportNotesSheet = ({ notes }) => {
}}
color={colors.icon}
>
- {notes.length > 1 ? "Notes exported" : "Note exported"}
+ {notes.length > 1
+ ? `${notes.length} Notes exported`
+ : "Note exported"}
</Heading>
<Paragraph
style={{
@@ -306,9 +312,9 @@ const ExportNotesSheet = ({ notes }) => {
);
};
-ExportNotesSheet.present = (note, allNotes) => {
+ExportNotesSheet.present = (notes, allNotes) => {
presentSheet({
- component: <ExportNotesSheet notes={allNotes ? db.notes.all : [note]} />
+ component: <ExportNotesSheet notes={allNotes ? db.notes.all : notes} />
});
};
diff --git a/apps/mobile/app/hooks/use-actions.js b/apps/mobile/app/hooks/use-actions.js
index bb780dee3..6ff84e53b 100644
--- a/apps/mobile/app/hooks/use-actions.js
+++ b/apps/mobile/app/hooks/use-actions.js
@@ -538,7 +538,7 @@ export const useActions = ({ close = () => null, item }) => {
async function exportNote() {
close();
await sleep(300);
- ExportNotesSheet.present(item);
+ ExportNotesSheet.present([item]);
}
async function toggleLocalOnly() {
diff --git a/apps/mobile/app/services/exporter.js b/apps/mobile/app/services/exporter.js
index 4cf0ad267..b89107b02 100644
--- a/apps/mobile/app/services/exporter.js
+++ b/apps/mobile/app/services/exporter.js
@@ -534,7 +534,7 @@ async function bulkExport(notes, type, callback) {
callback("zipping");
await sleep(1);
const zipped = await zipAsync(results);
- const fileName = `nn-export-all-${type}-${Date.now()}.zip`;
+ const fileName = `nn-export-${notes.length}-${type}-${Date.now()}.zip`;
callback("saving to disk");
await sleep(1);
try {