| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 | // @flow
import React from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
import { translate } from '../../../base/i18n';
import { Icon, IconClose } from '../../../base/icons';
import AbstractNotification, {
    type Props
} from '../AbstractNotification';
import styles from './styles';
/**
 * Implements a React {@link Component} to display a notification.
 *
 * @extends Component
 */
class Notification extends AbstractNotification<Props> {
    /**
     * Implements React's {@link Component#render()}.
     *
     * @inheritdoc
     * @returns {ReactElement}
     */
    render() {
        const {
            isDismissAllowed
        } = this.props;
        return (
            <View
                pointerEvents = 'box-none'
                style = { styles.notification }>
                <View style = { styles.contentColumn }>
                    <View
                        pointerEvents = 'box-none'
                        style = { styles.notificationContent }>
                        {
                            this._renderContent()
                        }
                    </View>
                </View>
                {
                    isDismissAllowed
                    && <TouchableOpacity onPress = { this._onDismissed }>
                        <Icon
                            src = { IconClose }
                            style = { styles.dismissIcon } />
                    </TouchableOpacity>
                }
            </View>
        );
    }
    /**
     * Renders the notification's content. If the title or title key is present
     * it will be just the title. Otherwise it will fallback to description.
     *
     * @returns {Array<ReactElement>}
     * @private
     */
    _renderContent() {
        const { t, title, titleArguments, titleKey } = this.props;
        const titleText = title || (titleKey && t(titleKey, titleArguments));
        const description = this._getDescription();
        if (description && description.length) {
            return description.map((line, index) => (
                <Text
                    key = { index }
                    numberOfLines = { 1 }
                    style = { styles.contentText }>
                    { line }
                </Text>
            ));
        }
        return (
            <Text
                numberOfLines = { 1 }
                style = { styles.contentText } >
                { titleText }
            </Text>
        );
    }
    _getDescription: () => Array<string>;
    _onDismissed: () => void;
}
export default translate(Notification);
 |