Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

rn: add generic alert dialog

Bettenbuk Zoltan7e9df74e6098
diff --git a/react/features/base/dialog/components/native/AlertDialog.js b/react/features/base/dialog/components/native/AlertDialog.js
new file mode 100644
index 0000000000..50432514af
--- /dev/null
+++ b/react/features/base/dialog/components/native/AlertDialog.js
@@ -0,0 +1,52 @@
+// @flow
+
+import React from 'react';
+import { Text } from 'react-native';
+
+import { translate } from '../../../i18n';
+import { connect } from '../../../redux';
+
+import { _abstractMapStateToProps } from '../../functions';
+
+import { type Props as AbstractProps } from './BaseDialog';
+import BaseSubmitDialog from './BaseSubmitDialog';
+
+type Props = AbstractProps & {
+
+ /**
+ * Untranslated i18n key of the content to be displayed.
+ *
+ * NOTE: This dialog also adds support to Object type keys that will be
+ * translated using the provided params. See i18n function
+ * {@code translate(string, Object)} for more details.
+ */
+ contentKey: string | { key: string, params: Object},
+};
+
+/**
+ * Implements an alert dialog, to simply show an error or a message, then disappear on dismiss.
+ */
+class AlertDialog extends BaseSubmitDialog<Props, *> {
+ /**
+ * Implements {@code BaseSubmitDialog._renderSubmittable}.
+ *
+ * @inheritdoc
+ */
+ _renderSubmittable() {
+ const { _dialogStyles, contentKey, t } = this.props;
+ const content
+ = typeof contentKey === 'string'
+ ? t(contentKey)
+ : this._renderHTML(t(contentKey.key, contentKey.params));
+
+ return (
+ <Text style = { _dialogStyles.text }>
+ { content }
+ </Text>
+ );
+ }
+
+ _renderHTML: string => Object | string
+}
+
+export default translate(connect(_abstractMapStateToProps)(AlertDialog));
diff --git a/react/features/base/dialog/components/native/index.js b/react/features/base/dialog/components/native/index.js
index a57c369bd8..aabd917c03 100644
--- a/react/features/base/dialog/components/native/index.js
+++ b/react/features/base/dialog/components/native/index.js
@@ -4,6 +4,7 @@ export { default as BottomSheet } from './BottomSheet';
export { default as ConfirmDialog } from './ConfirmDialog';
export { default as CustomDialog } from './CustomDialog';
export { default as DialogContainer } from './DialogContainer';
+export { default as AlertDialog } from './AlertDialog';
export { default as InputDialog } from './InputDialog';
export { default as CustomSubmitDialog } from './CustomSubmitDialog';