Skip to content

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

add export dialog

ammarahm-ed19c5b856c194
diff --git a/apps/mobile/src/components/ActionSheet/index.js b/apps/mobile/src/components/ActionSheet/index.js
index 1219424b7..cab98a0d2 100644
--- a/apps/mobile/src/components/ActionSheet/index.js
+++ b/apps/mobile/src/components/ActionSheet/index.js
@@ -1,6 +1,6 @@
import PropTypes from "prop-types";
import React, { Component, createRef } from "react";
-import { Animated, DeviceEventEmitter, Dimensions, FlatList, Keyboard, Modal, Platform, StatusBar, TextInput, TouchableOpacity, UIManager, View, ViewPropTypes } from "react-native";
+import { Animated, DeviceEventEmitter, Dimensions, FlatList, Keyboard, Modal, Platform, StatusBar, TextInput,findNodeHandle, TouchableOpacity, UIManager, View, ViewPropTypes } from "react-native";
import { styles } from "./styles";
var deviceHeight = getDeviceHeight();
@@ -375,9 +375,10 @@ export default class ActionSheet extends Component {
const { height: windowHeight } = Dimensions.get("window");
const currentlyFocusedField = TextInput.State.currentlyFocusedInput
- ? TextInput.State.currentlyFocusedInput()._nativeTag
+ ? findNodeHandle(TextInput?.State?.currentlyFocusedInput())?._nativeTag
: TextInput.State.currentlyFocusedField();
+ if (!currentlyFocusedField) return;
UIManager.measure(
currentlyFocusedField,
(originX, originY, width, height, pageX, pageY) => {
diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js
index f105c3e10..832040b35 100644
--- a/apps/mobile/src/components/ActionSheetComponent/index.js
+++ b/apps/mobile/src/components/ActionSheetComponent/index.js
@@ -28,7 +28,7 @@ import {ACTIONS} from '../../provider/actions';
import NavigationService from '../../services/NavigationService';
import {timeConverter, ToastEvent, DDS, db} from '../../utils/utils';
import {openVault, eSendEvent} from '../../services/eventManager';
-import {refreshNotesPage, eOpenPremiumDialog} from '../../services/events';
+import {refreshNotesPage, eOpenPremiumDialog, eOpenExportDialog} from '../../services/events';
import {PremiumTag} from '../Premium/PremiumTag';
import { MMKV } from '../../utils/storage';
@@ -226,7 +226,7 @@ export const ActionSheetComponent = ({
name: 'Export',
icon: 'export',
func: () => {
- close();
+ close('export')
},
},
{
diff --git a/apps/mobile/src/components/DialogManager/index.js b/apps/mobile/src/components/DialogManager/index.js
index a9a5e2aff..4e88dd4e0 100644
--- a/apps/mobile/src/components/DialogManager/index.js
+++ b/apps/mobile/src/components/DialogManager/index.js
@@ -21,7 +21,8 @@ import {
eOpenMoveNoteDialog,
eOpenSimpleDialog,
eOpenPremiumDialog,
- eClosePremiumDialog
+ eClosePremiumDialog,
+ eOpenExportDialog
} from '../../services/events';
import {DDS, hexToRGBA} from '../../utils/utils';
import ActionSheet from '../ActionSheet';
@@ -36,6 +37,7 @@ import {TEMPLATE_DELETE, TEMPLATE_PERMANANT_DELETE} from './templates';
import MoveNoteDialog from '../MoveNoteDialog';
import LoginDialog from '../LoginDialog';
import PremiumDialog from '../Premium/PremiumDialog';
+import ExportDialog from '../ExportDialog';
export class DialogManager extends Component {
constructor(props) {
@@ -256,6 +258,9 @@ export class DialogManager extends Component {
case "premium": {
eSendEvent(eOpenPremiumDialog);
}
+ case "export": {
+ eSendEvent(eOpenExportDialog,[this.state.item]);
+ }
}
}
this.show = null;
@@ -357,6 +362,8 @@ export class DialogManager extends Component {
<LoginDialog colors={colors} ref={ref => (this.loginDialog = ref)} />
<MergeEditor />
+
+ <ExportDialog/>
</>
);
}
diff --git a/apps/mobile/src/components/ExportDialog/index.js b/apps/mobile/src/components/ExportDialog/index.js
new file mode 100644
index 000000000..67ce302c3
--- /dev/null
+++ b/apps/mobile/src/components/ExportDialog/index.js
@@ -0,0 +1,201 @@
+import React, {useEffect, useState} from 'react';
+import {
+ Modal,
+ StyleSheet,
+ Text,
+ TouchableOpacity,
+ View,
+ Platform,
+} from 'react-native';
+import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
+import {opacity, ph, pv, SIZE, WEIGHT} from '../../common/common';
+import {useTracked} from '../../provider';
+import {DDS, getElevation, db} from '../../utils/utils';
+import {Loading} from '../Loading';
+const {
+ eSubscribeEvent,
+ eUnSubscribeEvent,
+} = require('../../services/eventManager');
+const {
+ eOpenExportDialog,
+ eCloseExportDialog,
+} = require('../../services/events');
+
+const ExportDialog = () => {
+ const [state, dispatch] = useTracked();
+ const {colors, tags, premiumUser} = state;
+ const [visible, setVisible] = useState(false);
+ const [notes, setNotes] = useState([]);
+ const [exporting, setExporting] = useState(false);
+ const [complete, setComplete] = useState(false);
+ useEffect(() => {
+ eSubscribeEvent(eOpenExportDialog, open);
+ eSubscribeEvent(eCloseExportDialog, close);
+
+ return () => {
+ eUnSubscribeEvent(eOpenExportDialog, open);
+ eUnSubscribeEvent(eCloseExportDialog, close);
+ };
+ }, []);
+
+ const open = (data) => {
+ setVisible(true);
+ setNotes(data);
+ };
+
+ const close = (data) => {
+
+
+ setComplete(false);
+ setExporting(false);
+ setNotes([]);
+ setVisible(false);
+ setNotes(data);
+ };
+
+ const actions = [
+ {
+ title: 'PDF',
+ func: () => {},
+ icon: 'file-pdf-box',
+ },
+ {
+ title: 'Markdown',
+ func: () => {},
+ icon: 'language-markdown',
+ },
+ {
+ title: 'Plain Text',
+ func: () => {},
+ icon: 'card-text',
+ },
+ {
+ title: 'HTML',
+ func: () => {},
+ icon: 'language-html5',
+ },
+ ];
+
+ return (
+ <Modal
+ visible={visible}
+ transparent={true}
+ animated
+ animationType="fade"
+ onRequestClose={close}>
+ <View style={styles.wrapper}>
+ <TouchableOpacity onPress={close} style={styles.overlay} />
+ <View
+ style={[
+ {
+ width: DDS.isTab ? '40%' : '80%',
+ backgroundColor: colors.bg,
+ },
+ styles.container,
+ ]}>
+ <View style={styles.headingContainer}>
+ <Icon name="export" color={colors.accent} size={SIZE.lg} />
+ <Text style={[{color: colors.accent}, styles.heading]}>
+ Export
+ {notes.length === 0 || notes.length === 1
+ ? ''
+ : ' ' + notes.length}{' '}
+ Note
+ </Text>
+ </View>
+
+ {exporting ? (
+ <Loading
+ done={complete}
+ doneText={`Note exported successfully! You can find exported notes in ${
+ Platform.OS === 'ios'
+ ? 'Files Manager/Notesnook'
+ : 'Phone Storage/Notesnook/Exported/'
+ }.`}
+ onDone={close}
+ tagline="Exporting notes..."
+ />
+ ) : (
+ <View style={styles.buttonContainer}>
+ {actions.map((item) => (
+ <TouchableOpacity
+ activeOpacity={opacity}
+ onPress={() => {
+ setExporting(true);
+ setTimeout(() => {
+ setComplete(true);
+ }, 1000);
+ }}
+ style={[
+ styles.button,
+ {
+ borderColor: colors.accent,
+ backgroundColor: colors.accent,
+ },
+ ]}>
+ <Icon name={item.icon} color="white" size={SIZE.lg} />
+ <Text style={styles.buttonText}>{item.title}</Text>
+ </TouchableOpacity>
+ ))}
+ </View>
+ )}
+ </View>
+ </View>
+ </Modal>
+ );
+};
+
+const styles = StyleSheet.create({
+ wrapper: {
+ width: '100%',
+ height: '100%',
+ backgroundColor: 'rgba(0,0,0,0.3)',
+ justifyContent: 'center',
+ alignItems: 'center',
+ },
+ container: {
+ ...getElevation(5),
+ maxHeight: 350,
+ borderRadius: 5,
+ paddingHorizontal: ph,
+ paddingVertical: pv,
+ },
+ headingContainer: {
+ flexDirection: 'row',
+ justifyContent: 'center',
+ alignItems: 'center',
+ },
+ buttonContainer: {
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ },
+ heading: {
+ fontFamily: WEIGHT.bold,
+ marginLeft: 5,
+ fontSize: SIZE.md,
+ },
+ button: {
+ paddingVertical: pv,
+ paddingHorizontal: ph,
+ marginTop: 10,
+ borderRadius: 5,
+ width: '100%',
+ justifyContent: 'center',
+ alignItems: 'center',
+ borderWidth: 1,
+ flexDirection: 'row',
+ },
+ buttonText: {
+ fontFamily: WEIGHT.medium,
+ color: 'white',
+ fontSize: SIZE.sm,
+ marginLeft: 5,
+ },
+ overlay: {
+ width: '100%',
+ height: '100%',
+ position: 'absolute',
+ },
+});
+
+export default ExportDialog;
diff --git a/apps/mobile/src/components/Loading/index.js b/apps/mobile/src/components/Loading/index.js
new file mode 100644
index 000000000..c98ea6729
--- /dev/null
+++ b/apps/mobile/src/components/Loading/index.js
@@ -0,0 +1,85 @@
+import React from 'react';
+import {
+ ActivityIndicator,
+ StyleSheet,
+ Text,
+ View,
+ TouchableOpacity,
+} from 'react-native';
+import {SIZE, pv, ph, WEIGHT, opacity} from '../../common/common';
+import {useTracked} from '../../provider';
+
+export const Loading = ({
+ height = 150,
+ tagline = 'Loading....',
+ done = false,
+ doneText = 'Action completed successfully!',
+ onDone = () => {},
+}) => {
+ const [state, dispatch] = useTracked();
+ const {colors, tags, premiumUser} = state;
+
+ return (
+ <View style={[{height: height}, styles.activityContainer]}>
+ {done ? (
+ <>
+ <Text
+ style={[
+ {color: colors.icon},
+ styles.activityText,
+ {fontSize: SIZE.xs},
+ ]}>
+ {doneText}
+ </Text>
+ <TouchableOpacity
+ activeOpacity={opacity}
+ onPress={onDone}
+ style={[
+ styles.button,
+ {
+ borderColor: colors.accent,
+ backgroundColor: colors.accent,
+ },
+ ]}>
+ <Text style={styles.buttonText}>Close</Text>
+ </TouchableOpacity>
+ </>
+ ) : (
+ <>
+ <ActivityIndicator color={colors.accent} />
+ <Text style={[{color: colors.pri}, styles.activityText]}>
+ {tagline}
+ </Text>
+ </>
+ )}
+ </View>
+ );
+};
+
+const styles = StyleSheet.create({
+ activityText: {
+ fontSize: SIZE.sm,
+ textAlign: 'center',
+ },
+ activityContainer: {
+ alignItems: 'center',
+ justifyContent: 'center',
+ },
+ button: {
+ paddingVertical: pv,
+ paddingHorizontal: ph,
+ marginTop: 10,
+ borderRadius: 5,
+ alignSelf: 'center',
+ width: '48%',
+ justifyContent: 'center',
+ alignItems: 'center',
+ borderWidth: 1,
+ flexDirection: 'row',
+ },
+ buttonText: {
+ fontFamily: WEIGHT.medium,
+ color: 'white',
+ fontSize: SIZE.sm,
+ },
+});
diff --git a/apps/mobile/src/components/Toast/index.js b/apps/mobile/src/components/Toast/index.js
index 54033a21a..38532ea4b 100644
--- a/apps/mobile/src/components/Toast/index.js
+++ b/apps/mobile/src/components/Toast/index.js
@@ -1,38 +1,29 @@
import React, {useEffect, useState} from 'react';
import {Keyboard, Text, TouchableOpacity} from 'react-native';
-import * as Animatable from 'react-native-animatable';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import {normalize, opacity, ph, pv, SIZE, WEIGHT} from '../../common/common';
-import {useTracked} from '../../provider';
-import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/eventManager';
-import {eHideToast, eShowToast} from '../../services/events';
-import {DDS, w, getElevation} from '../../utils/utils';
+import Animated, {Easing, useValue} from 'react-native-reanimated';
+import {getElevation} from '../../utils/utils';
+import {eShowToast, eHideToast} from '../../services/events';
+import {eUnSubscribeEvent, eSubscribeEvent} from '../../services/eventManager';
+import { useTracked } from '../../provider';
-const AnimatedTouchableOpacity = Animatable.createAnimatableComponent(
+const {spring, timing} = Animated;
+const AnimatedTouchableOpacity = Animated.createAnimatedComponent(
TouchableOpacity,
);
export const Toast = ({context = 'global'}) => {
const [state, dispatch] = useTracked();
- const {colors} = state;
- const [toast, setToast] = useState(false);
+ const colors = state.colors;
const [keyboard, setKeyboard] = useState(false);
- const [message, setMessage] = useState([]);
const [data, setData] = useState([]);
const [toastStyle, setToastStyle] = useState({
backgroundColor: colors.errorBg,
color: colors.errorText,
});
- const showToastFunc = data => {
- setData(data);
-
- if (data.context === context) {
- setToast(true);
- }
- if (data.message) {
- setMessage(data.message);
- }
+ let toastTranslate = useValue(300);
+ const showToastFunc = (data) => {
+ setData(data);
if (data.type === 'success') {
setToastStyle({
backgroundColor: colors.successBg,
@@ -46,13 +37,23 @@ export const Toast = ({context = 'global'}) => {
}
setTimeout(() => {
- setToast(false);
+ timing(toastTranslate, {
+ toValue: 0,
+ duration: 500,
+ easing: Easing.elastic(1.1),
+ }).start();
+ }, 100);
+
+ setTimeout(() => {
+ timing(toastTranslate, {
+ toValue: 300,
+ duration: 200,
+ easing: Easing.inOut(Easing.ease),
+ }).start();
}, data.duration);
};
- const hideToastFunc = data => {
- setToast(false);
- };
+ const hideToastFunc = (data) => {};
const _onKeyboardShow = () => {
setKeyboard(true);
@@ -78,11 +79,7 @@ export const Toast = ({context = 'global'}) => {
}, []);
return (
- <Animatable.View
- transition={['translateY', 'opacity']}
- duration={0}
- delay={toast? 0 :300}
- useNativeDriver={true}
+ <Animated.View
style={{
width: '100%',
alignItems: 'center',
@@ -93,26 +90,20 @@ export const Toast = ({context = 'global'}) => {
elevation: 15,
transform: [
{
- translateY: toast ? 0 : 300,
+ translateY: toastTranslate,
},
],
}}>
<AnimatedTouchableOpacity
- activeOpacity={1}
- transition={['opacity']}
- duration={300}
- useNativeDriver={true}
- delay={!toast? 0 : 150}
style={{
...getElevation(5),
...toastStyle,
- maxWidth: DDS.isTab ? normalize(350) : w - 24,
- minWidth: DDS.isTab ? normalize(250) : w / 2,
+ maxWidth: '95%',
+ minWidth: '50%',
alignSelf: 'center',
borderRadius: 5,
- paddingHorizontal: ph,
- paddingVertical: pv,
- opacity: toast ? 1 : 0,
+ paddingHorizontal: 15,
+ paddingVertical: 10,
justifyContent: 'center',
flexDirection: 'row',
alignItems: 'center',
@@ -121,33 +112,22 @@ export const Toast = ({context = 'global'}) => {
style={{
...toastStyle,
backgroundColor: 'transparent',
- fontFamily: WEIGHT.regular,
- fontSize: SIZE.sm,
+ fontSize: 16,
+ textAlign: 'center',
}}>
- <Icon
- name={
- toastStyle.color === colors.errorText
- ? 'alert-circle-outline'
- : 'check-circle-outline'
- }
- color={toastStyle.color}
- size={SIZE.sm}
- />
- {' '}
- {message}
+ {data.message}
</Text>
<TouchableOpacity activeOpacity={1}>
<Text
style={{
...toastStyle,
- fontFamily: WEIGHT.bold,
- fontSize: SIZE.sm,
+ fontSize: 16,
}}>
{data.actionText}
</Text>
</TouchableOpacity>
</AnimatedTouchableOpacity>
- </Animatable.View>
+ </Animated.View>
);
};
diff --git a/apps/mobile/src/services/events.js b/apps/mobile/src/services/events.js
index b4dbb9327..8950b6ae1 100644
--- a/apps/mobile/src/services/events.js
+++ b/apps/mobile/src/services/events.js
@@ -82,4 +82,7 @@ export const eOpenPremiumDialog = '540'
export const eClosePremiumDialog = '541'
-export const eResetApp = '542'
\ No newline at end of file
+export const eResetApp = '542'
+
+export const eOpenExportDialog = '543';
+export const eCloseExportDialog = '544';
\ No newline at end of file
diff --git a/apps/mobile/src/utils/animations.js b/apps/mobile/src/utils/animations.js
index 396f741a2..08a8568e5 100644
--- a/apps/mobile/src/utils/animations.js
+++ b/apps/mobile/src/utils/animations.js
@@ -20,19 +20,19 @@ export function openEditorAnimation() {
setTimeout(() => {
timing(EditorScale, {
- duration: 150,
+ duration: 300,
toValue: 1,
- easing: Easing.in(Easing.linear),
+ easing: Easing.out(Easing.ease),
}).start();
timing(EditorTranslateY, {
- duration: 150,
+ duration: 300,
toValue: 0,
- easing: Easing.in(Easing.linear),
+ easing: Easing.out(Easing.ease),
}).start();
timing(EditorOpacity, {
- duration: 150,
+ duration: 300,
toValue: 1,
- easing: Easing.in(Easing.linear),
+ easing: Easing.out(Easing.ease),
}).start();
}, 10);
}
@@ -48,7 +48,7 @@ export function exitEditorAnimation() {
EditorPosition.setValue(Dimensions.get('window').width * 1.5);
}, 250);
timing(EditorOpacity, {
- duration: 150,
+ duration: 300,
toValue: 0,
easing: Easing.in(Easing.linear),
}).start();
@@ -65,8 +65,6 @@ export function exitEditorAnimation() {
},20)
-
-
}
export const slideRight = {
diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js
index e5a95b23f..857dab049 100755
--- a/apps/mobile/src/views/Home/index.js
+++ b/apps/mobile/src/views/Home/index.js
@@ -55,15 +55,14 @@ export const Home = ({route, navigation}) => {
state: {
bottomButtonText: 'Create a new note',
bottomButtonOnPress: async () => {
- let res = await RNHTMLtoPDF.convert({
+ /* let res = await RNHTMLtoPDF.convert({
html: '<h1>Custom converted PDF Document</h1>',
fileName: 'test',
base64: false,
directory:"Documents"
});
- console.log(res);
- return;
+ console.log(res); */
if (DDS.isTab) {
eSendEvent(eOnLoadNote, {type: 'new'});
} else {