Skip to content

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

update all ToastEvent functions

ammarahm-ed05d8bca5fd94
diff --git a/apps/mobile/ios/Notesnook.xcodeproj/project.pbxproj b/apps/mobile/ios/Notesnook.xcodeproj/project.pbxproj
index 336ce159f..c848d5e9f 100644
--- a/apps/mobile/ios/Notesnook.xcodeproj/project.pbxproj
+++ b/apps/mobile/ios/Notesnook.xcodeproj/project.pbxproj
@@ -18,13 +18,11 @@
2DCD954D1E0B4F2C00145EB5 /* NotesnookTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* NotesnookTests.m */; };
539FE06D3E38F091251923E8 /* libPods-Notesnook-Make Note.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5269A46969D8091533003C72 /* libPods-Notesnook-Make Note.a */; };
6515C42F2580AA3000E83E39 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6515C42E2580AA2F00E83E39 /* StoreKit.framework */; };
- 653BE16B25A2EA710045F8A2 /* Images-2.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 653BE16A25A2EA710045F8A2 /* Images-2.xcassets */; };
655FD77A253AD31C001D807D /* Web.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 655FD779253AD31C001D807D /* Web.bundle */; };
65B5014425A672B200E2D264 /* ShareViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 65B5014325A672B200E2D264 /* ShareViewController.m */; };
65B5014725A672B200E2D264 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 65B5014525A672B200E2D264 /* MainInterface.storyboard */; };
65B5014B25A672B200E2D264 /* Make Note.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 65B5014025A672B200E2D264 /* Make Note.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
65B5020325A6756700E2D264 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B5020225A6756700E2D264 /* File.swift */; };
- 65B5F41D257CADA5007D2310 /* notesnook-text.png in Resources */ = {isa = PBXBuildFile; fileRef = 65B5F41C257CADA5007D2310 /* notesnook-text.png */; };
65E0340B257B9FF100793428 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65E0340A257B9FF100793428 /* File.swift */; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
87CE5B71DC72F3D95B7B1AA5 /* libPods-Notesnook-tvOSTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A03E3F5851D27269540E147C /* libPods-Notesnook-tvOSTests.a */; };
@@ -94,7 +92,6 @@
5269A46969D8091533003C72 /* libPods-Notesnook-Make Note.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Notesnook-Make Note.a"; sourceTree = BUILT_PRODUCTS_DIR; };
6515C42E2580AA2F00E83E39 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
6529D2B0257B4A2900B49BC3 /* NotesnookDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = NotesnookDebug.entitlements; path = Notesnook/NotesnookDebug.entitlements; sourceTree = "<group>"; };
- 653BE16A25A2EA710045F8A2 /* Images-2.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = "Images-2.xcassets"; path = "Notesnook/Images-2.xcassets"; sourceTree = "<group>"; };
655FD779253AD31C001D807D /* Web.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = Web.bundle; path = ../html/Web.bundle; sourceTree = "<group>"; };
65A7F34F255689AD00699170 /* Notesnook.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = Notesnook.entitlements; path = Notesnook/Notesnook.entitlements; sourceTree = "<group>"; };
65B5014025A672B200E2D264 /* Make Note.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "Make Note.appex"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -104,7 +101,6 @@
65B501AA25A6733400E2D264 /* Make Note.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Make Note.entitlements"; sourceTree = "<group>"; };
65B5020125A6756700E2D264 /* Make Note-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Make Note-Bridging-Header.h"; sourceTree = "<group>"; };
65B5020225A6756700E2D264 /* File.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = File.swift; sourceTree = "<group>"; };
- 65B5F41C257CADA5007D2310 /* notesnook-text.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "notesnook-text.png"; path = "Notesnook/Images.xcassets/notesnook-text.png"; sourceTree = "<group>"; };
65E03409257B9FF100793428 /* Notesnook-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Notesnook-Bridging-Header.h"; sourceTree = "<group>"; };
65E0340A257B9FF100793428 /* File.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = File.swift; sourceTree = "<group>"; };
747E42E32601638E75E9A3CF /* Pods-Notesnook-tvOSTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Notesnook-tvOSTests.debug.xcconfig"; path = "Target Support Files/Pods-Notesnook-tvOSTests/Pods-Notesnook-tvOSTests.debug.xcconfig"; sourceTree = "<group>"; };
@@ -188,7 +184,6 @@
13B07FAE1A68108700A75B9A /* Notesnook */ = {
isa = PBXGroup;
children = (
- 65B5F41C257CADA5007D2310 /* notesnook-text.png */,
6529D2B0257B4A2900B49BC3 /* NotesnookDebug.entitlements */,
65A7F34F255689AD00699170 /* Notesnook.entitlements */,
655FD779253AD31C001D807D /* Web.bundle */,
@@ -201,7 +196,6 @@
13B07FB71A68108700A75B9A /* main.m */,
65E0340A257B9FF100793428 /* File.swift */,
65E03409257B9FF100793428 /* Notesnook-Bridging-Header.h */,
- 653BE16A25A2EA710045F8A2 /* Images-2.xcassets */,
);
name = Notesnook;
sourceTree = "<group>";
@@ -466,8 +460,6 @@
655FD77A253AD31C001D807D /* Web.bundle in Resources */,
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
- 653BE16B25A2EA710045F8A2 /* Images-2.xcassets in Resources */,
- 65B5F41D257CADA5007D2310 /* notesnook-text.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -541,12 +533,42 @@
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Notesnook/Pods-Notesnook-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core.common-CoreModulesHeaders/AccessibilityResources.bundle",
+ "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/AntDesign.ttf",
+ "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Entypo.ttf",
+ "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/EvilIcons.ttf",
+ "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Feather.ttf",
+ "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf",
+ "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/FontAwesome5_Brands.ttf",
+ "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/FontAwesome5_Regular.ttf",
+ "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/FontAwesome5_Solid.ttf",
+ "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Fontisto.ttf",
+ "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Foundation.ttf",
+ "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf",
"${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf",
+ "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/MaterialIcons.ttf",
+ "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Octicons.ttf",
+ "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/SimpleLineIcons.ttf",
+ "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Zocial.ttf",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AccessibilityResources.bundle",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AntDesign.ttf",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Entypo.ttf",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/EvilIcons.ttf",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Feather.ttf",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/FontAwesome.ttf",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/FontAwesome5_Brands.ttf",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/FontAwesome5_Regular.ttf",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/FontAwesome5_Solid.ttf",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Fontisto.ttf",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Foundation.ttf",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Ionicons.ttf",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/MaterialCommunityIcons.ttf",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/MaterialIcons.ttf",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Octicons.ttf",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/SimpleLineIcons.ttf",
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Zocial.ttf",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -1083,8 +1105,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Notesnook/Notesnook.entitlements;
- CODE_SIGN_IDENTITY = "iPhone Distribution";
- CODE_SIGN_STYLE = Manual;
+ CODE_SIGN_IDENTITY = "Apple Development";
+ CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1220;
DEVELOPMENT_TEAM = 53CWBG3QUC;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
@@ -1164,7 +1186,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = org.streetwriters.notesnook;
PRODUCT_NAME = Notesnook;
- PROVISIONING_PROFILE_SPECIFIER = "Notesnook iOS Distribution";
+ PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Notesnook-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
@@ -1412,8 +1434,8 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = "Make Note/Make Note.entitlements";
- CODE_SIGN_IDENTITY = "iPhone Distribution";
- CODE_SIGN_STYLE = Manual;
+ CODE_SIGN_IDENTITY = "Apple Development";
+ CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1200;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
@@ -1492,7 +1514,7 @@
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.streetwriters.notesnook.share;
PRODUCT_NAME = "$(TARGET_NAME)";
- PROVISIONING_PROFILE_SPECIFIER = "Notesnook Extension iOS Distribution 2";
+ PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "Make Note/Make Note-Bridging-Header.h";
SWIFT_VERSION = 5.0;
diff --git a/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js b/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js
index 86212e730..114d0d709 100644
--- a/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js
+++ b/apps/mobile/src/components/ActionSheetComponent/ActionSheetTagsSection.js
@@ -46,7 +46,11 @@ export const ActionSheetTagsSection = ({item, close}) => {
const _onSubmit = async () => {
if (!tagToAdd || tagToAdd === '' || tagToAdd.trimStart().length == 0) {
- ToastEvent.show('Empty Tag', 'error', 'local');
+ ToastEvent.show({
+ heading: 'Tag field is empty',
+ type: 'error',
+ context: 'local',
+ });
return;
}
@@ -74,8 +78,12 @@ export const ActionSheetTagsSection = ({item, close}) => {
});
tagToAdd = '';
} catch (e) {
- //console.log(e.message);
- ToastEvent.show(e.message, 'error', 'local');
+ ToastEvent.show({
+ heading: "Cannot add tag",
+ type: 'error',
+ message: error.message,
+ context: 'local',
+ });
}
};
diff --git a/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js b/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js
index 618ec2721..420fe878a 100644
--- a/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js
+++ b/apps/mobile/src/components/ActionSheetComponent/ActionSheetWrapper.js
@@ -15,6 +15,7 @@ import {
} from '../../views/Editor/Functions';
import tiny from '../../views/Editor/tiny/tiny';
import { focusEditor } from '../../views/Editor/tiny/toolbar/constants';
+import { Toast } from '../Toast';
import { GetPremium } from './GetPremium';
const ActionSheetWrapper = ({
@@ -87,11 +88,14 @@ const ActionSheetWrapper = ({
onOpen={_onOpen}
keyboardShouldPersistTaps="always"
premium={
+ <>
+ <Toast context="local" />
<GetPremium
context="sheet"
close={() => fwdRef?.current?.hide()}
offset={50}
/>
+ </>
}
onClose={_onClose}>
{children}
diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js
index b0da548eb..e22d8625b 100644
--- a/apps/mobile/src/components/ActionSheetComponent/index.js
+++ b/apps/mobile/src/components/ActionSheetComponent/index.js
@@ -127,7 +127,7 @@ export const ActionSheetComponent = ({
Navigation.setRoutesToUpdate([
Navigation.routeNames.NotesPage,
Navigation.routeNames.Favorites,
- ])
+ ]);
}
}
setNote({...toAdd});
@@ -156,8 +156,8 @@ export const ActionSheetComponent = ({
novault: true,
locked: true,
share: true,
- title:'Share note',
- description:"Unlock note to share it."
+ title: 'Share note',
+ description: 'Unlock note to share it.',
});
} else {
let text = await db.notes.note(note.id).export('txt');
@@ -189,9 +189,9 @@ export const ActionSheetComponent = ({
novault: true,
locked: true,
item: note,
- title:'Delete note',
- description:"Unlock note to delete it."
- });
+ title: 'Delete note',
+ description: 'Unlock note to delete it.',
+ });
} else {
try {
await deleteItems(note);
@@ -226,15 +226,19 @@ export const ActionSheetComponent = ({
novault: true,
locked: true,
item: note,
- title:'Copy note',
- description:"Unlock note to copy to clipboard."
+ title: 'Copy note',
+ description: 'Unlock note to copy to clipboard.',
});
} else {
let text = await db.notes.note(note.id).content();
text = toTXT(text);
text = `${note.title}\n \n ${text}`;
Clipboard.setString(text);
- ToastEvent.show('Note copied to clipboard', 'success', 'local');
+ ToastEvent.show({
+ heading: 'Note copied to clipboard',
+ type: 'success',
+ context: 'local',
+ });
}
},
},
@@ -249,14 +253,17 @@ export const ActionSheetComponent = ({
Navigation.routeNames.Notebooks,
Navigation.routeNames.NotesPage,
Navigation.routeNames.Favorites,
- Navigation.routeNames.Trash
- ])
+ Navigation.routeNames.Trash,
+ ]);
type = note.type === 'trash' ? note.itemType : note.type;
- ToastEvent.show(
- type === 'note' ? 'Note restored' : 'Notebook restored',
- 'success',
- 'global',
- );
+
+ ToastEvent.show({
+ heading:
+ type === 'note'
+ ? 'Note restored from trash'
+ : 'Notebook restored from trash',
+ type: 'success',
+ });
close();
},
},
@@ -295,21 +302,21 @@ export const ActionSheetComponent = ({
if (!note.id) return;
if (note.type === 'note') {
if (db.notes.pinned.length === 3 && !note.pinned) {
- ToastEvent.show(
- 'You cannot pin more than 3 notes',
- 'error',
- 'local',
- );
+ ToastEvent.show({
+ heading: 'Cannot pin more than 3 notes',
+ type: 'error',
+ context: 'local',
+ });
return;
}
await db.notes.note(note.id).pin();
} else {
if (db.notebooks.pinned.length === 3 && !note.pinned) {
- ToastEvent.show(
- 'You cannot pin more than 3 notes',
- 'error',
- 'local',
- );
+ ToastEvent.show({
+ heading: 'Cannot pin more than 3 notebooks',
+ type: 'error',
+ context: 'local',
+ });
return;
}
await db.notebooks.notebook(note.id).pin();
@@ -349,8 +356,10 @@ export const ActionSheetComponent = ({
color: 'orange',
},
{
- name: isPinnedToMenu ? 'Remove Shortcut from Menu' : 'Add Shortcut to Menu',
- icon: isPinnedToMenu? 'link-variant-remove' : 'link-variant',
+ name: isPinnedToMenu
+ ? 'Remove Shortcut from Menu'
+ : 'Add Shortcut to Menu',
+ icon: isPinnedToMenu ? 'link-variant-remove' : 'link-variant',
func: async () => {
try {
if (isPinnedToMenu) {
@@ -730,12 +739,12 @@ export const ActionSheetComponent = ({
.notebook(editing.actionAfterFirstSave.notebook)
.topics.topic(editing.actionAfterFirstSave.id)
.delete(note.id);
- Navigation.setRoutesToUpdate([
- Navigation.routeNames.Notebooks,
- Navigation.routeNames.Notes,
- Navigation.routeNames.NotesPage,
- Navigation.routeNames.Notebook,
- ]);
+ Navigation.setRoutesToUpdate([
+ Navigation.routeNames.Notebooks,
+ Navigation.routeNames.Notes,
+ Navigation.routeNames.NotesPage,
+ Navigation.routeNames.Notebook,
+ ]);
setNote(db.notes.note(note.id).data);
close();
}}
@@ -778,7 +787,6 @@ export const ActionSheetComponent = ({
}}
/>
) : null}
- <Toast context="local" />
</ScrollView>
);
};
diff --git a/apps/mobile/src/components/Dialog/index.js b/apps/mobile/src/components/Dialog/index.js
index 79b76af27..f4619752c 100644
--- a/apps/mobile/src/components/Dialog/index.js
+++ b/apps/mobile/src/components/Dialog/index.js
@@ -41,7 +41,11 @@ export class Dialog extends Component {
updateEvent({type: Actions.TRASH});
updateEvent({type: Actions.CLEAR_SELECTION});
updateEvent({type: Actions.SELECTION_MODE, enabled: false});
- ToastEvent.show('Permanantly deleted','success');
+ ToastEvent.show({
+ heading: 'Permanantly deleted items',
+ type: 'success',
+ context: 'local',
+ });
this.hide();
break;
}
@@ -50,7 +54,12 @@ export class Dialog extends Component {
updateEvent({type: Actions.TRASH});
updateEvent({type: Actions.CLEAR_SELECTION});
updateEvent({type: Actions.SELECTION_MODE, enabled: false});
- ToastEvent.show('Trash cleared', 'success');
+ ToastEvent.show({
+ heading: 'Trash cleared',
+ message:"All notes and notebooks in the trash have been removed permanantly.",
+ type: 'success',
+ context: 'local',
+ });
this.hide();
break;
}
diff --git a/apps/mobile/src/components/Menu/UserSection.js b/apps/mobile/src/components/Menu/UserSection.js
index ffbb2be68..39a4c376f 100644
--- a/apps/mobile/src/components/Menu/UserSection.js
+++ b/apps/mobile/src/components/Menu/UserSection.js
@@ -37,7 +37,11 @@ export const UserSection = ({noTextMode}) => {
activeOpacity={0.8}
onPress={() => {
if (user) {
- ToastEvent.show('Logged in as ' + user?.email, 'success');
+ ToastEvent.show({
+ title: 'Logged in as ' + user?.email,
+ type: 'success',
+ context: 'local',
+ });
} else {
eSendEvent(eOpenLoginDialog);
}
diff --git a/apps/mobile/src/components/MergeEditor/index.js b/apps/mobile/src/components/MergeEditor/index.js
index 5470bc25f..04f43a410 100644
--- a/apps/mobile/src/components/MergeEditor/index.js
+++ b/apps/mobile/src/components/MergeEditor/index.js
@@ -32,7 +32,7 @@ import KeepAwake from '@sayem314/react-native-keep-awake';
import {timeConverter} from '../../utils/TimeUtils';
import tiny from '../../views/Editor/tiny/tiny';
import diff from '../../utils/differ';
-import { openLinkInBrowser } from '../../utils/functions';
+import {openLinkInBrowser} from '../../utils/functions';
const {Value, timing} = Animated;
@@ -133,10 +133,17 @@ const MergeEditor = () => {
const _onShouldStartLoadWithRequest = (request) => {
if (request.url.includes('http')) {
openLinkInBrowser(request.url, colors)
- .catch((e) => ToastEvent.show(e.message, 'error'))
- .then((r) => {
- console.log('closed');
- });
+ .catch((e) =>
+ ToastEvent.show({
+ title: 'Failed to open link',
+ message: e.message,
+ type: 'success',
+ context: 'local',
+ }),
+ )
+ .then((r) => {
+ console.log('closed');
+ });
return false;
} else {
diff --git a/apps/mobile/src/components/MoveNoteDialog/index.js b/apps/mobile/src/components/MoveNoteDialog/index.js
index 586fd3df1..9fe6b1e1a 100644
--- a/apps/mobile/src/components/MoveNoteDialog/index.js
+++ b/apps/mobile/src/components/MoveNoteDialog/index.js
@@ -91,7 +91,11 @@ const MoveNoteComponent = ({close, note, setNote}) => {
const addNewNotebook = async () => {
if (!newNotebookTitle || newNotebookTitle.trim().length === 0)
- return ToastEvent.show('Title is required', 'error', 'local');
+ return ToastEvent.show({
+ heading: 'Notebook title is required',
+ type: 'error',
+ context: 'local',
+ });
await db.notebooks.add({
title: newNotebookTitle,
@@ -106,7 +110,11 @@ const MoveNoteComponent = ({close, note, setNote}) => {
const addNewTopic = async () => {
if (!newTopicTitle || newTopicTitle.trim().length === 0) {
- return ToastEvent.show('Title is required', 'error', 'local');
+ return ToastEvent.show({
+ heading: 'Topic title is required',
+ type: 'error',
+ context: 'local',
+ });
}
await db.notebooks.notebook(expanded).topics.add(newTopicTitle);
Navigation.setRoutesToUpdate([Navigation.routeNames.Notebooks]);
@@ -459,7 +467,6 @@ const MoveNoteComponent = ({close, note, setNote}) => {
)}
/>
</View>
- <Toast context="local" />
</>
);
};
diff --git a/apps/mobile/src/components/ProgressDialog/index.js b/apps/mobile/src/components/ProgressDialog/index.js
index 63224d228..9bf7b4b8a 100644
--- a/apps/mobile/src/components/ProgressDialog/index.js
+++ b/apps/mobile/src/components/ProgressDialog/index.js
@@ -133,7 +133,6 @@ const ProgressDialog = () => {
/>
))}
</View>
- <Toast context="local" />
</ActionSheetWrapper>
);
};
diff --git a/apps/mobile/src/components/RecoveryKeyDialog/index.js b/apps/mobile/src/components/RecoveryKeyDialog/index.js
index 608de5b34..49ce4f5dd 100644
--- a/apps/mobile/src/components/RecoveryKeyDialog/index.js
+++ b/apps/mobile/src/components/RecoveryKeyDialog/index.js
@@ -1,23 +1,23 @@
-import React, { createRef } from 'react';
-import { Clipboard, View } from 'react-native';
+import React, {createRef} from 'react';
+import {Clipboard, View} from 'react-native';
import QRCode from 'react-native-qrcode-svg';
import Share from 'react-native-share';
-import { LOGO_BASE64 } from '../../assets/images/assets';
+import {LOGO_BASE64} from '../../assets/images/assets';
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
- ToastEvent
+ ToastEvent,
} from '../../services/EventManager';
-import { eOpenRecoveryKeyDialog, eOpenResultDialog } from '../../utils/Events';
-import { SIZE } from '../../utils/SizeUtils';
+import {eOpenRecoveryKeyDialog, eOpenResultDialog} from '../../utils/Events';
+import {SIZE} from '../../utils/SizeUtils';
import Storage from '../../utils/storage';
-import { sleep } from '../../utils/TimeUtils';
+import {sleep} from '../../utils/TimeUtils';
import ActionSheetWrapper from '../ActionSheetComponent/ActionSheetWrapper';
-import { Button } from '../Button';
+import {Button} from '../Button';
import DialogHeader from '../Dialog/dialog-header';
import Seperator from '../Seperator';
-import { Toast } from '../Toast';
+import {Toast} from '../Toast';
import Paragraph from '../Typography/Paragraph';
let RNFetchBlob;
@@ -52,7 +52,12 @@ class RecoveryKeyDialog extends React.Component {
close = () => {
if (this.tapCount === 0) {
- ToastEvent.show('Tap one more time to confirm.', 'success', 'local');
+ ToastEvent.show({
+ heading: 'Did you save recovery key?',
+ message: 'Tap one more time to confirm.',
+ type: 'success',
+ context: 'local',
+ });
this.tapCount++;
return;
}
@@ -84,7 +89,12 @@ class RecoveryKeyDialog extends React.Component {
saveQRCODE = async () => {
if ((await Storage.requestPermission()) === false) {
- ToastEvent.show('Storage access not granted!', 'error', 'local');
+ ToastEvent.show({
+ heading: 'Storage access not granted',
+ message: 'You must provide access to phone storage to save QR-Code',
+ type: 'error',
+ context: 'local',
+ });
return;
}
@@ -101,11 +111,12 @@ class RecoveryKeyDialog extends React.Component {
},
])
.then((r) => {
- ToastEvent.show(
- 'Recovery key saved to Gallery as ' + path + fileName,
- 'success',
- 'local',
- );
+ ToastEvent.show({
+ heading: 'Recovery key QR-Code saved',
+ message: 'QR-Code image has been saved to Gallery at ' + path + fileName,
+ type: 'success',
+ context: 'local',
+ });
});
});
});
@@ -113,35 +124,39 @@ class RecoveryKeyDialog extends React.Component {
saveToTextFile = async () => {
if ((await Storage.requestPermission()) === false) {
- ToastEvent.show('Storage access not granted!', 'error', 'local');
+ ToastEvent.show({
+ heading: 'Storage access not granted',
+ message: 'You must provide access to phone storage to save recovery key text file.',
+ type: 'error',
+ context: 'local',
+ });
return;
}
try {
let path = await Storage.checkAndCreateDir('/');
- let fileName = 'nn_' + "test" + '_recovery_key.txt';
- RNFetchBlob = require('rn-fetch-blob').default
+ let fileName = 'nn_' + 'test' + '_recovery_key.txt';
+ RNFetchBlob = require('rn-fetch-blob').default;
await RNFetchBlob.fs.writeFile(path + fileName, this.state.key, 'utf8');
- ToastEvent.show(
- 'Recovery key saved as ' + path + fileName,
- 'success',
- 'local',
- );
+ ToastEvent.show({
+ heading: 'Recovery key text file saved',
+ message: 'Recovery key saved in text file at ' + path + fileName,
+ type: 'success',
+ context: 'local',
+ });
return path + fileName;
} catch (e) {
-
- alert(e.message)
-
+ alert(e.message);
}
};
onOpen = async () => {
//let k = await db.user.getEncryptionKey();
- // this.user = await db.user.getUser();
- // if (k) {
- // this.setState({
- // key: k.key,
- // });
- // }
+ // this.user = await db.user.getUser();
+ // if (k) {
+ // this.setState({
+ // key: k.key,
+ // });
+ // }
};
shareFile = async () => {
@@ -185,7 +200,6 @@ class RecoveryKeyDialog extends React.Component {
padding: 10,
marginTop: 10,
}}>
-
<Paragraph
color={colors.icon}
size={SIZE.md}
@@ -194,7 +208,7 @@ class RecoveryKeyDialog extends React.Component {
width: '100%',
maxWidth: '100%',
paddingRight: 10,
- marginBottom:10
+ marginBottom: 10,
}}>
{this.state.key}
</Paragraph>
@@ -202,7 +216,11 @@ class RecoveryKeyDialog extends React.Component {
<Button
onPress={() => {
Clipboard.setString(this.state.key);
- ToastEvent.show('Copied!', 'success', 'local');
+ ToastEvent.show({
+ heading: 'Recovery key copied!',
+ type: 'success',
+ context: 'local',
+ });
}}
icon="content-copy"
title="Copy to clipboard"
@@ -211,8 +229,6 @@ class RecoveryKeyDialog extends React.Component {
fontSize={SIZE.md}
height={50}
/>
-
-
</View>
<Seperator />
@@ -225,7 +241,7 @@ class RecoveryKeyDialog extends React.Component {
justifyContent: 'center',
position: 'absolute',
opacity: 0,
- zIndex:-1
+ zIndex: -1,
}}>
{this.state.key ? (
<QRCode
@@ -275,7 +291,6 @@ class RecoveryKeyDialog extends React.Component {
fontSize={SIZE.md}
onPress={this.close}
/>
- <Toast context="local" />
</View>
</ActionSheetWrapper>
);
diff --git a/apps/mobile/src/components/RestoreDialog/index.js b/apps/mobile/src/components/RestoreDialog/index.js
index 802f7fe38..76f40e2de 100644
--- a/apps/mobile/src/components/RestoreDialog/index.js
+++ b/apps/mobile/src/components/RestoreDialog/index.js
@@ -22,7 +22,7 @@ import {Toast} from '../Toast';
import Paragraph from '../Typography/Paragraph';
const actionSheetRef = createRef();
-let RNFetchBlob
+let RNFetchBlob;
const RestoreDialog = () => {
const [visible, setVisible] = useState(false);
const [restoring, setRestoring] = useState(false);
@@ -50,11 +50,12 @@ const RestoreDialog = () => {
};
const showIsWorking = () => {
- ToastEvent.show(
- 'Please wait, we are restoring your data.',
- 'error',
- 'local',
- );
+ ToastEvent.show({
+ heading: 'Restoring Backup',
+ message: 'Your backup data is being restored. please wait.',
+ type: 'error',
+ context: 'local',
+ });
};
return !visible ? null : (
@@ -91,11 +92,12 @@ const RestoreDataComponent = ({close, setRestoring, restoring}) => {
if (Platform.OS === 'android') {
let granted = storage.requestPermission();
if (!granted) {
- ToastEvent.show(
- 'Restore Failed! Storage access denied',
- 'error',
- 'local',
- );
+ ToastEvent.show({
+ heading: 'Cannot restore backup',
+ message: 'You must provide phone storage access to restore backups.',
+ type: 'error',
+ context: 'local',
+ });
return;
}
}
@@ -105,11 +107,21 @@ const RestoreDataComponent = ({close, setRestoring, restoring}) => {
await db.backup.import(backup);
setRestoring(false);
dispatch({type: Actions.ALL});
- ToastEvent.show('Restore Complete!', 'success', 'local');
+ ToastEvent.show({
+ heading: 'Restore successful',
+ message: 'Your backup data has been restored successfully.',
+ type: 'success',
+ context: 'local',
+ });
close();
} catch (e) {
setRestoring(false);
- ToastEvent.show(e.message, 'error', 'local');
+ ToastEvent.show({
+ heading: 'Restore failed',
+ message: e.message,
+ type: 'error',
+ context: 'local',
+ });
}
};
@@ -117,14 +129,17 @@ const RestoreDataComponent = ({close, setRestoring, restoring}) => {
if (Platform.OS === 'android') {
let granted = await storage.requestPermission();
if (!granted) {
- ToastEvent.show(
- 'Storage permission required to check for backups.',
- 'error',
- );
+ ToastEvent.show({
+ heading: 'Backup check failed',
+ message:
+ 'You must provide phone storage access to check for backups.',
+ type: 'success',
+ context: 'local',
+ });
return;
}
}
- RNFetchBlob = require('rn-fetch-blob').default
+ RNFetchBlob = require('rn-fetch-blob').default;
try {
let path = await storage.checkAndCreateDir('/backups/');
let files = await RNFetchBlob.fs.lstat(path);
@@ -169,19 +184,24 @@ const RestoreDataComponent = ({close, setRestoring, restoring}) => {
await db.backup.import(JSON.stringify(backup));
setRestoring(false);
dispatch({type: Actions.ALL});
- ToastEvent.show(
- 'Restore Complete!',
- 'success',
- 'global',
- );
+
+ ToastEvent.show({
+ heading: 'Restore successful',
+ message:
+ 'Your backup data has been restored successfully.',
+ type: 'success',
+ context: 'local',
+ });
setVisible(false);
} catch (e) {
setRestoring(false);
- ToastEvent.show(
- 'Invalid backup data',
- 'error',
- 'local',
- );
+ ToastEvent.show({
+ heading: 'Restore failed',
+ message:
+ 'The selected backup data file is invalid. You must select a *.nnbackup file to restore.',
+ type: 'error',
+ context: 'local',
+ });
}
});
})
@@ -285,7 +305,6 @@ const RestoreDataComponent = ({close, setRestoring, restoring}) => {
}
/>
</View>
- <Toast context="local" />
</>
);
};
diff --git a/apps/mobile/src/components/SelectionHeader/index.js b/apps/mobile/src/components/SelectionHeader/index.js
index 3e744d602..468ef666b 100644
--- a/apps/mobile/src/components/SelectionHeader/index.js
+++ b/apps/mobile/src/components/SelectionHeader/index.js
@@ -34,7 +34,7 @@ export const SelectionHeader = () => {
const onHeaderStateChange = (event) => {
if (!event) return;
- setHeaderTextState(event);
+ setHeaderTextState(event);
};
useEffect(() => {
@@ -85,7 +85,10 @@ export const SelectionHeader = () => {
]);
dispatch({type: Actions.SELECTION_MODE, enabled: false});
dispatch({type: Actions.CLEAR_SELECTION});
- ToastEvent.show('Restore complete', 'success');
+ ToastEvent.show({
+ heading: 'Restore successful',
+ type: 'success',
+ });
}
};
diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.js
index aaf8e09de..20b987737 100644
--- a/apps/mobile/src/components/SimpleList/index.js
+++ b/apps/mobile/src/components/SimpleList/index.js
@@ -67,13 +67,6 @@ const SimpleList = ({
setLoading(false);
}, [listData, deviceMode]);
- /*
- const loadData = () => {
- let mainData = [header, {type: 'empty'}];
- mainData =
- !listData || listData.length === 0 ? mainData : [header].concat(listData);
- setDataProvider(dataProvider.cloneWithRows(mainData));
- }; */
const _onRefresh = async () => {
await Sync.run();
@@ -186,6 +179,9 @@ const SimpleList = ({
return (
<Header
title={headerProps.heading}
+ paragraph={headerProps.paragraph}
+ onPress={headerProps.onPress}
+ icon={headerProps.icon}
type={dataType}
index={index}
data={listData}
diff --git a/apps/mobile/src/components/SplashScreen/index.js b/apps/mobile/src/components/SplashScreen/index.js
index 0b40f3b1d..9abc7f6a2 100644
--- a/apps/mobile/src/components/SplashScreen/index.js
+++ b/apps/mobile/src/components/SplashScreen/index.js
@@ -22,6 +22,44 @@ import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
+
+const features = [
+ {
+ title: 'Notesnook',
+ description: 'A safe place to write and stay organized.',
+ icon: require('../../assets/images/notesnook-logo-png.png'),
+ type: 'image',
+ },
+ {
+ title: 'Made to protect your privacy',
+ description:
+ 'Your data is encrypted on your device. No one but you can read your notes.',
+ icon: PRIVACY_SVG,
+ link: 'https://notesnook.com',
+ },
+ {
+ icon: SYNC_SVG,
+ title: 'While keeping you in sync',
+ description:
+ 'Everything is automatically synced to all your devices in a safe and secure way. Notesnook is available on all major platforms.',
+ link: 'https://notesnook.com',
+ },
+ {
+ icon: ORGANIZE_SVG,
+ title: 'And helping you stay organized',
+ description:
+ 'Add your notes in notebooks and topics or simply assign tags or colors to find them easily.',
+ link: 'https://notesnook.com',
+ },
+ {
+ icon: COMMUNITY_SVG,
+ title: 'Join our community',
+ description:
+ 'We are not ghosts, chat with us and share your experience. Give suggestions, report issues and meet other people using Notesnook',
+ link: 'https://discord.gg/zQBK97EE22',
+ },
+];
+
const SplashScreen = () => {
const [state, dispatch] = useTracked();
const {colors} = state;
@@ -31,50 +69,12 @@ const SplashScreen = () => {
const opacity = useValue(0);
const translateY = useValue(20);
const translateY2 = useValue(0);
- const features = [
- {
- title: 'Notesnook',
- description: 'A safe place to write and stay organized.',
- icon: require('../../assets/images/notesnook-logo-png.png'),
- type: 'image',
- },
- {
- title: 'Made to protect your privacy',
- description:
- 'Your data is encrypted on your device. No one but you can read your notes.',
- icon: PRIVACY_SVG,
- link: 'https://notesnook.com',
- },
- {
- icon: SYNC_SVG,
- title: 'While keeping you in sync',
- description:
- 'Everything is automatically synced to all your devices in a safe and secure way. Notesnook is available on all major platforms.',
- link: 'https://notesnook.com',
- },
- {
- icon: ORGANIZE_SVG,
- title: 'And helping you stay organized',
- description:
- 'Add your notes in notebooks and topics or simply assign tags or colors to find them easily.',
- link: 'https://notesnook.com',
- },
- {
- icon: COMMUNITY_SVG,
- title: 'Join our community',
- description:
- 'We are not ghosts, chat with us and share your experience. Give suggestions, report issues and meet other people using Notesnook',
- link: 'https://discord.gg/zQBK97EE22',
- },
- ];
useEffect(() => {
- return;
Storage.read('introCompleted').then(async (r) => {
- setVisible(true);
- await sleep(500);
requestAnimationFrame(() => {
if (!r) {
+ setVisible(true);
timing(opacity, {
toValue: 1,
duration: 500,
@@ -136,7 +136,6 @@ const SplashScreen = () => {
data={features}
itemWidth={dWidth}
sliderWidth={dWidth}
- autoplay={true}
loop={false}
shouldOptimizeUpdates
autoplayInterval={5000}
@@ -216,11 +215,9 @@ const SplashScreen = () => {
title="Learn more"
fontSize={SIZE.md}
onPress={() => {
- openLinkInBrowser(item.link, colors)
- .catch((e) => ToastEvent.show(e.message, 'error'))
- .then((r) => {
- console.log('closed');
- });
+ try {
+ openLinkInBrowser(item.link, colors);
+ } catch (e) {}
}}
/>
)}
@@ -245,6 +242,7 @@ const SplashScreen = () => {
<Button
fontSize={SIZE.md}
onPress={async () => {
+ await Storage.write('introCompleted', 'true');
await hide();
}}
height={50}
@@ -262,6 +260,7 @@ const SplashScreen = () => {
carouselRef.current?.snapToNext();
} else {
await hide();
+ await Storage.write('introCompleted', 'true');
eSendEvent(eOpenLoginDialog, 1);
}
}}
diff --git a/apps/mobile/src/components/Toast/index.js b/apps/mobile/src/components/Toast/index.js
index b5fa8ecc1..85e04d5aa 100644
--- a/apps/mobile/src/components/Toast/index.js
+++ b/apps/mobile/src/components/Toast/index.js
@@ -1,13 +1,17 @@
-import React, { useEffect, useState } from 'react';
-import { Keyboard, TouchableOpacity, View } from 'react-native';
-import Animated, { Easing, useValue } from 'react-native-reanimated';
+import React, {useEffect, useState} from 'react';
+import {Keyboard, TouchableOpacity, View} from 'react-native';
+import Animated, {Easing, useValue} from 'react-native-reanimated';
+import {useSafeAreaInsets} from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useTracked } from '../../provider';
-import { DDS } from '../../services/DeviceDetection';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
-import { dHeight, getElevation } from '../../utils';
-import { eHideToast, eShowToast } from '../../utils/Events';
-import { sleep } from '../../utils/TimeUtils';
+import {useTracked} from '../../provider';
+import {DDS} from '../../services/DeviceDetection';
+import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/EventManager';
+import {dHeight, getElevation} from '../../utils';
+import {eHideToast, eShowToast} from '../../utils/Events';
+import {SIZE} from '../../utils/SizeUtils';
+import {sleep} from '../../utils/TimeUtils';
+import {Button} from '../Button';
+import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
const {timing} = Animated;
@@ -21,9 +25,10 @@ export const Toast = ({context = 'global'}) => {
backgroundColor: colors.errorBg,
color: colors.errorText,
});
+ const insets = useSafeAreaInsets();
- let toastTranslate = useValue(dHeight);
- let toastOpacity = useValue(1);
+ let toastTranslate = useValue(-dHeight);
+ let toastOpacity = useValue(0);
const showToastFunc = async (data) => {
if (data.context !== context) return;
@@ -43,7 +48,7 @@ export const Toast = ({context = 'global'}) => {
color: colors.errorText,
});
}
- toastTranslate.setValue(dHeight);
+ toastTranslate.setValue(-dHeight);
toastTranslate.setValue(0);
await sleep(50);
timing(toastOpacity, {
@@ -98,7 +103,7 @@ export const Toast = ({context = 'global'}) => {
easing: Easing.inOut(Easing.ease),
}).start(async () => {
await sleep(100);
- toastTranslate.setValue(dHeight);
+ toastTranslate.setValue(-dHeight);
toastMessages.shift();
setData({});
});
@@ -115,7 +120,7 @@ export const Toast = ({context = 'global'}) => {
useEffect(() => {
toastMessages = [];
- toastTranslate.setValue(dHeight);
+ toastTranslate.setValue(-dHeight);
toastOpacity.setValue(0);
Keyboard.addListener('keyboardDidShow', _onKeyboardShow);
Keyboard.addListener('keyboardDidHide', _onKeyboardHide);
@@ -137,11 +142,10 @@ export const Toast = ({context = 'global'}) => {
alignItems: 'center',
alignSelf: 'center',
minHeight: 30,
- bottom: keyboard ? 30 : 100,
+ top: insets.top + 10,
position: 'absolute',
zIndex: 999,
elevation: 15,
- opacity: toastOpacity,
transform: [
{
translateY: toastTranslate,
@@ -154,29 +158,30 @@ export const Toast = ({context = 'global'}) => {
...getElevation(5),
...toastStyle,
maxWidth: '95%',
- backgroundColor: 'black',
+ backgroundColor: colors.nav,
minWidth: data.func ? '95%' : '50%',
alignSelf: 'center',
borderRadius: 5,
+ opacity: toastOpacity,
minHeight: 30,
paddingVertical: 10,
- paddingHorizontal: 15,
+ paddingLeft: 12,
+ paddingRight: 5,
justifyContent: 'space-between',
flexDirection: 'row',
alignItems: 'center',
+ width: '95%',
}}>
<View
style={{
flexDirection: 'row',
alignItems: 'center',
- maxWidth: !data.func ? '90%' : '75%',
+ flexGrow: 1,
+ flex: 1,
}}>
<View
style={{
- width: 25,
- height: 25,
- backgroundColor:
- data.type === 'error' ? colors.errorText : colors.successText,
+ height: 30,
borderRadius: 100,
justifyContent: 'center',
alignItems: 'center',
@@ -184,41 +189,47 @@ export const Toast = ({context = 'global'}) => {
}}>
<Icon
name={data.type === 'success' ? 'check' : 'close'}
- size={20}
- color="white"
+ size={SIZE.lg}
+ color={data.type === 'error' ? colors.errorText : colors.accent}
/>
</View>
- <Paragraph
- color="white"
- onPress={() => {
- hideToastFunc();
- }}
+ <View
style={{
- width: '90%',
+ flexGrow: 1,
+ paddingRight: 25,
}}>
- {data.message}
- </Paragraph>
+ {data?.heading && (
+ <Heading
+ color={colors.pri}
+ size={SIZE.md}
+ onPress={() => {
+ hideToastFunc();
+ }}>
+ {data.heading}
+ </Heading>
+ )}
+
+ {data?.message && (
+ <Paragraph
+ color={colors.pri}
+ onPress={() => {
+ hideToastFunc();
+ }}>
+ {data.message}
+ </Paragraph>
+ )}
+ </View>
</View>
{data.func ? (
- <TouchableOpacity
+ <Button
+ fontSize={SIZE.md}
+ type={data.type === 'error' ? 'errorShade' : 'transparent'}
onPress={data.func}
- style={{
- width: '15%',
- height: '100%',
- alignItems: 'center',
- justifyContent: 'center',
- borderRadius: 5,
- }}
- activeOpacity={0.5}>
- <Paragraph
- color={
- data.type === 'error' ? colors.errorText : colors.successText
- }>
- {data.actionText}
- </Paragraph>
- </TouchableOpacity>
+ title={data.actionText}
+ height={30}
+ />
) : null}
</Animated.View>
</Animated.View>
diff --git a/apps/mobile/src/components/UpdateDialog/index.js b/apps/mobile/src/components/UpdateDialog/index.js
index 1b5168042..df3f9ea30 100644
--- a/apps/mobile/src/components/UpdateDialog/index.js
+++ b/apps/mobile/src/components/UpdateDialog/index.js
@@ -31,7 +31,7 @@ export const UpdateDialog = () => {
return () => {
eUnSubscribeEvent('updateDialog', open);
};
- });
+ },[]);
const format = (ver) => {
if (!ver) return ""
diff --git a/apps/mobile/src/components/VaultDialog/index.js b/apps/mobile/src/components/VaultDialog/index.js
index c1aa5c3db..0c909f78e 100644
--- a/apps/mobile/src/components/VaultDialog/index.js
+++ b/apps/mobile/src/components/VaultDialog/index.js
@@ -175,11 +175,12 @@ export class VaultDialog extends Component {
close = () => {
if (this.state.loading) {
- ToastEvent.show(
- 'Please wait and do not close the app.',
- 'success',
- 'local',
- );
+ ToastEvent.show({
+ title: this.state.title,
+ message: 'Please wait and do not close the app.',
+ type: 'success',
+ context: 'local',
+ });
return;
}
Navigation.setRoutesToUpdate([
@@ -213,18 +214,32 @@ export class VaultDialog extends Component {
if (this.state.loading) return;
if (!this.password) {
- ToastEvent.show('You must fill all the fields.', 'error', 'local');
+ ToastEvent.show({
+ title: 'Password not entered',
+ message: 'Enter a password for the vault and try again.',
+ type: 'error',
+ context: 'local',
+ });
return;
}
if (this.password && this.password.length < 3) {
- ToastEvent.show('Password too short', 'error', 'local');
+ ToastEvent.show({
+ title: 'Password too short',
+ message: 'Password must be longer than 3 characters.',
+ type: 'error',
+ context: 'local',
+ });
return;
}
if (!this.state.novault) {
if (this.password !== this.confirmPassword) {
- ToastEvent.show('Passwords do not match', 'error', 'local');
+ ToastEvent.show({
+ title: 'Passwords do not match',
+ type: 'error',
+ context: 'local',
+ });
this.setState({
passwordsDontMatch: true,
});
@@ -246,7 +261,11 @@ export class VaultDialog extends Component {
if (this.state.biometricUnlock) {
this._enrollFingerprint(this.newPassword);
}
- ToastEvent.show('Vault password changed', 'success');
+ ToastEvent.show({
+ title: 'Vault password updated',
+ type: 'success',
+ context: 'local',
+ });
this.close();
})
.catch((e) => {
@@ -254,12 +273,20 @@ export class VaultDialog extends Component {
loading: false,
});
if (e.message === db.vault.ERRORS.wrongPassword) {
- ToastEvent.show('Current password incorrect.', 'error', 'local');
+ ToastEvent.show({
+ title: 'Incorrect password',
+ type: 'error',
+ context: 'local',
+ });
}
});
} else if (this.state.locked) {
if (!this.password || this.password.trim() === 0) {
- ToastEvent.show('Password is invalid', 'error', 'local');
+ ToastEvent.show({
+ title: 'Incorrect password',
+ type: 'error',
+ context: 'local',
+ });
this.setState({
wrongPassword: true,
});
@@ -287,7 +314,11 @@ export class VaultDialog extends Component {
async _lockNote() {
if (!this.password || this.password.trim() === 0) {
- ToastEvent.show('Password is invalid', 'error', 'local');
+ ToastEvent.show({
+ title: 'Incorrect password',
+ type: 'error',
+ context: 'local',
+ });
return;
} else {
db.vault.add(this.state.note.id).then((e) => {
@@ -298,7 +329,11 @@ export class VaultDialog extends Component {
async _unlockNote() {
if (!this.password || this.password.trim() === 0) {
- ToastEvent.show('Password is invalid', 'error', 'local');
+ ToastEvent.show({
+ title: 'Incorrect password',
+ type: 'error',
+ context: 'local',
+ });
return;
}
if (this.state.permanant) {
@@ -349,7 +384,12 @@ export class VaultDialog extends Component {
loading: false,
});
eSendEvent('vaultUpdated');
- ToastEvent.show('Biometric unlocking enabled!', 'success');
+ ToastEvent.show({
+ title: 'Biometric unlocking enabled!',
+ message: 'Now you can unlock your notes with biometrics.',
+ type: 'success',
+ context: 'local',
+ });
this.close();
},
);
@@ -369,7 +409,11 @@ export class VaultDialog extends Component {
this.setState({
loading: false,
});
- ToastEvent.show('Note added to vault', 'success', 'local');
+ ToastEvent.show({
+ title: 'Note added to vault',
+ type: 'success',
+ context: 'local',
+ });
this.close();
} else {
eSendEvent('vaultUpdated');
@@ -412,7 +456,12 @@ export class VaultDialog extends Component {
text = `${note.title}\n \n ${text}`;
console.log(text, 'TEXT');
Clipboard.setString(text);
- ToastEvent.show('Note copied to clipboard', 'success', 'local');
+ Toast.show({
+ heading: 'Note copied',
+ type: 'success',
+ message: 'Note has been copied to clipboard!',
+ context: 'local',
+ });
this.close();
}
@@ -431,22 +480,35 @@ export class VaultDialog extends Component {
_takeErrorAction(e) {
if (e.message === db.vault.ERRORS.wrongPassword) {
- ToastEvent.show('Password is incorrect', 'error', 'local');
+ ToastEvent.show({
+ heading: 'Incorrect password',
+ type: 'error',
+ context: 'local',
+ });
+
this.setState({
wrongPassword: true,
});
return;
- } else {
- }
+ }
}
_revokeFingerprintAccess = async () => {
try {
await BiometricService.resetCredentials();
eSendEvent('vaultUpdated');
- ToastEvent.show('Biometrics access revoked!', 'success');
+ ToastEvent.show({
+ title: 'Biometric unlocking disabled!',
+ type: 'success',
+ context: 'local',
+ });
+
} catch (e) {
- ToastEvent.show(e.message, 'error', 'local');
+ ToastEvent.show({
+ title: e.message,
+ type: 'success',
+ context: 'local',
+ });
}
};
diff --git a/apps/mobile/src/services/Backup.js b/apps/mobile/src/services/Backup.js
index e8d331d32..8974e199c 100644
--- a/apps/mobile/src/services/Backup.js
+++ b/apps/mobile/src/services/Backup.js
@@ -13,11 +13,16 @@ async function run() {
if (Platform.OS === 'android') {
let granted = await storage.requestPermission();
if (!granted) {
- ToastEvent.show('Backup failed! Storage access was denied.');
+ ToastEvent.show({
+ heading: 'Cannot backup data',
+ message: 'You must provide phone storage access to backup data.',
+ type: 'error',
+ context: 'local',
+ });
return;
}
}
- RNFetchBlob = require('rn-fetch-blob').default
+ RNFetchBlob = require('rn-fetch-blob').default;
eSendEvent(eOpenProgressDialog, {
title: 'Backing up your data',
paragraph:
@@ -40,8 +45,14 @@ async function run() {
let path = await storage.checkAndCreateDir('backups/');
await RNFetchBlob.fs.createFile(path + backupName, backup, 'utf8');
await MMKV.setItem('backupDate', JSON.stringify(Date.now()));
- ToastEvent.show('Backup complete!', 'success');
-
+
+ ToastEvent.show({
+ heading: 'Backup successful',
+ message: 'Your backup is stored in Notesnook folder on your phone.',
+ type: 'success',
+ context: 'local',
+ });
+
eSendEvent(eOpenProgressDialog, {
title: 'Backup complete',
icon: 'cloud-upload',
@@ -70,7 +81,12 @@ async function run() {
}
} else {
eSendEvent(eCloseProgressDialog);
- ToastEvent.show('Backup failed!', 'success');
+ ToastEvent.show({
+ heading: 'Backup failed',
+ type: 'error',
+ context: 'local',
+ });
+
return null;
}
}
@@ -80,7 +96,7 @@ async function getLastBackupDate() {
}
async function checkBackupRequired(type) {
- if (type === "off") return;
+ if (type === 'off') return;
let now = Date.now();
let lastBackupDate = await getLastBackupDate();
if (!lastBackupDate || lastBackupDate === 'never') {
@@ -89,13 +105,13 @@ async function checkBackupRequired(type) {
lastBackupDate = parseInt(lastBackupDate);
if (type === 'daily' && lastBackupDate + MS_DAY < now) {
- console.log("daily")
+ console.log('daily');
return true;
} else if (type === 'weekly' && lastBackupDate + MS_WEEK < now) {
- console.log("weekly")
+ console.log('weekly');
return true;
} else {
- console.log("no need",lastBackupDate);
+ console.log('no need', lastBackupDate);
return false;
}
}
diff --git a/apps/mobile/src/services/BiometricService.js b/apps/mobile/src/services/BiometricService.js
index 02c05dcf0..997bd537c 100644
--- a/apps/mobile/src/services/BiometricService.js
+++ b/apps/mobile/src/services/BiometricService.js
@@ -13,10 +13,10 @@ const CRYPT_CONFIG = Platform.select({
async function isBiometryAvailable() {
try {
-
return await FingerprintScanner.isSensorAvailable();
} catch (e) {
- ToastEvent.show(e.message, 'error');
+ console.log(e, 'sensor not available');
+ //ToastEvent.show(e.message, 'error');
return false;
}
}
@@ -44,16 +44,16 @@ async function resetCredentials() {
}
async function hasInternetCredentials() {
- return await Keychain.hasInternetCredentials('nn_vault');
+ return await Keychain.hasInternetCredentials('nn_vault');
}
-async function getCredentials(title,description) {
+async function getCredentials(title, description) {
try {
await FingerprintScanner.authenticate(
Platform.select({
ios: {
fallbackEnabled: true,
- description:description,
+ description: description,
},
android: {
title: title,
@@ -66,15 +66,22 @@ async function getCredentials(title,description) {
FingerprintScanner.release();
return await Keychain.getInternetCredentials('nn_vault', CRYPT_CONFIG);
} catch (e) {
- console.log('failed');
- FingerprintScanner.release();
+ console.log('failed');
+ FingerprintScanner.release();
if (e.name === 'DeviceLocked') {
- ToastEvent.show(
- 'Authentication failed. Wait 30 seconds to try again.',
- 'error',
- );
+ ToastEvent.show({
+ heading: 'Biometrics authentication failed.',
+ message: 'Wait 30 seconds to try again.',
+ type: 'error',
+ context: 'local',
+ });
} else {
- ToastEvent.show('Authentication failed. Tap to try again.', 'error');
+ ToastEvent.show({
+ heading: 'Authentication failed.',
+ message: 'Tap to try again.',
+ type: 'error',
+ context: 'local',
+ });
}
return null;
}
@@ -87,5 +94,5 @@ export default {
resetCredentials,
getCredentials,
storeCredentials,
- hasInternetCredentials
+ hasInternetCredentials,
};
diff --git a/apps/mobile/src/services/Navigation.js b/apps/mobile/src/services/Navigation.js
index 5d066bbc8..f41da8726 100755
--- a/apps/mobile/src/services/Navigation.js
+++ b/apps/mobile/src/services/Navigation.js
@@ -7,6 +7,17 @@ import {eSendEvent} from './EventManager';
import SettingsService from './SettingsService';
let currentScreen = 'Notes';
+let homeLoaded = false;
+
+
+function getHomeLoaded() {
+ return homeLoaded;
+}
+
+function setHomeLoaded() {
+ homeLoaded(true);
+}
+
let headerState = {
heading: 'Notes',
color: null,
@@ -20,7 +31,7 @@ const routeNames = {
Notebook: 'Notebook',
NotesPage: 'NotesPage',
Tags: 'Tags',
- Favorites: 'favorites',
+ Favorites: 'Favorites',
Trash: 'Trash',
};
@@ -35,8 +46,9 @@ function getHeaderState() {
}
function clearRouteFromUpdates(routeName) {
- if (routesToUpdate.indexOf(routeName) === -1) {
- routesToUpdate = routesToUpdate.slice(routesToUpdate.indexOf(routeName), 1);
+ if (routesToUpdate.indexOf(routeName) !== -1) {
+ routesToUpdate = [...new Set(routesToUpdate)]
+ routesToUpdate.splice(routesToUpdate.indexOf(routeName), 1);
}
}
@@ -47,15 +59,20 @@ function routeNeedsUpdate(routeName, callback) {
}
}
+/**
+ *
+ * @param {array} routes
+ */
function setRoutesToUpdate(routes) {
console.log(currentScreen, "current");
if (routes.indexOf(currentScreen) > -1) {
console.log('updating screen', currentScreen);
if (
- currentScreen === routeNames.NotesPage &&
+ currentScreen === routeNames.NotesPage||
currentScreen === routeNames.Notebook
) {
+ console.log(currentScreen ,"CURRENT");
eSendEvent(
currentScreen === routeNames.NotesPage
? refreshNotesPage
@@ -64,12 +81,12 @@ function setRoutesToUpdate(routes) {
} else {
updateEvent({type: Actions[currentScreen.toUpperCase()]});
}
- routes = routes.slice(routes.indexOf(currentScreen), 1);
+ clearRouteFromUpdates(currentScreen);
+ routes.splice(routes.indexOf(currentScreen), 1);
}
+
routesToUpdate = routesToUpdate.concat(routes);
- routesToUpdate.filter(function (item, pos) {
- return routesToUpdate.indexOf(item) == pos;
- });
+ routesToUpdate = [...new Set(routesToUpdate)];
}
/**
@@ -108,7 +125,7 @@ function setHeaderState(name, params, item) {
headerState.verticalMenu = params.menu;
if (headerState) {
- eSendEvent('onHeaderStateChange', headerState);
+ eSendEvent('onHeaderStateChange', {...headerState});
}
}
@@ -122,8 +139,10 @@ function push(name, params, item) {
rootNavigatorRef.current?.dispatch(StackActions.push(name, params));
}
-function replace(...args) {
- rootNavigatorRef.current?.dispatch(StackActions.replace(...args));
+function replace(name, params, item) {
+ currentScreen = name;
+ setHeaderState(name, params, item);
+ rootNavigatorRef.current?.dispatch(StackActions.replace(name,params));
}
function popToTop() {
@@ -162,4 +181,6 @@ export default {
setRoutesToUpdate,
routeNeedsUpdate,
routeNames,
+ getHomeLoaded,
+ setHomeLoaded
};
diff --git a/apps/mobile/src/services/PremiumService.js b/apps/mobile/src/services/PremiumService.js
index 50b09aa20..bdc05c6fb 100644
--- a/apps/mobile/src/services/PremiumService.js
+++ b/apps/mobile/src/services/PremiumService.js
@@ -21,7 +21,6 @@ async function setPremiumStatus() {
} else {
premiumStatus = user.subscription.type;
updateEvent({type: Actions.PREMIUM, state: get()});
- console.log('updating user');
updateEvent({type: Actions.USER, user: user});
}
} catch (e) {
@@ -30,22 +29,21 @@ async function setPremiumStatus() {
}
function get() {
- return true /* (
+ return (
premiumStatus === 1 ||
premiumStatus === 2 ||
premiumStatus === 5 ||
premiumStatus === 6
- ); */
+ );
}
async function verify(callback, error) {
try {
- if (premiumStatus) {
+ if (!premiumStatus) {
if (error) {
error();
return;
}
-
eSendEvent(eOpenPremiumDialog);
return;
} else {
@@ -99,14 +97,13 @@ const onUserStatusCheck = async (type) => {
case CHECK_IDS.databaseSync:
message = null;
break;
-
}
if (message) {
eSendEvent(eShowGetPremium, message);
}
}
- return {type, result: true};
+ return {type, result: status};
};
const showVerifyEmailDialog = () => {
@@ -122,20 +119,32 @@ const showVerifyEmailDialog = () => {
lastEmailTime &&
Date.now() - JSON.parse(lastEmailTime) < 60000 * 10
) {
- ToastEvent.show(
- 'Please wait before requesting another email',
- 'error',
- 'local',
- );
+ ToastEvent.show({
+ heading: 'Please wait before requesting another email',
+ type: 'error',
+ context: 'local',
+ });
console.log('error');
return;
}
await db.user.sendVerificationEmail();
console.log('MAIN SENT');
await MMKV.setItem('lastEmailTime', JSON.stringify(Date.now()));
- ToastEvent.show('Verification email sent!', 'success', 'local');
+
+ ToastEvent.show({
+ heading: 'Verification email sent!',
+ message:
+ 'We have sent you an email confirmation link. Please check your email inbox to verify your account. If you cannot find the email, check your spam folder.',
+ type: 'success',
+ context: 'local',
+ });
} catch (e) {
- ToastEvent.show(e.message, 'error', 'local');
+ ToastEvent.show({
+ heading: 'Could not send email',
+ message: e.message,
+ type: 'error',
+ context: 'local',
+ });
//await MMKV.removeItem('lastEmailTime');
}
},
diff --git a/apps/mobile/src/services/Sync.js b/apps/mobile/src/services/Sync.js
index ad2992b9b..9bdd341ac 100644
--- a/apps/mobile/src/services/Sync.js
+++ b/apps/mobile/src/services/Sync.js
@@ -2,7 +2,7 @@ import {updateEvent} from '../components/DialogManager/recievers';
import {Actions} from '../provider/Actions';
import {db} from '../utils/DB';
import {eOpenLoginDialog} from '../utils/Events';
-import {eSendEvent, ToastEvent} from './EventManager';
+import {eSendEvent, ToastEvent, } from './EventManager';
const run = async (context = 'global') => {
updateEvent({
@@ -12,25 +12,34 @@ const run = async (context = 'global') => {
try {
await db.sync();
- ToastEvent.show('Sync Complete', 'success', context);
+ ToastEvent.show({
+ heading:"Sync complete",
+ type:"success",
+ message: "All your notes are encrypted and synced successfully!",
+ context: context,
+ });
} catch (e) {
+ console.log(e);
if (e.message === 'You need to login to sync.') {
- ToastEvent.show(
- e.message,
- 'error',
- context,
- 5000,
- () => {
+ ToastEvent.show({
+ heading:"Enable sync",
+ message: "Login to encrypt and sync notes.",
+ context: context,
+ func: () => {
eSendEvent(eOpenLoginDialog);
},
- 'Login',
- );
+ actionText: 'Login',
+ });
} else {
updateEvent({
type: Actions.SYNCING,
syncing: false,
});
- ToastEvent.show(e.message, 'error', context, 3000);
+ ToastEvent.show({
+ heading:"Sync failed",
+ message: e.message,
+ context: context,
+ });
}
} finally {
updateEvent({
diff --git a/apps/mobile/src/utils/Animations.js b/apps/mobile/src/utils/Animations.js
index 017e6efe6..874b7f723 100644
--- a/apps/mobile/src/utils/Animations.js
+++ b/apps/mobile/src/utils/Animations.js
@@ -66,7 +66,7 @@ export function exitEditorAnimation() {
export const AppScale = new Animated.Value(0.95);
export const AppBorders = new Animated.Value(10);
-export const ContainerScale = new Animated.Value(1);
+export const ContainerScale = new Animated.Value(0.95);
export const EditorScalee = new Animated.Value(1);
export const DrawerScale = new Animated.Value(0.95);
diff --git a/apps/mobile/src/utils/DB.js b/apps/mobile/src/utils/DB.js
index b6c685dbe..298affc12 100644
--- a/apps/mobile/src/utils/DB.js
+++ b/apps/mobile/src/utils/DB.js
@@ -12,9 +12,9 @@ export const db = new Database(
db.host( __DEV__ ? {
- API_HOST: 'http://192.168.10.7:5264',
- AUTH_HOST: 'http://192.168.10.7:8264',
- SSE_HOST: 'http://192.168.10.7:7264',
+ API_HOST: 'http://192.168.10.6:5264',
+ AUTH_HOST: 'http://192.168.10.6:8264',
+ SSE_HOST: 'http://192.168.10.6:7264',
} : {
API_HOST: 'https://api.notesnook.com',
AUTH_HOST: 'https://auth.streetwriters.co',
diff --git a/apps/mobile/src/utils/functions.js b/apps/mobile/src/utils/functions.js
index 53ad6e426..33a50b3ee 100644
--- a/apps/mobile/src/utils/functions.js
+++ b/apps/mobile/src/utils/functions.js
@@ -39,7 +39,10 @@ export const deleteItems = async (item) => {
Navigation.routeNames.Notebook,
]);
updateEvent({type: Actions.MENU_PINS});
- ToastEvent.show('Topics deleted', 'success');
+ ToastEvent.show({
+ heading: 'Topics deleted',
+ type: 'success',
+ });
}
if (notebooks?.length > 0) {
@@ -57,12 +60,10 @@ export const deleteItems = async (item) => {
let itemsCopy = [...history.selectedItemsList];
if (topics.length === 0 && (notes.length > 0 || notebooks.length > 0)) {
- ToastEvent.show(
- message,
- 'success',
- 'global',
- 6000,
- async () => {
+ ToastEvent.show({
+ heading: message,
+ type: 'success',
+ func: async () => {
let trash = db.trash;
let ids = [];
for (var i = 0; i < itemsCopy.length; i++) {
@@ -83,8 +84,8 @@ export const deleteItems = async (item) => {
updateEvent({type: Actions.MENU_PINS});
ToastEvent.hide();
},
- 'Undo',
- );
+ actionText: 'Undo',
+ });
}
Navigation.setRoutesToUpdate([Navigation.routeNames.Trash]);
updateEvent({type: Actions.CLEAR_SELECTION});
@@ -92,6 +93,8 @@ export const deleteItems = async (item) => {
updateEvent({type: Actions.SELECTION_MODE, enabled: false});
};
+
+
export const openLinkInBrowser = async (link, colors) => {
try {
const url = link;
diff --git a/apps/mobile/src/views/Editor/EditorHeader.js b/apps/mobile/src/views/Editor/EditorHeader.js
index 6aac6c956..433ea1cfe 100644
--- a/apps/mobile/src/views/Editor/EditorHeader.js
+++ b/apps/mobile/src/views/Editor/EditorHeader.js
@@ -69,7 +69,10 @@ const EditorHeader = () => {
});
if (checkNote() && isNotedEdited()) {
- ToastEvent.show('Note Saved!', 'success');
+ ToastEvent.show({
+ heading: 'Note Saved',
+ type: 'success',
+ });
}
await clearEditor();
Keyboard.removeListener('keyboardDidShow', () => {
diff --git a/apps/mobile/src/views/Editor/EditorRoot.js b/apps/mobile/src/views/Editor/EditorRoot.js
index bfc171534..fc0fdc7f9 100644
--- a/apps/mobile/src/views/Editor/EditorRoot.js
+++ b/apps/mobile/src/views/Editor/EditorRoot.js
@@ -117,7 +117,10 @@ const EditorRoot = () => {
});
if (checkNote() && isNotedEdited()) {
- ToastEvent.show('Note Saved!', 'success');
+ ToastEvent.show({
+ heading: 'Note Saved',
+ type: 'success',
+ });
}
await clearEditor();
Keyboard.removeListener('keyboardDidShow', () => {
diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.js
index c065d4932..f40d4a641 100644
--- a/apps/mobile/src/views/Editor/Functions.js
+++ b/apps/mobile/src/views/Editor/Functions.js
@@ -123,7 +123,7 @@ export function post(type, value = null) {
export const _onShouldStartLoadWithRequest = async (request) => {
if (request.url.includes('https')) {
openLinkInBrowser(request.url, appColors)
- .catch((e) => ToastEvent.show(e.message, 'error'))
+ .catch((e) => {})
.then((r) => {
console.log('closed');
});
@@ -201,6 +201,7 @@ export const loadNote = async (item) => {
sendNoteEditedEvent({
id: id,
});
+
if (webviewInit) {
await loadNoteInEditor();
} else {
@@ -298,6 +299,7 @@ export const _onMessage = async (evt) => {
webviewOK = true;
break;
case 'focus':
+ console.log('focus gained',message.value);
editing.focusType = message.value;
break;
case 'selectionchange':
@@ -326,6 +328,7 @@ export async function clearEditor() {
if (noteEdited && id) {
await saveNote(false);
}
+ editing.focusType = null;
updateEvent({type: Actions.CURRENT_EDITING_NOTE, id: null});
sendNoteEditedEvent({
id: id,
@@ -411,6 +414,7 @@ export async function saveNote() {
clearNote();
return;
}
+ console.log('saving note is called here')
let locked = id ? db.notes.note(id).data.locked : null;
let noteData = {
@@ -481,17 +485,18 @@ const loadNoteInEditor = async () => {
if (!webviewInit) return;
saveCounter = 0;
if (note?.id) {
+ console.log(content.data);
tiny.call(EditorWebView, tiny.setTitle(title));
intent = false;
tiny.call(EditorWebView, tiny.html(content.data));
- setColors();
+ setColors();
tiny.call(
EditorWebView,
- tiny.updateDateEdited(timeConverter(note.dateEdited)),
+ tiny.updateDateEdited(timeConverter(note.dateEdited)),
);
tiny.call(EditorWebView, tiny.updateSavingState('Saved'));
} else {
await restoreEditorState();
}
- tiny.call(EditorWebView, tiny.clearHistory);
+ tiny.call(EditorWebView, tiny.clearHistory);
};
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index e59c496e6..e1dbdc6ca 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -79,11 +79,15 @@ const Editor = React.memo(
<ScrollView
bounces={false}
bouncesZoom={false}
+ disableScrollViewPanResponder
+ keyboardDismissMode="none"
+ keyboardShouldPersistTaps="always"
showsVerticalScrollIndicator={false}
style={{
height: '100%',
width: '100%',
}}
+
nestedScrollEnabled
contentContainerStyle={{
width: '100%',
@@ -94,6 +98,7 @@ const Editor = React.memo(
testID={notesnook.ids.default.editor}
ref={EditorWebView}
onLoad={onLoad}
+ scrollEnabled={false}
onRenderProcessGone={(event) => {
onResetRequested();
}}
@@ -103,9 +108,8 @@ const Editor = React.memo(
injectedJavaScript={Platform.OS === 'ios' ? injectedJS : null}
onShouldStartLoadWithRequest={_onShouldStartLoadWithRequest}
cacheMode="LOAD_DEFAULT"
- cacheEnabled={false}
+ cacheEnabled={true}
domStorageEnabled={true}
- scrollEnabled={false}
bounces={false}
allowFileAccess={true}
scalesPageToFit={true}
diff --git a/apps/mobile/src/views/Editor/tiny/tiny.js b/apps/mobile/src/views/Editor/tiny/tiny.js
index 764c0331b..dba4d81c8 100644
--- a/apps/mobile/src/views/Editor/tiny/tiny.js
+++ b/apps/mobile/src/views/Editor/tiny/tiny.js
@@ -11,25 +11,12 @@ window.blur();
`;
export const keyboardStateChanged = `(() => {
- var range = editor.getSelection();
- if (range) {
- if (range.length == 0) {
- let correction = isTablet ? 215 : 60;
- setTimeout(() => {
- document.querySelector('.app-main').scrollTo({
- top:
- editor.getBounds(editor.getSelection().index).bottom -
- (window.innerHeight - correction),
- behavior: 'smooth',
- });
- }, 200);
- }
- }
+
})();
`;
const blur = `
document.activeElement.blur();
- window.blur();
+ window.blur();
`;
@@ -114,7 +101,16 @@ isLoading = true;
const html = (value) => `
isLoading = true;
+tinymce.activeEditor.mode.set("readonly")
tinymce.activeEditor.setContent(\`${value}\`);
+setTimeout(() => {
+ document.activeElement.blur();
+ window.blur();
+ tinymce.activeEditor.mode.set("design")
+ document.activeElement.blur();
+ window.blur();
+
+},300)
info.querySelector('#infowords').innerText =
tinymce.activeEditor.plugins.wordcount.getCount() + " words";
`;
diff --git a/apps/mobile/src/views/Editor/tiny/toolbar/constants.js b/apps/mobile/src/views/Editor/tiny/toolbar/constants.js
index 1caef3502..2390e1599 100644
--- a/apps/mobile/src/views/Editor/tiny/toolbar/constants.js
+++ b/apps/mobile/src/views/Editor/tiny/toolbar/constants.js
@@ -18,12 +18,12 @@ export function formatSelection(command) {
}
export function focusEditor(format) {
-
eSendEvent("showTooltip");
Platform.OS === 'android' && EditorWebView.current.requestFocus();
if (format === 'link' || format === 'video') {
tiny.call(EditorWebView, tiny.blur + ' ' + tiny.focusEditor);
} else {
+
tiny.call(EditorWebView, tiny.focusEditor);
}
}
diff --git a/apps/mobile/src/views/Editor/tiny/toolbar/index.js b/apps/mobile/src/views/Editor/tiny/toolbar/index.js
index 760e90ce5..9f54f1c98 100644
--- a/apps/mobile/src/views/Editor/tiny/toolbar/index.js
+++ b/apps/mobile/src/views/Editor/tiny/toolbar/index.js
@@ -1,12 +1,9 @@
-import React, {useEffect} from 'react';
-import {View} from 'react-native';
-import {ScrollView} from 'react-native';
-import {useTracked} from '../../../../provider';
-import {eSendEvent} from '../../../../services/EventManager';
-import { getElevation } from '../../../../utils';
+import React, { useEffect } from 'react';
+import { ScrollView, View } from 'react-native';
+import { useTracked } from '../../../../provider';
import { normalize } from '../../../../utils/SizeUtils';
-import {TOOLBAR_CONFIG} from './config';
-import {properties, toolbarRef} from './constants';
+import { TOOLBAR_CONFIG } from './config';
+import { properties, toolbarRef } from './constants';
import ToolbarGroup from './group';
import Tooltip from './tooltip';