diff --git a/apps/mobile/src/components/AddTopicDialog/index.js b/apps/mobile/src/components/AddTopicDialog/index.js
index 137a63b6f..10ccc036f 100644
--- a/apps/mobile/src/components/AddTopicDialog/index.js
+++ b/apps/mobile/src/components/AddTopicDialog/index.js
@@ -8,6 +8,9 @@ import {eSendEvent} from '../../services/eventManager';
import {eOnNewTopicAdded} from '../../services/events';
import {Toast} from '../Toast';
import {Button} from '../Button';
+import BaseDialog from '../Dialog/base-dialog';
+import DialogHeader from '../Dialog/dialog-header';
+import DialogButtons from '../Dialog/dialog-buttons';
export class AddTopicDialog extends React.Component {
constructor(props) {
@@ -31,7 +34,7 @@ export class AddTopicDialog extends React.Component {
} else {
let topic = this.props.toEdit;
topic.title = this.title;
-
+
await db.notebooks.notebook(topic.notebookId).topics.add(topic);
}
this.close();
@@ -44,6 +47,7 @@ export class AddTopicDialog extends React.Component {
});
}
close() {
+ refs = [];
this.title = null;
this.setState({
visible: false,
@@ -55,116 +59,66 @@ export class AddTopicDialog extends React.Component {
const {colors, toEdit} = this.props;
return (
- {
this.titleRef.current?.focus();
}}
- onRequestClose={() => {
- refs = [];
- this.close();
- }}>
+ visible={visible}
+ onRequestClose={this.close}>
- this.close()}
- style={{
- width: '100%',
- height: '100%',
- position: 'absolute',
- }}
+
-
-
-
-
- {toEdit ? 'Edit Topic' : 'Add New Topic'}
-
-
+ borderRadius: 5,
+ fontSize: SIZE.sm,
+ fontFamily: WEIGHT.regular,
+ color: colors.pri,
+ marginTop: 20,
+ }}
+ onFocus={() => {
+ this.setState({
+ titleFocused: true,
+ });
+ }}
+ onBlur={() => {
+ this.setState({
+ titleFocused: true,
+ });
+ }}
+ defaultValue={toEdit ? toEdit.title : null}
+ onChangeText={(value) => {
+ this.title = value;
+ }}
+ placeholder="Enter title of topic"
+ placeholderTextColor={colors.icon}
+ />
- {
- this.setState({
- titleFocused: true,
- });
- }}
- onBlur={() => {
- this.setState({
- titleFocused: true,
- });
- }}
- defaultValue={toEdit ? toEdit.title : null}
- onChangeText={(value) => {
- this.title = value;
- }}
- placeholder="Enter title of topic"
- placeholderTextColor={colors.icon}
- />
-
-
-
-
+
-
+
);
}
}
diff --git a/apps/mobile/src/components/Dialog/BaseDialog.js b/apps/mobile/src/components/Dialog/BaseDialog.js
new file mode 100644
index 000000000..fa8fdb106
--- /dev/null
+++ b/apps/mobile/src/components/Dialog/BaseDialog.js
@@ -0,0 +1,49 @@
+import React from 'react';
+import {Modal, StyleSheet, TouchableOpacity, View} from 'react-native';
+import {useTracked} from '../../provider';
+
+const BaseDialog = ({visible, onRequestClose, children, onShow}) => {
+ const [state, dispatch] = useTracked();
+ return (
+
+
+
+ {children}
+
+
+ );
+};
+
+const styles = StyleSheet.create({
+ backdrop: {
+ width: '100%',
+ height: '100%',
+ justifyContent: 'center',
+ alignItems: 'center',
+ },
+ overlayButton: {
+ width: '100%',
+ height: '100%',
+ position: 'absolute',
+ },
+});
+
+export default BaseDialog;
diff --git a/apps/mobile/src/components/Dialog/DialogButtons.js b/apps/mobile/src/components/Dialog/DialogButtons.js
new file mode 100644
index 000000000..13cb4c1c7
--- /dev/null
+++ b/apps/mobile/src/components/Dialog/DialogButtons.js
@@ -0,0 +1,31 @@
+import React from 'react';
+import {StyleSheet, Text, View} from 'react-native';
+import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
+import {useTracked} from '../../provider';
+import {Button} from '../Button';
+
+const DialogButtons = ({
+ onPressPositive,
+ onPressNegative,
+ positiveTitle,
+ negativeTitle = 'Cancel',
+}) => {
+ return (
+
+
+
+
+ );
+};
+
+export default DialogButtons;
+
+const styles = StyleSheet.create({
+ container:{
+ justifyContent: 'space-around',
+ alignItems: 'center',
+ flexDirection: 'row',
+ marginTop: 20,
+ }
+})
diff --git a/apps/mobile/src/components/Dialog/DialogHeader.js b/apps/mobile/src/components/Dialog/DialogHeader.js
new file mode 100644
index 000000000..25d12245e
--- /dev/null
+++ b/apps/mobile/src/components/Dialog/DialogHeader.js
@@ -0,0 +1,31 @@
+import React from 'react';
+import {Text, View} from 'react-native';
+import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
+import {useTracked} from '../../provider';
+
+const DialogHeader = ({icon, title}) => {
+ const [state, dispatch] = useTracked();
+ const colors = state.colors;
+
+ return (
+
+ {icon ? : null}
+
+ {title}
+
+
+ );
+};
+
+export default DialogHeader
diff --git a/apps/mobile/src/components/Dialog/index.js b/apps/mobile/src/components/Dialog/index.js
index 2f8b9b247..edae460a8 100644
--- a/apps/mobile/src/components/Dialog/index.js
+++ b/apps/mobile/src/components/Dialog/index.js
@@ -1,20 +1,22 @@
import React, {Component} from 'react';
import {Modal, Text, TouchableOpacity, View} from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import {opacity, ph, pv, SIZE, WEIGHT} from '../../common/common';
+import {ph, pv, SIZE, WEIGHT} from '../../common/common';
import {ACTIONS} from '../../provider/actions';
import {eSendEvent} from '../../services/eventManager';
import {
+ eApplyChanges,
eClearEditor,
eCloseFullscreenEditor,
+ eOnLoadNote,
eOnNewTopicAdded,
- eApplyChanges, eOnLoadNote
} from '../../services/events';
import NavigationService from '../../services/NavigationService';
import {db, DDS, getElevation, history, ToastEvent} from '../../utils/utils';
+import {Button} from '../Button';
import {dialogActions} from '../DialogManager/dialogActions';
import {updateEvent} from '../DialogManager/recievers';
-import {Button} from '../Button';
+import BaseDialog from './base-dialog';
export class Dialog extends Component {
constructor(props) {
@@ -134,7 +136,7 @@ export class Dialog extends Component {
break;
}
case dialogActions.ACTION_NEW_NOTE: {
- eSendEvent(eOnLoadNote, {type:"new"});
+ eSendEvent(eOnLoadNote, {type: 'new'});
this.hide();
break;
}
@@ -205,93 +207,70 @@ export class Dialog extends Component {
const {title, paragraph, positiveText, negativeText, icon} = template;
const {visible} = this.state;
return (
- this.setState({visible: false})}>
+
-
-
- {icon ? (
-
- ) : null}
-
- {template.noTitle ? null : (
-
- {title}
-
- )}
-
-
- {paragraph ? (
-
- {this.state.selectedItemsLength > 0
- ? 'Delete ' +
- this.state.selectedItemsLength +
- ' selected items?'
- : paragraph}
-
+ {icon ? (
+
) : null}
- {template.noButtons ? null : (
-
-
-
-
+ {title}
+
)}
+
+ {paragraph ? (
+
+ {this.state.selectedItemsLength > 0
+ ? 'Delete ' +
+ this.state.selectedItemsLength +
+ ' selected items?'
+ : paragraph}
+
+ ) : null}
+
+ {template.noButtons ? null : (
+
+
+
+
+ )}
-
+
);
}
}
diff --git a/apps/mobile/src/components/ExportDialog/index.js b/apps/mobile/src/components/ExportDialog/index.js
index 554f90c05..d004560d7 100644
--- a/apps/mobile/src/components/ExportDialog/index.js
+++ b/apps/mobile/src/components/ExportDialog/index.js
@@ -14,6 +14,8 @@ import {useTracked} from '../../provider';
import storage from '../../utils/storage';
import {DDS, getElevation, ToastEvent} from '../../utils/utils';
import {Button} from '../Button/index';
+import BaseDialog from '../Dialog/base-dialog';
+import DialogHeader from '../Dialog/dialog-header';
import {Loading} from '../Loading';
import Seperator from '../Seperator';
@@ -112,94 +114,70 @@ const ExportDialog = () => {
];
return (
-
-
-
-
-
-
-
- Export
- {notes.length === 0 || notes.length === 1
- ? ''
- : ' ' + notes.length}{' '}
- Note
-
-
+
+
+
-
- {exporting ? (
- {
- FileViewer.open(result.filePath, {
- showOpenWithDialog: true,
- showAppsSuggestions: true,
- }).catch((e) => {
- console.log(e);
- ToastEvent.show(
- `No application found to open ${result.name} file`,
- );
- });
- close();
- }}
- tagline="Exporting notes"
- />
- ) : (
- <>
-
- Export your note in any of the following formats.
-
-
- {actions.map((item) => (
-
-
-
-
- ))}
-
- >
- )}
-
+
+ {exporting ? (
+ {
+ FileViewer.open(result.filePath, {
+ showOpenWithDialog: true,
+ showAppsSuggestions: true,
+ }).catch((e) => {
+ console.log(e);
+ ToastEvent.show(
+ `No application found to open ${result.name} file`,
+ );
+ });
+ close();
+ }}
+ tagline="Exporting notes"
+ />
+ ) : (
+ <>
+
+ Export your note in any of the following formats.
+
+
+ {actions.map((item) => (
+
+
+
+
+ ))}
+
+ >
+ )}
-
+
);
};
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,
@@ -207,20 +185,10 @@ const styles = StyleSheet.create({
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,
diff --git a/apps/mobile/src/components/VaultDialog/index.js b/apps/mobile/src/components/VaultDialog/index.js
index 4094b040d..f55aab84b 100644
--- a/apps/mobile/src/components/VaultDialog/index.js
+++ b/apps/mobile/src/components/VaultDialog/index.js
@@ -19,6 +19,9 @@ import {
import {openEditorAnimation} from '../../utils/animations';
import {db, DDS, getElevation, ToastEvent} from '../../utils/utils';
import {Button} from '../Button/index';
+import BaseDialog from '../Dialog/base-dialog';
+import DialogButtons from '../Dialog/dialog-buttons';
+import DialogHeader from '../Dialog/dialog-header';
import {updateEvent} from '../DialogManager/recievers';
import {Toast} from '../Toast';
const passInputRef = createRef();
@@ -251,98 +254,100 @@ export class VaultDialog extends Component {
} = this.state;
return (
- {
passInputRef.current?.focus();
}}
- visible={visible}
- transparent={true}
- onRequestClose={this.close}>
+ onRequestClose={this.close}
+ visible={visible}>
-
-
-
-
- {!novault
- ? 'Create vault'
- : note.locked
- ? this.state.deleteNote
- ? 'Delete note'
- : this.state.share
- ? 'Share note'
- : this.state.goToEditor
- ? 'Unlock note'
- : 'Unlock note'
- : 'Lock note'}
-
-
-
-
- {!novault
- ? 'Set a password to create vault'
- : permanant
- ? 'Enter password to remove note from vault.'
+
+ ? 'Unlock note'
+ : 'Unlock note'
+ : 'Lock note'
+ }
+ icon="shield"
+ />
- {note.locked || locked || permanant ? (
+
+ {!novault
+ ? 'Set a password to create vault'
+ : permanant
+ ? 'Enter password to remove note from vault.'
+ : note.locked
+ ? this.state.deleteNote
+ ? 'Unlock note to delete it.'
+ : this.state.share
+ ? 'Unlock note to share it.'
+ : this.state.goToEditor
+ ? 'Unlock note to open it in editor'
+ : 'Enter vault password to unlock note.'
+ : 'Enter vault password to lock note.'}
+
+
+ {note.locked || locked || permanant ? (
+ {
+ this.password = value;
+ }}
+ secureTextEntry
+ placeholder="Password"
+ placeholderTextColor={colors.icon}
+ />
+ ) : null}
+
+ {!novault ? (
+
- ) : null}
- {!novault ? (
-
- {
- this.password = value;
- }}
- secureTextEntry
- placeholder="Password"
- placeholderTextColor={colors.icon}
- />
-
- {
- this.confirmPassword = value;
- if (value !== this.password) {
- this.setState({
- passwordsDontMatch: true,
- });
- } else {
- this.setState({
- passwordsDontMatch: false,
- });
- }
- }}
- placeholder="Confirm password"
- placeholderTextColor={colors.icon}
- />
-
- ) : null}
-
-
-
-
- {
+ this.confirmPassword = value;
+ if (value !== this.password) {
+ this.setState({
+ passwordsDontMatch: true,
+ });
+ } else {
+ this.setState({
+ passwordsDontMatch: false,
+ });
+ }
+ }}
+ placeholder="Confirm password"
+ placeholderTextColor={colors.icon}
/>
-
+ ) : null}
+
+
-
+
);
}
}
diff --git a/apps/mobile/src/utils/animations.js b/apps/mobile/src/utils/animations.js
index 42e74c090..223b43dae 100644
--- a/apps/mobile/src/utils/animations.js
+++ b/apps/mobile/src/utils/animations.js
@@ -7,7 +7,9 @@ const {color, Value, timing} = Animated;
export const EditorPosition = new Value(Dimensions.get('window').width * 1.5);
export const EditorScale = new Value(1);
export const EditorOpacity = new Value(0);
-export const EditorTranslateY = new Value(Dimensions.get('window').height * 0.75);
+export const EditorTranslateY = new Value(
+ Dimensions.get('window').height * 0.75,
+);
export function openEditorAnimation() {
EditorPosition.setValue(Dimensions.get('window').width * 1.5);
@@ -18,17 +20,16 @@ export function openEditorAnimation() {
EditorPosition.setValue(0);
- timing(EditorTranslateY, {
- duration: 200,
- toValue: 0,
- easing: Easing.out(Easing.ease),
- }).start();
- timing(EditorOpacity, {
- duration: 150,
- toValue: 1,
- easing: Easing.out(Easing.ease),
- }).start();
-
+ timing(EditorTranslateY, {
+ duration: 200,
+ toValue: 0,
+ easing: Easing.out(Easing.ease),
+ }).start();
+ timing(EditorOpacity, {
+ duration: 150,
+ toValue: 1,
+ easing: Easing.out(Easing.ease),
+ }).start();
}
export function exitEditorAnimation() {
@@ -37,21 +38,18 @@ export function exitEditorAnimation() {
EditorTranslateY.setValue(0);
editing.currentlyEditing = false;
- timing(EditorOpacity, {
- duration: 150,
- toValue: 0,
- easing: Easing.inOut(Easing.ease),
- }).start(() => {
- EditorPosition.setValue(Dimensions.get('window').width * 1.5);
- });
- timing(EditorTranslateY, {
- duration: 200,
- toValue: Dimensions.get('window').height * 0.75,
- easing: Easing.inOut(Easing.ease),
- }).start();
-
-
-
+ timing(EditorOpacity, {
+ duration: 150,
+ toValue: 0,
+ easing: Easing.inOut(Easing.ease),
+ }).start(() => {
+ EditorPosition.setValue(Dimensions.get('window').width * 1.5);
+ });
+ timing(EditorTranslateY, {
+ duration: 200,
+ toValue: Dimensions.get('window').height * 0.75,
+ easing: Easing.inOut(Easing.ease),
+ }).start();
}
export const slideRight = {