2021-09-15 12:23:37 +05:00
|
|
|
import Clipboard from "@react-native-clipboard/clipboard";
|
2021-07-19 14:32:29 +05:00
|
|
|
import htmlToText from 'html-to-text';
|
2021-09-15 12:23:37 +05:00
|
|
|
import React, { useEffect, useState } from 'react';
|
2020-01-09 20:14:51 +05:00
|
|
|
import {
|
2020-12-31 12:01:14 +05:00
|
|
|
Dimensions,
|
|
|
|
|
Keyboard,
|
2021-07-19 14:32:29 +05:00
|
|
|
Platform,
|
2020-12-31 12:01:14 +05:00
|
|
|
ScrollView,
|
|
|
|
|
TouchableOpacity,
|
2021-07-19 13:25:32 +05:00
|
|
|
View
|
2020-01-09 20:14:51 +05:00
|
|
|
} from 'react-native';
|
2021-09-15 12:23:37 +05:00
|
|
|
import { FlatList } from 'react-native-gesture-handler';
|
2020-03-14 13:37:07 +05:00
|
|
|
import Share from 'react-native-share';
|
2020-02-11 20:33:36 +05:00
|
|
|
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
2021-09-15 12:23:37 +05:00
|
|
|
import { notesnook } from '../../../e2e/test.ids';
|
|
|
|
|
import { useTracked } from '../../provider';
|
|
|
|
|
import { Actions } from '../../provider/Actions';
|
2020-10-31 16:32:21 +05:00
|
|
|
import {
|
2021-06-14 08:37:38 +05:00
|
|
|
useMenuStore,
|
|
|
|
|
useSelectionStore,
|
2021-09-15 12:23:37 +05:00
|
|
|
useSettingStore, useUserStore
|
2021-06-14 08:37:38 +05:00
|
|
|
} from '../../provider/stores';
|
2021-09-15 12:23:37 +05:00
|
|
|
import { DDS } from '../../services/DeviceDetection';
|
2021-07-19 09:20:55 +05:00
|
|
|
import {
|
|
|
|
|
eSendEvent,
|
|
|
|
|
eSubscribeEvent,
|
|
|
|
|
eUnSubscribeEvent,
|
|
|
|
|
openVault,
|
2021-07-19 13:25:32 +05:00
|
|
|
ToastEvent
|
2021-07-19 09:20:55 +05:00
|
|
|
} from '../../services/EventManager';
|
2021-02-16 16:11:10 +05:00
|
|
|
import Navigation from '../../services/Navigation';
|
2021-07-19 09:20:55 +05:00
|
|
|
import Notifications from '../../services/Notifications';
|
2020-12-20 23:01:35 +05:00
|
|
|
import Sync from '../../services/Sync';
|
2021-09-15 12:23:37 +05:00
|
|
|
import { editing } from '../../utils';
|
2020-10-13 17:02:14 +05:00
|
|
|
import {
|
|
|
|
|
ACCENT,
|
|
|
|
|
COLOR_SCHEME,
|
|
|
|
|
COLOR_SCHEME_DARK,
|
|
|
|
|
COLOR_SCHEME_LIGHT,
|
2021-07-19 13:25:32 +05:00
|
|
|
setColorScheme
|
2020-10-31 16:32:21 +05:00
|
|
|
} from '../../utils/Colors';
|
2021-10-02 10:26:29 +05:00
|
|
|
import { db } from '../../utils/database';
|
2021-07-07 12:54:48 +05:00
|
|
|
import {
|
2021-10-01 12:03:57 +05:00
|
|
|
eOpenAttachmentsDialog,
|
2021-11-04 13:05:51 +05:00
|
|
|
eOpenLoginDialog,
|
2021-07-07 12:54:48 +05:00
|
|
|
eOpenMoveNoteDialog,
|
|
|
|
|
eOpenPublishNoteDialog,
|
2021-10-05 11:47:00 +05:00
|
|
|
eOpenTagsDialog,
|
|
|
|
|
refreshNotesPage
|
2021-07-07 12:54:48 +05:00
|
|
|
} from '../../utils/Events';
|
2021-09-15 12:23:37 +05:00
|
|
|
import { deleteItems, openLinkInBrowser } from '../../utils/functions';
|
|
|
|
|
import { MMKV } from '../../utils/mmkv';
|
|
|
|
|
import { SIZE } from '../../utils/SizeUtils';
|
|
|
|
|
import { sleep, timeConverter } from '../../utils/TimeUtils';
|
|
|
|
|
import { Button } from '../Button';
|
|
|
|
|
import { presentDialog } from '../Dialog/functions';
|
|
|
|
|
import { PressableButton } from '../PressableButton';
|
2020-11-09 20:26:20 +05:00
|
|
|
import Heading from '../Typography/Heading';
|
|
|
|
|
import Paragraph from '../Typography/Paragraph';
|
2021-09-15 12:23:37 +05:00
|
|
|
import { ActionSheetColorsSection } from './ActionSheetColorsSection';
|
|
|
|
|
import { ActionSheetTagsSection } from './ActionSheetTagsSection';
|
2020-01-09 20:14:51 +05:00
|
|
|
const w = Dimensions.get('window').width;
|
2020-10-31 16:32:21 +05:00
|
|
|
|
2020-01-09 20:14:51 +05:00
|
|
|
export const ActionSheetComponent = ({
|
2020-04-18 13:49:24 +05:00
|
|
|
close = () => {},
|
2020-01-11 23:05:39 +05:00
|
|
|
item,
|
2020-01-10 18:44:41 +05:00
|
|
|
hasColors = false,
|
|
|
|
|
hasTags = false,
|
|
|
|
|
rowItems = [],
|
2021-07-19 13:25:32 +05:00
|
|
|
getRef
|
2020-01-09 20:14:51 +05:00
|
|
|
}) => {
|
2020-01-17 21:26:01 +05:00
|
|
|
const [state, dispatch] = useTracked();
|
2021-06-14 08:37:38 +05:00
|
|
|
const {colors} = state;
|
2021-06-05 21:10:20 +05:00
|
|
|
const clearSelection = useSelectionStore(state => state.clearSelection);
|
|
|
|
|
const setSelectedItem = useSelectionStore(state => state.setSelectedItem);
|
|
|
|
|
const setMenuPins = useMenuStore(state => state.setMenuPins);
|
2021-06-14 08:37:38 +05:00
|
|
|
const [isPinnedToMenu, setIsPinnedToMenu] = useState(
|
2021-07-19 13:25:32 +05:00
|
|
|
db.settings.isPinned(item.id)
|
2021-06-14 08:37:38 +05:00
|
|
|
);
|
2020-12-31 13:42:53 +05:00
|
|
|
const [note, setNote] = useState(item);
|
2021-06-16 11:39:52 +05:00
|
|
|
const user = useUserStore(state => state.user);
|
|
|
|
|
const lastSynced = useUserStore(state => state.lastSynced);
|
2021-07-19 09:20:55 +05:00
|
|
|
const [notifPinned, setNotifPinned] = useState(null);
|
2021-07-25 00:54:50 +05:00
|
|
|
const dimensions = useSettingStore(state => state.dimensions);
|
2021-09-15 12:23:37 +05:00
|
|
|
const settings = useSettingStore(state => state.settings);
|
|
|
|
|
const alias =
|
|
|
|
|
note.type === 'tag'
|
|
|
|
|
? db.tags.alias(note.id)
|
|
|
|
|
: note.type === 'color'
|
|
|
|
|
? db.colors.alias(note.id)
|
|
|
|
|
: note.title;
|
2021-06-05 01:35:58 +05:00
|
|
|
|
2021-06-16 11:39:52 +05:00
|
|
|
const refreshing = false;
|
|
|
|
|
const isPublished = db.monographs.isPublished(note.id);
|
2021-06-14 08:37:38 +05:00
|
|
|
const noteInTopic =
|
2021-02-27 12:23:36 +05:00
|
|
|
editing.actionAfterFirstSave.type === 'topic' &&
|
2021-06-14 08:37:38 +05:00
|
|
|
db.notebooks
|
|
|
|
|
.notebook(editing.actionAfterFirstSave.notebook)
|
|
|
|
|
.topics.topic(editing.actionAfterFirstSave.id)
|
|
|
|
|
.has(item.id);
|
2020-01-22 02:49:29 +05:00
|
|
|
|
2020-01-11 23:05:39 +05:00
|
|
|
useEffect(() => {
|
2021-06-14 08:37:38 +05:00
|
|
|
if (item.id === null) return;
|
2021-07-19 09:20:55 +05:00
|
|
|
checkNotifPinned();
|
|
|
|
|
setNote({...item});
|
|
|
|
|
if (item.type !== 'note') {
|
|
|
|
|
setIsPinnedToMenu(db.settings.isPinned(note.id));
|
|
|
|
|
}
|
2020-01-11 23:05:39 +05:00
|
|
|
}, [item]);
|
|
|
|
|
|
2021-07-19 09:20:55 +05:00
|
|
|
function checkNotifPinned() {
|
|
|
|
|
let pinned = Notifications.getPinnedNotes();
|
|
|
|
|
console.log(pinned);
|
|
|
|
|
if (!pinned) {
|
|
|
|
|
setNotifPinned(null);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-09-15 12:23:37 +05:00
|
|
|
|
2021-07-19 09:20:55 +05:00
|
|
|
let index = pinned.findIndex(notif => notif.tag === item.id);
|
|
|
|
|
if (index !== -1) {
|
|
|
|
|
setNotifPinned(pinned[index]);
|
|
|
|
|
} else {
|
|
|
|
|
setNotifPinned(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-19 13:25:32 +05:00
|
|
|
const onUpdate = async type => {
|
2021-07-19 09:20:55 +05:00
|
|
|
console.log('update', type);
|
|
|
|
|
if (type === 'unpin') {
|
2021-07-19 13:25:32 +05:00
|
|
|
await sleep(1000);
|
|
|
|
|
|
|
|
|
|
await Notifications.get();
|
2021-07-19 09:20:55 +05:00
|
|
|
checkNotifPinned();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
eSubscribeEvent('onUpdate', onUpdate);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
eUnSubscribeEvent('onUpdate', onUpdate);
|
|
|
|
|
};
|
2021-07-19 13:25:32 +05:00
|
|
|
}, [item]);
|
2021-07-19 09:20:55 +05:00
|
|
|
|
2021-06-14 08:37:38 +05:00
|
|
|
function changeColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
|
|
|
|
|
let newColors = setColorScheme(colors, accent);
|
|
|
|
|
dispatch({type: Actions.THEME, colors: newColors});
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-20 10:33:36 +05:00
|
|
|
const localRefresh = (type, nodispatch = false) => {
|
2020-02-06 13:08:35 +05:00
|
|
|
if (!note || !note.id) return;
|
2021-06-14 08:37:38 +05:00
|
|
|
let _item;
|
2020-02-02 23:50:55 +05:00
|
|
|
|
2020-01-10 18:44:41 +05:00
|
|
|
switch (type) {
|
|
|
|
|
case 'note': {
|
2021-06-14 08:37:38 +05:00
|
|
|
_item = db.notes.note(note.id)?.data;
|
2020-01-10 18:44:41 +05:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 'notebook': {
|
2021-06-14 08:37:38 +05:00
|
|
|
_item = db.notebooks.notebook(note.id)?.data;
|
2020-01-10 18:44:41 +05:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 'topic': {
|
2021-06-14 08:37:38 +05:00
|
|
|
_item = db.notebooks.notebook(note.notebookId).topics.topic(note.title);
|
2020-01-10 18:44:41 +05:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-14 08:37:38 +05:00
|
|
|
if (!_item || !_item.id) return;
|
2020-01-20 15:32:32 +05:00
|
|
|
|
2020-01-20 10:33:36 +05:00
|
|
|
if (!nodispatch) {
|
2021-06-05 21:10:20 +05:00
|
|
|
Navigation.setRoutesToUpdate([
|
2021-06-14 08:37:38 +05:00
|
|
|
Navigation.routeNames.NotesPage,
|
|
|
|
|
Navigation.routeNames.Favorites,
|
|
|
|
|
Navigation.routeNames.Notes,
|
|
|
|
|
Navigation.routeNames.Notebooks,
|
|
|
|
|
Navigation.routeNames.Notebook,
|
|
|
|
|
Navigation.routeNames.Tags,
|
2021-07-19 13:25:32 +05:00
|
|
|
Navigation.routeNames.Trash
|
2021-06-14 08:37:38 +05:00
|
|
|
]);
|
2020-01-20 10:33:36 +05:00
|
|
|
}
|
2021-06-05 21:10:20 +05:00
|
|
|
|
2021-06-14 08:37:38 +05:00
|
|
|
setNote({..._item});
|
2020-01-10 18:44:41 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const rowItemsData = [
|
|
|
|
|
{
|
2021-07-10 00:22:51 +05:00
|
|
|
name: 'Dark Mode',
|
|
|
|
|
title: 'Dark mode',
|
|
|
|
|
icon: 'theme-light-dark',
|
|
|
|
|
func: () => {
|
|
|
|
|
if (!colors.night) {
|
|
|
|
|
MMKV.setStringAsync('theme', JSON.stringify({night: true}));
|
|
|
|
|
changeColorScheme(COLOR_SCHEME_DARK);
|
|
|
|
|
} else {
|
|
|
|
|
MMKV.setStringAsync('theme', JSON.stringify({night: false}));
|
|
|
|
|
changeColorScheme(COLOR_SCHEME_LIGHT);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
switch: true,
|
|
|
|
|
on: colors.night ? true : false,
|
|
|
|
|
close: false,
|
|
|
|
|
nopremium: true,
|
2021-07-19 13:25:32 +05:00
|
|
|
id: notesnook.ids.dialogs.actionsheet.night
|
2021-07-10 00:22:51 +05:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Add to notebook',
|
|
|
|
|
title: 'Add to notebook',
|
2020-02-11 20:33:36 +05:00
|
|
|
icon: 'book-outline',
|
2020-01-10 18:44:41 +05:00
|
|
|
func: () => {
|
2021-02-27 12:23:36 +05:00
|
|
|
close();
|
2021-06-05 21:10:20 +05:00
|
|
|
clearSelection();
|
2021-06-15 14:48:51 +05:00
|
|
|
setSelectedItem(note);
|
2020-09-14 17:10:02 +05:00
|
|
|
setTimeout(() => {
|
2020-12-15 14:14:19 +05:00
|
|
|
eSendEvent(eOpenMoveNoteDialog, note);
|
2021-02-27 12:23:36 +05:00
|
|
|
}, 300);
|
2021-07-19 13:25:32 +05:00
|
|
|
}
|
2020-01-10 18:44:41 +05:00
|
|
|
},
|
|
|
|
|
{
|
2021-07-10 00:22:51 +05:00
|
|
|
name: 'Pin',
|
2021-07-12 10:55:25 +05:00
|
|
|
title: note.pinned ? 'Unpin' : 'Pin to top',
|
2021-07-10 00:22:51 +05:00
|
|
|
icon: note.pinned ? 'pin-off-outline' : 'pin-outline',
|
2020-12-01 16:36:19 +05:00
|
|
|
func: async () => {
|
2021-07-10 00:22:51 +05:00
|
|
|
if (!note.id) return;
|
|
|
|
|
close();
|
2021-09-13 09:55:56 +05:00
|
|
|
let type = note.type;
|
|
|
|
|
if (db[`${type}s`].pinned.length === 3 && !note.pinned) {
|
|
|
|
|
ToastEvent.show({
|
|
|
|
|
heading: `Cannot pin more than 3 ${type}s`,
|
2021-09-15 12:23:37 +05:00
|
|
|
type: 'error'
|
2021-09-13 09:55:56 +05:00
|
|
|
});
|
|
|
|
|
return;
|
2020-01-29 17:38:50 +05:00
|
|
|
}
|
2021-09-13 09:55:56 +05:00
|
|
|
await db[`${type}s`][type](note.id).pin();
|
2021-07-10 00:22:51 +05:00
|
|
|
localRefresh(item.type);
|
2020-01-10 18:44:41 +05:00
|
|
|
},
|
2021-07-10 00:22:51 +05:00
|
|
|
close: false,
|
|
|
|
|
check: true,
|
|
|
|
|
on: note.pinned,
|
|
|
|
|
nopremium: true,
|
2021-07-19 13:25:32 +05:00
|
|
|
id: notesnook.ids.dialogs.actionsheet.pin
|
2020-01-10 18:44:41 +05:00
|
|
|
},
|
|
|
|
|
{
|
2021-07-10 00:22:51 +05:00
|
|
|
name: 'Favorite',
|
2021-07-12 10:55:25 +05:00
|
|
|
title: !note.favorite ? 'Favorite' : 'Unfavorite',
|
2021-07-10 00:22:51 +05:00
|
|
|
icon: note.favorite ? 'star-off' : 'star-outline',
|
|
|
|
|
func: async () => {
|
|
|
|
|
if (!note.id) return;
|
|
|
|
|
close();
|
|
|
|
|
if (note.type === 'note') {
|
|
|
|
|
await db.notes.note(note.id).favorite();
|
|
|
|
|
} else {
|
|
|
|
|
await db.notebooks.notebook(note.id).favorite();
|
|
|
|
|
}
|
|
|
|
|
Navigation.setRoutesToUpdate([
|
|
|
|
|
Navigation.routeNames.NotesPage,
|
|
|
|
|
Navigation.routeNames.Favorites,
|
2021-07-19 13:25:32 +05:00
|
|
|
Navigation.routeNames.Notes
|
2021-07-10 00:22:51 +05:00
|
|
|
]);
|
|
|
|
|
localRefresh(item.type, true);
|
2020-01-10 18:44:41 +05:00
|
|
|
},
|
2021-07-10 00:22:51 +05:00
|
|
|
close: false,
|
|
|
|
|
check: true,
|
|
|
|
|
on: note.favorite,
|
|
|
|
|
nopremium: true,
|
|
|
|
|
id: notesnook.ids.dialogs.actionsheet.favorite,
|
2021-07-19 13:25:32 +05:00
|
|
|
color: 'orange'
|
2020-01-10 18:44:41 +05:00
|
|
|
},
|
2021-07-19 09:20:55 +05:00
|
|
|
{
|
|
|
|
|
name: 'PinToNotif',
|
|
|
|
|
title:
|
|
|
|
|
notifPinned !== null
|
|
|
|
|
? 'Unpin from Notifications'
|
|
|
|
|
: 'Pin to Notifications',
|
|
|
|
|
icon: 'bell',
|
|
|
|
|
on: notifPinned !== null,
|
|
|
|
|
func: async () => {
|
2021-07-19 13:25:32 +05:00
|
|
|
if (Platform.OS === 'ios') return;
|
2021-07-19 09:20:55 +05:00
|
|
|
if (notifPinned !== null) {
|
|
|
|
|
Notifications.remove(note.id, notifPinned.identifier);
|
2021-07-19 12:58:05 +05:00
|
|
|
await sleep(1000);
|
2021-07-19 09:20:55 +05:00
|
|
|
await Notifications.get();
|
|
|
|
|
checkNotifPinned();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (note.locked) return;
|
|
|
|
|
let text = await db.notes.note(note.id).content();
|
2021-07-19 14:32:29 +05:00
|
|
|
text = htmlToText.convert(text, {
|
|
|
|
|
selectors: [{selector: 'img', format: 'skip'}]
|
|
|
|
|
});
|
2021-07-19 09:20:55 +05:00
|
|
|
Notifications.present({
|
|
|
|
|
title: note.title,
|
|
|
|
|
message: note.headline,
|
|
|
|
|
subtitle: note.headline,
|
|
|
|
|
bigText: text,
|
|
|
|
|
ongoing: true,
|
|
|
|
|
actions: ['UNPIN'],
|
2021-07-19 13:25:32 +05:00
|
|
|
tag: note.id
|
2021-07-19 09:20:55 +05:00
|
|
|
});
|
2021-07-19 12:58:05 +05:00
|
|
|
await sleep(1000);
|
2021-07-20 09:53:04 +05:00
|
|
|
await Notifications.get();
|
2021-07-19 09:20:55 +05:00
|
|
|
checkNotifPinned();
|
2021-07-19 13:25:32 +05:00
|
|
|
}
|
2021-07-19 09:20:55 +05:00
|
|
|
},
|
2021-07-10 00:22:51 +05:00
|
|
|
|
2021-06-14 08:37:38 +05:00
|
|
|
{
|
|
|
|
|
name: 'Edit Notebook',
|
2021-07-10 00:22:51 +05:00
|
|
|
title: 'Edit notebook',
|
2021-06-14 08:37:38 +05:00
|
|
|
icon: 'square-edit-outline',
|
|
|
|
|
func: () => {
|
|
|
|
|
close('notebook');
|
2021-07-19 13:25:32 +05:00
|
|
|
}
|
2021-06-14 08:37:38 +05:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Edit Topic',
|
2021-07-10 00:22:51 +05:00
|
|
|
title: 'Edit topic',
|
2021-06-14 08:37:38 +05:00
|
|
|
icon: 'square-edit-outline',
|
|
|
|
|
func: () => {
|
|
|
|
|
close('topic');
|
2021-07-19 13:25:32 +05:00
|
|
|
}
|
2021-06-14 08:37:38 +05:00
|
|
|
},
|
2020-02-03 12:18:45 +05:00
|
|
|
{
|
2020-09-14 13:14:07 +05:00
|
|
|
name: 'Copy',
|
2021-07-10 00:22:51 +05:00
|
|
|
title: 'Copy',
|
2020-09-14 13:14:07 +05:00
|
|
|
icon: 'content-copy',
|
|
|
|
|
func: async () => {
|
2020-12-07 11:26:30 +05:00
|
|
|
if (note.locked) {
|
2020-12-10 15:26:02 +05:00
|
|
|
openVault({
|
|
|
|
|
copyNote: true,
|
|
|
|
|
novault: true,
|
|
|
|
|
locked: true,
|
|
|
|
|
item: note,
|
2021-02-20 15:03:02 +05:00
|
|
|
title: 'Copy note',
|
2021-07-19 13:25:32 +05:00
|
|
|
description: 'Unlock note to copy to clipboard.'
|
2020-12-10 15:26:02 +05:00
|
|
|
});
|
2020-12-07 11:26:30 +05:00
|
|
|
} else {
|
2020-12-10 15:26:02 +05:00
|
|
|
let text = await db.notes.note(note.id).content();
|
2021-07-19 14:32:29 +05:00
|
|
|
text = htmlToText.convert(text, {
|
|
|
|
|
selectors: [{selector: 'img', format: 'skip'}]
|
|
|
|
|
});
|
2020-12-10 15:26:02 +05:00
|
|
|
text = `${note.title}\n \n ${text}`;
|
|
|
|
|
Clipboard.setString(text);
|
2021-02-20 15:03:02 +05:00
|
|
|
ToastEvent.show({
|
|
|
|
|
heading: 'Note copied to clipboard',
|
|
|
|
|
type: 'success',
|
2021-07-19 13:25:32 +05:00
|
|
|
context: 'local'
|
2021-02-20 15:03:02 +05:00
|
|
|
});
|
2020-12-07 11:26:30 +05:00
|
|
|
}
|
2021-07-19 13:25:32 +05:00
|
|
|
}
|
2020-02-03 12:18:45 +05:00
|
|
|
},
|
2020-01-10 18:44:41 +05:00
|
|
|
{
|
|
|
|
|
name: 'Restore',
|
2021-07-19 09:20:55 +05:00
|
|
|
title: 'Restore ' + note.itemType,
|
2020-02-11 20:33:36 +05:00
|
|
|
icon: 'delete-restore',
|
2020-02-07 04:25:55 +05:00
|
|
|
func: async () => {
|
2021-02-27 12:23:36 +05:00
|
|
|
close();
|
2020-12-16 11:35:40 +05:00
|
|
|
await db.trash.restore(note.id);
|
2021-02-16 16:11:10 +05:00
|
|
|
Navigation.setRoutesToUpdate([
|
|
|
|
|
Navigation.routeNames.Tags,
|
|
|
|
|
Navigation.routeNames.Notes,
|
|
|
|
|
Navigation.routeNames.Notebooks,
|
|
|
|
|
Navigation.routeNames.NotesPage,
|
|
|
|
|
Navigation.routeNames.Favorites,
|
2021-07-19 13:25:32 +05:00
|
|
|
Navigation.routeNames.Trash
|
2021-02-20 15:03:02 +05:00
|
|
|
]);
|
2021-01-01 15:40:12 +05:00
|
|
|
type = note.type === 'trash' ? note.itemType : note.type;
|
2021-02-20 15:03:02 +05:00
|
|
|
|
|
|
|
|
ToastEvent.show({
|
|
|
|
|
heading:
|
|
|
|
|
type === 'note'
|
|
|
|
|
? 'Note restored from trash'
|
|
|
|
|
: 'Notebook restored from trash',
|
2021-07-19 13:25:32 +05:00
|
|
|
type: 'success'
|
2021-02-20 15:03:02 +05:00
|
|
|
});
|
2021-07-19 13:25:32 +05:00
|
|
|
}
|
2020-01-10 18:44:41 +05:00
|
|
|
},
|
2021-07-10 00:22:51 +05:00
|
|
|
|
2021-06-14 08:37:38 +05:00
|
|
|
{
|
|
|
|
|
name: 'Publish',
|
2021-07-10 00:22:51 +05:00
|
|
|
title: 'Publish',
|
2021-06-15 17:45:56 +05:00
|
|
|
icon: 'cloud-upload-outline',
|
2021-06-14 08:37:38 +05:00
|
|
|
func: async () => {
|
2021-06-15 17:45:56 +05:00
|
|
|
if (!user) {
|
|
|
|
|
ToastEvent.show({
|
|
|
|
|
heading: 'Login required',
|
|
|
|
|
message: 'Login to publish note',
|
|
|
|
|
context: 'local',
|
|
|
|
|
func: () => {
|
|
|
|
|
eSendEvent(eOpenLoginDialog);
|
|
|
|
|
},
|
2021-07-19 13:25:32 +05:00
|
|
|
actionText: 'Login'
|
2021-06-15 17:45:56 +05:00
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!user.isEmailConfirmed) {
|
|
|
|
|
ToastEvent.show({
|
|
|
|
|
heading: 'Email not verified',
|
|
|
|
|
message: 'Please verify your email first.',
|
2021-07-19 13:25:32 +05:00
|
|
|
context: 'local'
|
2021-06-15 17:45:56 +05:00
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-06-16 08:31:10 +05:00
|
|
|
if (note.locked) {
|
|
|
|
|
ToastEvent.show({
|
2021-06-16 11:39:52 +05:00
|
|
|
heading: 'Locked notes cannot be published',
|
2021-06-16 08:31:10 +05:00
|
|
|
type: 'error',
|
2021-07-19 13:25:32 +05:00
|
|
|
context: 'local'
|
2021-06-16 08:31:10 +05:00
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-06-14 08:37:38 +05:00
|
|
|
close();
|
|
|
|
|
await sleep(300);
|
2021-06-14 10:01:44 +05:00
|
|
|
eSendEvent(eOpenPublishNoteDialog, note);
|
2021-07-19 13:25:32 +05:00
|
|
|
}
|
2021-06-14 08:37:38 +05:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Vault',
|
|
|
|
|
title: note.locked ? 'Remove from vault' : 'Add to vault',
|
|
|
|
|
icon: note.locked ? 'shield-off-outline' : 'shield-outline',
|
|
|
|
|
func: async () => {
|
|
|
|
|
if (!note.id) return;
|
|
|
|
|
if (note.locked) {
|
|
|
|
|
close('unlock');
|
|
|
|
|
} else {
|
|
|
|
|
db.vault
|
|
|
|
|
.add(note.id)
|
|
|
|
|
.then(r => {
|
|
|
|
|
let n = db.notes.note(note.id).data;
|
|
|
|
|
if (n.locked) {
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
Navigation.setRoutesToUpdate([
|
|
|
|
|
Navigation.routeNames.NotesPage,
|
|
|
|
|
Navigation.routeNames.Favorites,
|
2021-07-19 13:25:32 +05:00
|
|
|
Navigation.routeNames.Notes
|
2021-06-14 08:37:38 +05:00
|
|
|
]);
|
|
|
|
|
localRefresh(note.type);
|
|
|
|
|
})
|
|
|
|
|
.catch(async e => {
|
|
|
|
|
switch (e.message) {
|
|
|
|
|
case db.vault.ERRORS.noVault:
|
|
|
|
|
close('novault');
|
|
|
|
|
break;
|
|
|
|
|
case db.vault.ERRORS.vaultLocked:
|
|
|
|
|
close('locked');
|
|
|
|
|
break;
|
|
|
|
|
case db.vault.ERRORS.wrongPassword:
|
|
|
|
|
close();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-07-19 13:25:32 +05:00
|
|
|
on: note.locked
|
2021-06-14 08:37:38 +05:00
|
|
|
},
|
2021-07-10 00:22:51 +05:00
|
|
|
|
2020-01-10 18:44:41 +05:00
|
|
|
{
|
2021-07-10 00:22:51 +05:00
|
|
|
name: 'Add Shortcut',
|
|
|
|
|
title: isPinnedToMenu ? 'Remove Shortcut' : 'Add Shortcut',
|
2021-02-20 15:03:02 +05:00
|
|
|
icon: isPinnedToMenu ? 'link-variant-remove' : 'link-variant',
|
2020-11-25 18:49:21 +05:00
|
|
|
func: async () => {
|
2021-02-27 12:23:36 +05:00
|
|
|
close();
|
2020-11-25 18:49:21 +05:00
|
|
|
try {
|
|
|
|
|
if (isPinnedToMenu) {
|
|
|
|
|
await db.settings.unpin(note.id);
|
|
|
|
|
} else {
|
2020-11-25 18:57:46 +05:00
|
|
|
if (item.type === 'topic') {
|
2020-11-25 18:49:21 +05:00
|
|
|
await db.settings.pin(note.type, {
|
2020-11-26 11:32:30 +05:00
|
|
|
id: note.id,
|
2021-07-19 13:25:32 +05:00
|
|
|
notebookId: note.notebookId
|
2020-11-25 18:49:21 +05:00
|
|
|
});
|
2020-11-25 18:57:46 +05:00
|
|
|
} else {
|
|
|
|
|
await db.settings.pin(note.type, {id: note.id});
|
2020-11-25 18:49:21 +05:00
|
|
|
}
|
|
|
|
|
}
|
2020-11-26 11:32:30 +05:00
|
|
|
setIsPinnedToMenu(db.settings.isPinned(note.id));
|
2021-06-05 21:10:20 +05:00
|
|
|
setMenuPins();
|
2020-11-25 18:49:21 +05:00
|
|
|
} catch (e) {}
|
|
|
|
|
},
|
|
|
|
|
close: false,
|
|
|
|
|
check: true,
|
|
|
|
|
on: isPinnedToMenu,
|
2021-01-08 12:52:55 +05:00
|
|
|
nopremium: true,
|
2021-07-19 13:25:32 +05:00
|
|
|
id: notesnook.ids.dialogs.actionsheet.pinMenu
|
2020-11-25 18:49:21 +05:00
|
|
|
},
|
2021-07-12 10:55:25 +05:00
|
|
|
{
|
2021-09-13 12:57:34 +05:00
|
|
|
name: 'Rename Tag',
|
|
|
|
|
title: 'Rename tag',
|
2021-07-12 10:55:25 +05:00
|
|
|
icon: 'square-edit-outline',
|
|
|
|
|
func: async () => {
|
|
|
|
|
close();
|
|
|
|
|
await sleep(300);
|
|
|
|
|
presentDialog({
|
2021-09-13 12:57:34 +05:00
|
|
|
title: 'Rename tag',
|
|
|
|
|
paragraph: 'Change the title of the tag ' + alias,
|
2021-07-12 10:55:25 +05:00
|
|
|
positivePress: async value => {
|
2021-11-16 11:30:06 +05:00
|
|
|
if (!value || value === '' || value.trimStart().length == 0) return;
|
|
|
|
|
await db.tags.rename(note.id, value.replace(/[\s+#|&;$%@"'=<>()+,]/g, "").toLowerCase());
|
2021-07-12 10:55:25 +05:00
|
|
|
Navigation.setRoutesToUpdate([
|
|
|
|
|
Navigation.routeNames.Notes,
|
|
|
|
|
Navigation.routeNames.NotesPage,
|
2021-07-19 13:25:32 +05:00
|
|
|
Navigation.routeNames.Tags
|
2021-07-12 10:55:25 +05:00
|
|
|
]);
|
|
|
|
|
},
|
|
|
|
|
input: true,
|
2021-09-13 12:57:34 +05:00
|
|
|
defaultValue: alias,
|
|
|
|
|
inputPlaceholder: 'Enter title of tag',
|
2021-07-19 13:25:32 +05:00
|
|
|
positiveText: 'Save'
|
2021-07-12 10:55:25 +05:00
|
|
|
});
|
2021-07-19 13:25:32 +05:00
|
|
|
}
|
2021-07-12 10:55:25 +05:00
|
|
|
},
|
2021-07-10 00:22:51 +05:00
|
|
|
{
|
|
|
|
|
name: 'Share',
|
|
|
|
|
title: 'Share',
|
|
|
|
|
icon: 'share-variant',
|
|
|
|
|
func: async () => {
|
|
|
|
|
if (note.locked) {
|
|
|
|
|
close();
|
|
|
|
|
openVault({
|
|
|
|
|
item: item,
|
|
|
|
|
novault: true,
|
|
|
|
|
locked: true,
|
|
|
|
|
share: true,
|
|
|
|
|
title: 'Share note',
|
2021-07-19 13:25:32 +05:00
|
|
|
description: 'Unlock note to share it.'
|
2021-07-10 00:22:51 +05:00
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
let text = await db.notes.note(note.id).export('txt');
|
|
|
|
|
let m = `${note.title}\n \n ${text}`;
|
|
|
|
|
Share.open({
|
|
|
|
|
title: 'Share note to',
|
|
|
|
|
failOnCancel: false,
|
2021-07-19 13:25:32 +05:00
|
|
|
message: m
|
2021-07-10 00:22:51 +05:00
|
|
|
});
|
|
|
|
|
}
|
2021-07-19 13:25:32 +05:00
|
|
|
}
|
2021-07-10 00:22:51 +05:00
|
|
|
},
|
2021-10-01 12:03:57 +05:00
|
|
|
{
|
|
|
|
|
name: 'Attachments',
|
|
|
|
|
title: 'Attachments',
|
|
|
|
|
icon: 'attachment',
|
|
|
|
|
func: async () => {
|
|
|
|
|
close();
|
|
|
|
|
await sleep(300);
|
|
|
|
|
eSendEvent(eOpenAttachmentsDialog,note);
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-07-10 00:22:51 +05:00
|
|
|
{
|
|
|
|
|
name: 'Export',
|
|
|
|
|
title: 'Export',
|
|
|
|
|
icon: 'export',
|
|
|
|
|
func: () => {
|
|
|
|
|
close('export');
|
2021-07-19 13:25:32 +05:00
|
|
|
}
|
2021-07-10 00:22:51 +05:00
|
|
|
},
|
2021-06-14 08:37:38 +05:00
|
|
|
{
|
|
|
|
|
name: 'RemoveTopic',
|
|
|
|
|
title: 'Remove from topic',
|
|
|
|
|
hidden: !noteInTopic,
|
2021-06-14 10:01:44 +05:00
|
|
|
icon: 'minus-circle-outline',
|
2021-06-14 08:37:38 +05:00
|
|
|
func: async () => {
|
|
|
|
|
await db.notebooks
|
|
|
|
|
.notebook(editing.actionAfterFirstSave.notebook)
|
|
|
|
|
.topics.topic(editing.actionAfterFirstSave.id)
|
|
|
|
|
.delete(note.id);
|
|
|
|
|
Navigation.setRoutesToUpdate([
|
|
|
|
|
Navigation.routeNames.Notebooks,
|
|
|
|
|
Navigation.routeNames.Notes,
|
|
|
|
|
Navigation.routeNames.NotesPage,
|
2021-07-19 13:25:32 +05:00
|
|
|
Navigation.routeNames.Notebook
|
2021-06-14 08:37:38 +05:00
|
|
|
]);
|
|
|
|
|
setNote(db.notes.note(note.id).data);
|
|
|
|
|
close();
|
2021-07-19 13:25:32 +05:00
|
|
|
}
|
2021-06-14 08:37:38 +05:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Delete',
|
|
|
|
|
title:
|
|
|
|
|
note.type !== 'notebook' && note.type !== 'note'
|
|
|
|
|
? 'Delete ' + item.type
|
|
|
|
|
: 'Move to trash',
|
|
|
|
|
icon: 'delete-outline',
|
|
|
|
|
type: 'error',
|
|
|
|
|
func: async () => {
|
|
|
|
|
close();
|
2021-07-12 10:55:25 +05:00
|
|
|
if (note.type === 'tag') {
|
|
|
|
|
await sleep(300);
|
|
|
|
|
presentDialog({
|
|
|
|
|
title: 'Delete tag',
|
|
|
|
|
paragraph: 'This tag will be removed from all notes.',
|
|
|
|
|
positivePress: async value => {
|
|
|
|
|
await db.tags.remove(note.id);
|
|
|
|
|
Navigation.setRoutesToUpdate([
|
|
|
|
|
Navigation.routeNames.Notes,
|
|
|
|
|
Navigation.routeNames.NotesPage,
|
2021-07-19 13:25:32 +05:00
|
|
|
Navigation.routeNames.Tags
|
2021-07-12 10:55:25 +05:00
|
|
|
]);
|
|
|
|
|
},
|
|
|
|
|
positiveText: 'Delete',
|
2021-07-19 13:25:32 +05:00
|
|
|
positiveType: 'errorShade'
|
2021-07-12 10:55:25 +05:00
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-06-14 08:37:38 +05:00
|
|
|
if (note.locked) {
|
|
|
|
|
await sleep(300);
|
|
|
|
|
openVault({
|
|
|
|
|
deleteNote: true,
|
|
|
|
|
novault: true,
|
|
|
|
|
locked: true,
|
|
|
|
|
item: note,
|
|
|
|
|
title: 'Delete note',
|
2021-07-19 13:25:32 +05:00
|
|
|
description: 'Unlock note to delete it.'
|
2021-06-14 08:37:38 +05:00
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
close();
|
|
|
|
|
await deleteItems(note);
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
}
|
2021-07-19 13:25:32 +05:00
|
|
|
}
|
2021-06-14 08:37:38 +05:00
|
|
|
},
|
2021-07-10 00:22:51 +05:00
|
|
|
{
|
|
|
|
|
name: 'PermDelete',
|
2021-07-19 09:20:55 +05:00
|
|
|
title: 'Delete ' + note.itemType,
|
2021-07-10 00:22:51 +05:00
|
|
|
icon: 'delete',
|
|
|
|
|
func: async () => {
|
|
|
|
|
close();
|
|
|
|
|
await sleep(300);
|
|
|
|
|
presentDialog({
|
|
|
|
|
title: `Permanent delete`,
|
|
|
|
|
paragraph: `Are you sure you want to delete this ${note.itemType} permanantly from trash?`,
|
|
|
|
|
positiveText: 'Delete',
|
|
|
|
|
negativeText: 'Cancel',
|
|
|
|
|
positivePress: async () => {
|
|
|
|
|
await db.trash.delete(note.id);
|
2021-09-13 09:55:56 +05:00
|
|
|
Navigation.setRoutesToUpdate([Navigation.routeNames.Trash]);
|
2021-07-10 00:22:51 +05:00
|
|
|
useSelectionStore.getState().setSelectionMode(false);
|
|
|
|
|
ToastEvent.show({
|
|
|
|
|
heading: 'Permanantly deleted items',
|
|
|
|
|
type: 'success',
|
2021-07-19 13:25:32 +05:00
|
|
|
context: 'local'
|
2021-07-10 00:22:51 +05:00
|
|
|
});
|
|
|
|
|
},
|
2021-09-13 09:55:56 +05:00
|
|
|
positiveType: 'errorShade'
|
2021-07-10 00:22:51 +05:00
|
|
|
});
|
2021-07-19 13:25:32 +05:00
|
|
|
}
|
|
|
|
|
}
|
2020-01-10 18:44:41 +05:00
|
|
|
];
|
|
|
|
|
|
2021-07-25 00:54:50 +05:00
|
|
|
let width = dimensions.width > 600 ? 600 : 500;
|
|
|
|
|
let columnItemWidth = DDS.isTab ? (width - 24) / 5 : (w - 24) / 5;
|
|
|
|
|
|
2021-06-14 10:01:44 +05:00
|
|
|
const _renderRowItem = rowItem => (
|
2021-07-12 00:55:37 +05:00
|
|
|
<View
|
2021-06-14 10:01:44 +05:00
|
|
|
onPress={rowItem.func}
|
|
|
|
|
key={rowItem.name}
|
|
|
|
|
testID={'icon-' + rowItem.name}
|
|
|
|
|
style={{
|
|
|
|
|
alignItems: 'center',
|
2021-07-12 10:55:25 +05:00
|
|
|
width: columnItemWidth,
|
2021-07-19 13:25:32 +05:00
|
|
|
marginBottom: 10
|
2021-06-14 10:01:44 +05:00
|
|
|
}}>
|
2021-07-12 00:55:37 +05:00
|
|
|
<PressableButton
|
|
|
|
|
onPress={rowItem.func}
|
2021-07-17 20:38:41 +05:00
|
|
|
type={rowItem.on ? 'shade' : 'grayBg'}
|
2021-07-12 00:55:37 +05:00
|
|
|
customStyle={{
|
2021-07-12 10:55:25 +05:00
|
|
|
height: columnItemWidth - 12,
|
|
|
|
|
width: columnItemWidth - 12,
|
2021-07-10 00:22:51 +05:00
|
|
|
borderRadius: 5,
|
2021-06-14 10:01:44 +05:00
|
|
|
justifyContent: 'center',
|
2020-01-16 19:53:16 +05:00
|
|
|
alignItems: 'center',
|
2021-06-14 10:01:44 +05:00
|
|
|
textAlign: 'center',
|
|
|
|
|
textAlignVertical: 'center',
|
2021-07-19 13:25:32 +05:00
|
|
|
marginBottom: DDS.isTab ? 7 : 3.5
|
2021-07-08 10:18:18 +05:00
|
|
|
}}>
|
|
|
|
|
<Icon
|
|
|
|
|
name={rowItem.icon}
|
|
|
|
|
size={DDS.isTab ? SIZE.xl : SIZE.lg}
|
2021-07-12 10:55:25 +05:00
|
|
|
color={
|
|
|
|
|
rowItem.on
|
2021-07-17 20:38:41 +05:00
|
|
|
? colors.accent
|
2021-07-12 10:55:25 +05:00
|
|
|
: rowItem.name === 'Delete' || rowItem.name === 'PermDelete'
|
|
|
|
|
? colors.errorText
|
|
|
|
|
: colors.icon
|
|
|
|
|
}
|
2021-07-08 10:18:18 +05:00
|
|
|
/>
|
2021-07-12 00:55:37 +05:00
|
|
|
</PressableButton>
|
2021-07-08 10:18:18 +05:00
|
|
|
|
2021-10-01 12:03:57 +05:00
|
|
|
<Paragraph size={SIZE.sm - 1.5} style={{textAlign: 'center'}}>
|
2021-07-19 09:20:55 +05:00
|
|
|
{rowItem.title}
|
|
|
|
|
</Paragraph>
|
2021-07-12 00:55:37 +05:00
|
|
|
</View>
|
2021-06-14 10:01:44 +05:00
|
|
|
);
|
2020-01-16 19:53:16 +05:00
|
|
|
|
2020-12-19 14:26:44 +05:00
|
|
|
const onScrollEnd = () => {
|
2020-12-29 17:19:32 +05:00
|
|
|
getRef().current?.handleChildScrollEnd();
|
2020-12-19 14:26:44 +05:00
|
|
|
};
|
|
|
|
|
|
2020-01-09 20:14:51 +05:00
|
|
|
return (
|
2020-12-19 13:15:34 +05:00
|
|
|
<ScrollView
|
2020-12-19 14:26:44 +05:00
|
|
|
nestedScrollEnabled
|
|
|
|
|
onScrollEndDrag={onScrollEnd}
|
|
|
|
|
onScrollAnimationEnd={onScrollEnd}
|
|
|
|
|
onMomentumScrollEnd={onScrollEnd}
|
2020-12-31 12:16:28 +05:00
|
|
|
keyboardShouldPersistTaps="always"
|
|
|
|
|
keyboardDismissMode="none"
|
2020-01-20 10:33:36 +05:00
|
|
|
onLayout={() => {
|
2020-02-02 16:18:52 +05:00
|
|
|
if (!item.dateDeleted) {
|
|
|
|
|
localRefresh(item.type, true);
|
|
|
|
|
}
|
2020-01-20 10:33:36 +05:00
|
|
|
}}
|
2020-01-10 18:44:41 +05:00
|
|
|
style={{
|
|
|
|
|
backgroundColor: colors.bg,
|
2020-01-24 18:48:33 +05:00
|
|
|
paddingHorizontal: 0,
|
2020-12-19 14:26:44 +05:00
|
|
|
borderBottomRightRadius: DDS.isLargeTablet() ? 10 : 1,
|
2021-07-19 13:25:32 +05:00
|
|
|
borderBottomLeftRadius: DDS.isLargeTablet() ? 10 : 1
|
2020-01-10 18:44:41 +05:00
|
|
|
}}>
|
2020-12-15 14:14:19 +05:00
|
|
|
<TouchableOpacity
|
|
|
|
|
style={{
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
2021-07-19 13:25:32 +05:00
|
|
|
position: 'absolute'
|
2020-12-15 14:14:19 +05:00
|
|
|
}}
|
|
|
|
|
onPress={() => {
|
|
|
|
|
Keyboard.dismiss();
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2021-07-07 12:54:48 +05:00
|
|
|
|
2020-12-31 13:44:34 +05:00
|
|
|
{!note || !note.id ? (
|
2020-12-31 12:04:00 +05:00
|
|
|
<Paragraph style={{marginVertical: 10, alignSelf: 'center'}}>
|
2020-11-09 20:26:20 +05:00
|
|
|
Start writing to save your note.
|
|
|
|
|
</Paragraph>
|
2020-02-03 12:18:45 +05:00
|
|
|
) : (
|
2020-04-18 13:49:24 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
paddingHorizontal: 12,
|
|
|
|
|
alignItems: 'center',
|
2021-04-22 11:49:55 +05:00
|
|
|
marginTop: 5,
|
2021-07-19 13:25:32 +05:00
|
|
|
zIndex: 10
|
2020-04-18 13:49:24 +05:00
|
|
|
}}>
|
2021-04-22 11:49:55 +05:00
|
|
|
<Heading
|
2020-04-18 13:49:24 +05:00
|
|
|
style={{
|
2021-04-29 10:45:46 +05:00
|
|
|
maxWidth: '90%',
|
2021-07-19 13:25:32 +05:00
|
|
|
textAlign: 'center'
|
2021-04-22 11:49:55 +05:00
|
|
|
}}
|
|
|
|
|
size={SIZE.md}>
|
2021-06-14 10:01:44 +05:00
|
|
|
{note.type === 'tag' ? '#' : null}
|
2021-09-13 12:57:34 +05:00
|
|
|
{alias}
|
2021-04-22 11:49:55 +05:00
|
|
|
</Heading>
|
|
|
|
|
|
|
|
|
|
{note.headline || note.description ? (
|
|
|
|
|
<Paragraph
|
|
|
|
|
numberOfLines={2}
|
|
|
|
|
style={{
|
2021-04-29 10:45:46 +05:00
|
|
|
width: '90%',
|
2021-04-22 11:49:55 +05:00
|
|
|
textAlign: 'center',
|
2021-07-19 13:25:32 +05:00
|
|
|
maxWidth: '90%'
|
2021-04-22 11:49:55 +05:00
|
|
|
}}>
|
|
|
|
|
{note.type === 'notebook' && note.description
|
|
|
|
|
? note.description
|
|
|
|
|
: null}
|
|
|
|
|
{note.type === 'note' && note.headline
|
|
|
|
|
? note.headline[item.headline.length - 1] === '\n'
|
|
|
|
|
? note.headline.slice(0, note.headline.length - 1)
|
|
|
|
|
: note.headline
|
|
|
|
|
: null}
|
|
|
|
|
</Paragraph>
|
|
|
|
|
) : null}
|
2020-04-18 13:49:24 +05:00
|
|
|
|
2020-11-20 01:23:05 +05:00
|
|
|
<Paragraph
|
|
|
|
|
color={colors.icon}
|
|
|
|
|
size={SIZE.xs}
|
2020-04-18 13:49:24 +05:00
|
|
|
style={{
|
|
|
|
|
textAlignVertical: 'center',
|
2021-07-19 13:25:32 +05:00
|
|
|
marginTop: 2.5
|
2020-04-18 13:49:24 +05:00
|
|
|
}}>
|
2021-06-14 14:41:57 +05:00
|
|
|
{note.type === 'note' || (note.type === 'tag' && note.dateEdited)
|
2020-04-18 13:49:24 +05:00
|
|
|
? 'Last edited on ' + timeConverter(note.dateEdited)
|
|
|
|
|
: null}
|
2021-06-14 14:41:57 +05:00
|
|
|
{note.type !== 'note' &&
|
|
|
|
|
note.type !== 'tag' &&
|
|
|
|
|
note.dateCreated &&
|
|
|
|
|
!note.dateDeleted
|
|
|
|
|
? ' Created on ' + timeConverter(note.dateCreated)
|
2020-04-18 13:49:24 +05:00
|
|
|
: null}
|
|
|
|
|
{note.dateDeleted
|
|
|
|
|
? 'Deleted on ' + timeConverter(note.dateDeleted)
|
|
|
|
|
: null}
|
2020-11-20 01:23:05 +05:00
|
|
|
</Paragraph>
|
2020-04-18 13:49:24 +05:00
|
|
|
|
2021-07-07 12:54:48 +05:00
|
|
|
{hasTags && note ? (
|
|
|
|
|
<ActionSheetTagsSection
|
|
|
|
|
close={close}
|
|
|
|
|
item={note}
|
|
|
|
|
localRefresh={localRefresh}
|
|
|
|
|
/>
|
|
|
|
|
) : null}
|
|
|
|
|
|
2021-06-16 11:39:52 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
flexDirection: 'row',
|
2021-07-07 12:54:48 +05:00
|
|
|
marginTop: 5,
|
2021-07-10 00:22:51 +05:00
|
|
|
width: '90%',
|
|
|
|
|
maxWidth: '90%',
|
|
|
|
|
flexWrap: 'wrap',
|
2021-07-19 13:25:32 +05:00
|
|
|
justifyContent: 'center'
|
2021-06-16 11:39:52 +05:00
|
|
|
}}>
|
2021-07-10 00:22:51 +05:00
|
|
|
{note.type === 'notebook' &&
|
|
|
|
|
note &&
|
|
|
|
|
note.topics &&
|
|
|
|
|
note.topics.length > 0
|
|
|
|
|
? note.topics
|
|
|
|
|
.sort((a, b) => a.dateEdited - b.dateEdited)
|
|
|
|
|
.slice(0, 6)
|
|
|
|
|
.map(topic => (
|
|
|
|
|
<Button
|
|
|
|
|
key={topic.id}
|
|
|
|
|
title={topic.title}
|
2021-07-17 20:38:41 +05:00
|
|
|
type="gray"
|
2021-07-10 00:22:51 +05:00
|
|
|
height={30}
|
|
|
|
|
onPress={() => {
|
|
|
|
|
close();
|
|
|
|
|
let routeName = 'NotesPage';
|
|
|
|
|
let params = {...topic, menu: false, get: 'topics'};
|
|
|
|
|
let headerState = {
|
|
|
|
|
heading: topic.title,
|
|
|
|
|
id: topic.id,
|
2021-07-19 13:25:32 +05:00
|
|
|
type: topic.type
|
2021-10-05 11:47:00 +05:00
|
|
|
};
|
|
|
|
|
eSendEvent(refreshNotesPage, params);
|
2021-07-10 00:22:51 +05:00
|
|
|
Navigation.navigate(routeName, params, headerState);
|
|
|
|
|
}}
|
2021-11-12 11:01:02 +05:00
|
|
|
icon="bookmark-outline"
|
2021-07-10 00:22:51 +05:00
|
|
|
fontSize={SIZE.sm - 1}
|
|
|
|
|
style={{
|
|
|
|
|
marginRight: 5,
|
|
|
|
|
paddingHorizontal: 0,
|
2021-07-17 20:38:41 +05:00
|
|
|
paddingHorizontal: 6,
|
2021-07-19 13:25:32 +05:00
|
|
|
marginTop: 5
|
2021-07-10 00:22:51 +05:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
))
|
|
|
|
|
: null}
|
|
|
|
|
|
2021-09-13 08:53:16 +05:00
|
|
|
{note.type === 'note' && isPublished ? (
|
2021-07-07 12:54:48 +05:00
|
|
|
<Button
|
|
|
|
|
title="Published"
|
|
|
|
|
type="shade"
|
|
|
|
|
height={30}
|
|
|
|
|
fontSize={SIZE.sm - 1}
|
2020-12-10 15:26:02 +05:00
|
|
|
style={{
|
2021-07-07 12:54:48 +05:00
|
|
|
margin: 1,
|
2021-06-16 11:39:52 +05:00
|
|
|
marginRight: 5,
|
2021-07-07 12:54:48 +05:00
|
|
|
paddingHorizontal: 0,
|
|
|
|
|
borderRadius: 100,
|
2021-07-19 13:25:32 +05:00
|
|
|
paddingHorizontal: 12
|
2021-07-07 12:54:48 +05:00
|
|
|
}}
|
|
|
|
|
/>
|
2021-09-13 08:53:16 +05:00
|
|
|
) : null}
|
2020-09-08 14:36:25 +05:00
|
|
|
|
2021-07-07 12:54:48 +05:00
|
|
|
{note.type === 'note' && (
|
|
|
|
|
<Button
|
|
|
|
|
onPress={async () => {
|
|
|
|
|
close();
|
|
|
|
|
await sleep(300);
|
|
|
|
|
eSendEvent(eOpenTagsDialog, note);
|
|
|
|
|
}}
|
|
|
|
|
title="Add tags"
|
|
|
|
|
type="accent"
|
|
|
|
|
icon="plus"
|
|
|
|
|
iconPosition="right"
|
|
|
|
|
height={30}
|
|
|
|
|
fontSize={SIZE.sm}
|
|
|
|
|
style={{
|
|
|
|
|
margin: 1,
|
|
|
|
|
marginRight: 5,
|
|
|
|
|
paddingHorizontal: 0,
|
|
|
|
|
borderRadius: 100,
|
2021-07-19 13:25:32 +05:00
|
|
|
paddingHorizontal: 12
|
2021-07-07 12:54:48 +05:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</View>
|
2020-04-18 13:49:24 +05:00
|
|
|
</View>
|
|
|
|
|
)}
|
2020-01-29 18:20:54 +05:00
|
|
|
|
2020-11-14 13:53:19 +05:00
|
|
|
{hasColors && note.id ? (
|
|
|
|
|
<ActionSheetColorsSection close={close} item={note} />
|
|
|
|
|
) : null}
|
2020-11-02 20:45:11 +05:00
|
|
|
|
2021-07-10 00:22:51 +05:00
|
|
|
{note.id || note.dateCreated ? (
|
|
|
|
|
<FlatList
|
|
|
|
|
data={rowItemsData.filter(
|
2021-07-19 13:25:32 +05:00
|
|
|
i => rowItems.indexOf(i.name) > -1 && !i.hidden
|
2021-07-10 00:22:51 +05:00
|
|
|
)}
|
2021-07-10 14:23:30 +05:00
|
|
|
keyExtractor={item => item.title}
|
2021-07-10 00:22:51 +05:00
|
|
|
numColumns={rowItems.length < 5 ? rowItems.length : 5}
|
2021-06-14 08:37:38 +05:00
|
|
|
style={{
|
2021-07-10 00:22:51 +05:00
|
|
|
marginTop: note.type !== 'note' ? 10 : 0,
|
2021-07-10 14:23:30 +05:00
|
|
|
borderTopWidth: 1,
|
|
|
|
|
borderColor: colors.nav,
|
2021-07-19 13:25:32 +05:00
|
|
|
paddingTop: 20
|
2021-07-10 00:22:51 +05:00
|
|
|
}}
|
|
|
|
|
columnWrapperStyle={{
|
2021-07-19 13:25:32 +05:00
|
|
|
justifyContent: rowItems.length < 5 ? 'space-around' : 'flex-start'
|
2021-07-10 00:22:51 +05:00
|
|
|
}}
|
|
|
|
|
contentContainerStyle={{
|
|
|
|
|
alignSelf: 'center',
|
2021-07-19 13:25:32 +05:00
|
|
|
width: rowItems.length < 5 ? '100%' : null
|
2021-07-10 00:22:51 +05:00
|
|
|
}}
|
|
|
|
|
renderItem={({item, index}) => _renderRowItem(item)}
|
|
|
|
|
/>
|
2020-01-10 18:44:41 +05:00
|
|
|
) : null}
|
2020-01-24 18:48:33 +05:00
|
|
|
|
2021-04-29 10:45:46 +05:00
|
|
|
{note.type === 'note' && user && lastSynced >= note.dateEdited ? (
|
2021-06-14 14:41:57 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
2021-04-22 11:49:55 +05:00
|
|
|
paddingVertical: 10,
|
|
|
|
|
width: '95%',
|
|
|
|
|
alignItems: 'flex-start',
|
|
|
|
|
paddingHorizontal: 12,
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'flex-start',
|
2021-07-20 14:26:11 +05:00
|
|
|
alignSelf: 'center',
|
|
|
|
|
backgroundColor: colors.nav,
|
|
|
|
|
borderRadius: 5
|
2021-04-22 11:49:55 +05:00
|
|
|
}}>
|
2021-07-20 14:26:11 +05:00
|
|
|
<Icon
|
|
|
|
|
name="shield-key-outline"
|
|
|
|
|
color={colors.accent}
|
|
|
|
|
size={SIZE.sm + SIZE.xs + 2}
|
|
|
|
|
/>
|
2021-04-22 11:49:55 +05:00
|
|
|
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
flex: 1,
|
2021-07-20 14:26:11 +05:00
|
|
|
marginLeft: 5,
|
|
|
|
|
flexShrink: 1
|
2021-04-22 11:49:55 +05:00
|
|
|
}}>
|
|
|
|
|
<Heading
|
|
|
|
|
color={colors.accent}
|
|
|
|
|
style={{
|
2021-07-20 14:26:11 +05:00
|
|
|
fontSize: SIZE.sm,
|
|
|
|
|
flexWrap: 'wrap'
|
2021-04-22 11:49:55 +05:00
|
|
|
}}>
|
2021-07-20 14:26:11 +05:00
|
|
|
Encrypted and synced
|
2021-04-22 11:49:55 +05:00
|
|
|
</Heading>
|
|
|
|
|
<Paragraph
|
|
|
|
|
style={{
|
2021-07-20 14:26:11 +05:00
|
|
|
flexWrap: 'wrap'
|
2021-04-22 11:49:55 +05:00
|
|
|
}}
|
2021-07-20 14:26:11 +05:00
|
|
|
size={SIZE.xs}
|
2021-06-14 14:41:57 +05:00
|
|
|
color={colors.pri}>
|
2021-07-20 14:26:11 +05:00
|
|
|
No one can read this note except you.
|
2021-04-22 11:49:55 +05:00
|
|
|
</Paragraph>
|
|
|
|
|
</View>
|
2021-07-20 14:26:11 +05:00
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
onPress={async () => {
|
|
|
|
|
try {
|
|
|
|
|
close();
|
|
|
|
|
await sleep(300);
|
|
|
|
|
await openLinkInBrowser(
|
|
|
|
|
'https://docs.notesnook.com/how-is-my-data-encrypted/',
|
|
|
|
|
colors
|
|
|
|
|
);
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
}}
|
|
|
|
|
fontSize={SIZE.sm}
|
|
|
|
|
title="Learn more"
|
|
|
|
|
height={30}
|
|
|
|
|
type="accent"
|
|
|
|
|
/>
|
2021-06-14 14:41:57 +05:00
|
|
|
</View>
|
2021-04-22 11:49:55 +05:00
|
|
|
) : null}
|
|
|
|
|
|
2021-09-15 12:23:37 +05:00
|
|
|
{settings.devMode ? (
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
width: '100%',
|
|
|
|
|
paddingHorizontal: 12,
|
2021-11-02 11:48:28 +05:00
|
|
|
marginTop: 10,
|
2021-09-15 12:23:37 +05:00
|
|
|
}}>
|
|
|
|
|
<Button
|
|
|
|
|
onPress={async () => {
|
2021-11-02 11:48:28 +05:00
|
|
|
console.log('copy data');
|
2021-09-15 12:23:37 +05:00
|
|
|
let additionalData = {}
|
|
|
|
|
if (note.type === "note") {
|
|
|
|
|
let content = await db.content.raw(note.contentId);
|
2021-11-02 11:48:28 +05:00
|
|
|
if (content) {
|
|
|
|
|
content = db.debug.strip(content);
|
|
|
|
|
additionalData.content = content;
|
|
|
|
|
}
|
2021-09-15 12:23:37 +05:00
|
|
|
}
|
|
|
|
|
additionalData.lastSynced = await db.lastSynced();
|
2021-11-02 11:48:28 +05:00
|
|
|
console.log(_note);
|
2021-09-15 12:23:37 +05:00
|
|
|
let _note = {...note};
|
|
|
|
|
_note.additionalData = additionalData;
|
|
|
|
|
Clipboard.setString(db.debug.strip(_note));
|
2021-11-02 11:48:28 +05:00
|
|
|
|
2021-09-15 12:23:37 +05:00
|
|
|
ToastEvent.show({
|
|
|
|
|
heading:"Debug data copied!",
|
|
|
|
|
type:'success',
|
|
|
|
|
context:'local'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
fontSize={SIZE.sm}
|
|
|
|
|
title="Copy data"
|
|
|
|
|
icon="clipboard"
|
|
|
|
|
height={30}
|
|
|
|
|
type="warn"
|
|
|
|
|
style={{
|
|
|
|
|
alignSelf: 'flex-end'
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
|
|
|
|
) : null}
|
|
|
|
|
|
2020-01-24 18:48:33 +05:00
|
|
|
{DDS.isTab ? (
|
|
|
|
|
<View
|
|
|
|
|
style={{
|
2021-07-19 13:25:32 +05:00
|
|
|
height: 20
|
2020-01-24 18:48:33 +05:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
) : null}
|
2020-12-19 13:15:34 +05:00
|
|
|
</ScrollView>
|
2020-01-09 20:14:51 +05:00
|
|
|
);
|
|
|
|
|
};
|