|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+// @flow
|
|
|
2
|
+
|
|
|
3
|
+import React from 'react';
|
|
|
4
|
+import { Text } from 'react-native';
|
|
|
5
|
+
|
|
|
6
|
+import { translate } from '../../../i18n';
|
|
|
7
|
+import { connect } from '../../../redux';
|
|
|
8
|
+
|
|
|
9
|
+import { _abstractMapStateToProps } from '../../functions';
|
|
|
10
|
+
|
|
|
11
|
+import { type Props as AbstractProps } from './BaseDialog';
|
|
|
12
|
+import BaseSubmitDialog from './BaseSubmitDialog';
|
|
|
13
|
+
|
|
|
14
|
+type Props = AbstractProps & {
|
|
|
15
|
+
|
|
|
16
|
+ /**
|
|
|
17
|
+ * Untranslated i18n key of the content to be displayed.
|
|
|
18
|
+ *
|
|
|
19
|
+ * NOTE: This dialog also adds support to Object type keys that will be
|
|
|
20
|
+ * translated using the provided params. See i18n function
|
|
|
21
|
+ * {@code translate(string, Object)} for more details.
|
|
|
22
|
+ */
|
|
|
23
|
+ contentKey: string | { key: string, params: Object},
|
|
|
24
|
+};
|
|
|
25
|
+
|
|
|
26
|
+/**
|
|
|
27
|
+ * Implements an alert dialog, to simply show an error or a message, then disappear on dismiss.
|
|
|
28
|
+ */
|
|
|
29
|
+class AlertDialog extends BaseSubmitDialog<Props, *> {
|
|
|
30
|
+ /**
|
|
|
31
|
+ * Implements {@code BaseSubmitDialog._renderSubmittable}.
|
|
|
32
|
+ *
|
|
|
33
|
+ * @inheritdoc
|
|
|
34
|
+ */
|
|
|
35
|
+ _renderSubmittable() {
|
|
|
36
|
+ const { _dialogStyles, contentKey, t } = this.props;
|
|
|
37
|
+ const content
|
|
|
38
|
+ = typeof contentKey === 'string'
|
|
|
39
|
+ ? t(contentKey)
|
|
|
40
|
+ : this._renderHTML(t(contentKey.key, contentKey.params));
|
|
|
41
|
+
|
|
|
42
|
+ return (
|
|
|
43
|
+ <Text style = { _dialogStyles.text }>
|
|
|
44
|
+ { content }
|
|
|
45
|
+ </Text>
|
|
|
46
|
+ );
|
|
|
47
|
+ }
|
|
|
48
|
+
|
|
|
49
|
+ _renderHTML: string => Object | string
|
|
|
50
|
+}
|
|
|
51
|
+
|
|
|
52
|
+export default translate(connect(_abstractMapStateToProps)(AlertDialog));
|