Skip to content

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

add a ProgressDialog

ammarahm-ede1ec23e970e3
diff --git a/apps/mobile/src/components/ProgressDialog/index.js b/apps/mobile/src/components/ProgressDialog/index.js
new file mode 100644
index 000000000..f9f6fecce
--- /dev/null
+++ b/apps/mobile/src/components/ProgressDialog/index.js
@@ -0,0 +1,65 @@
+import React, {useEffect, useState} from 'react';
+import {Text, View} from 'react-native';
+import {ph, SIZE, WEIGHT} from '../../common/common';
+import {useTracked} from '../../provider';
+import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/eventManager';
+import {eOpenProgressDialog, eCloseProgressDialog} from '../../services/events';
+import {getElevation} from '../../utils/utils';
+import BaseDialog from '../Dialog/base-dialog';
+import {Loading} from '../Loading';
+
+const ProgressDialog = () => {
+ const [state, dispatch] = useTracked();
+ const {colors, tags, premiumUser} = state;
+ const [visible, setVisible] = useState(false);
+ const [dialogData, setDialogData] = useState({
+ title: 'Loading',
+ paragraph: 'Loading tagline',
+ });
+ useEffect(() => {
+ eSubscribeEvent(eOpenProgressDialog, open);
+ eSubscribeEvent(eCloseProgressDialog, close);
+ return () => {
+ eUnSubscribeEvent(eOpenProgressDialog, open);
+ eUnSubscribeEvent(eCloseProgressDialog, close);
+ };
+ }, []);
+
+ const open = (data) => {
+ setDialogData(data);
+ setVisible(true);
+ };
+
+ const close = () => {
+ setVisible(false);
+ };
+
+ return (
+ <BaseDialog visible={visible} onRequestClose={close}>
+ <View
+ style={{
+ ...getElevation(5),
+ width: '80%',
+ maxHeight: 350,
+ borderRadius: 5,
+ backgroundColor: colors.bg,
+ paddingHorizontal: ph,
+ paddingVertical: 20,
+ }}>
+ <Loading height={40} tagline={dialogData.title} />
+ <Text
+ style={{
+ fontFamily: WEIGHT.regular,
+ alignSelf: 'center',
+ textAlign: 'center',
+ color: colors.icon,
+ fontSize: SIZE.xs,
+ }}>
+ {dialogData.paragraph}
+ </Text>
+ </View>
+ </BaseDialog>
+ );
+};
+
+export default ProgressDialog;