Files
jitsi-meet/react/features/base/dialog/components/native/AlertDialog.tsx

57 lines
1.7 KiB
TypeScript
Raw Normal View History

2019-05-07 16:47:33 +02:00
import React from 'react';
import { WithTranslation } from 'react-i18next';
import Dialog from 'react-native-dialog';
import { connect } from 'react-redux';
2019-05-07 16:47:33 +02:00
import { translate } from '../../../i18n/functions';
2019-05-07 16:47:33 +02:00
import { _abstractMapStateToProps } from '../../functions';
import { renderHTML } from '../functions.native';
2019-05-07 16:47:33 +02:00
import AbstractDialog, { IProps as AbstractProps } from './AbstractDialog';
interface IProps extends AbstractProps, WithTranslation {
2019-05-07 16:47:33 +02:00
/**
* 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; };
}
2019-05-07 16:47:33 +02:00
/**
* Implements an alert dialog, to simply show an error or a message,
* then disappear on dismiss.
2019-05-07 16:47:33 +02:00
*/
class AlertDialog extends AbstractDialog<IProps> {
2019-05-07 16:47:33 +02:00
/**
* Implements React's {@link Component#render}.
2019-05-07 16:47:33 +02:00
*
* @inheritdoc
*/
override render() {
const { contentKey, t } = this.props;
2019-05-07 16:47:33 +02:00
const content
= typeof contentKey === 'string'
? t(contentKey)
: renderHTML(t(contentKey.key, contentKey.params));
2019-05-07 16:47:33 +02:00
return (
<Dialog.Container
coverScreen = { false }
visible = { true }>
<Dialog.Description>
{ content }
</Dialog.Description>
<Dialog.Button
label = { t('dialog.Ok') }
onPress = { this._onSubmit } />
</Dialog.Container>
2019-05-07 16:47:33 +02:00
);
}
}
export default translate(connect(_abstractMapStateToProps)(AlertDialog));