您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

NotificationsContainer.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // @flow
  2. import React from 'react';
  3. import { View } from 'react-native';
  4. import { connect } from '../../../base/redux';
  5. import AbstractNotificationsContainer, {
  6. _abstractMapStateToProps,
  7. type Props as AbstractProps
  8. } from '../AbstractNotificationsContainer';
  9. import Notification from './Notification';
  10. import styles from './styles';
  11. type Props = AbstractProps & {
  12. /**
  13. * Any custom styling applied to the notifications container.
  14. */
  15. style: Object
  16. };
  17. /**
  18. * Implements a React {@link Component} which displays notifications and handles
  19. * automatic dismissmal after a notification is shown for a defined timeout
  20. * period.
  21. *
  22. * @extends {Component}
  23. */
  24. class NotificationsContainer
  25. extends AbstractNotificationsContainer<Props> {
  26. /**
  27. * Implements React's {@link Component#render()}.
  28. *
  29. * @inheritdoc
  30. */
  31. render() {
  32. const { _notifications } = this.props;
  33. // Currently the native container displays only the topmost notification
  34. const theNotification
  35. = _notifications && _notifications.length && _notifications[0];
  36. if (!theNotification) {
  37. return null;
  38. }
  39. return (
  40. <View
  41. pointerEvents = 'box-none'
  42. style = { [
  43. styles.notificationContainer,
  44. this.props.style
  45. ] } >
  46. <Notification
  47. { ...theNotification.props }
  48. onDismissed = { this._onDismissed }
  49. uid = { theNotification.uid } />
  50. </View>
  51. );
  52. }
  53. _onDismissed: number => void;
  54. }
  55. export default connect(_abstractMapStateToProps)(NotificationsContainer);