You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NotificationsContainer.native.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // @flow
  2. import React from 'react';
  3. import { View } from 'react-native';
  4. import { connect } from 'react-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. if (!_notifications || !_notifications.length) {
  34. return null;
  35. }
  36. return (
  37. <View
  38. pointerEvents = 'box-none'
  39. style = { [
  40. styles.notificationContainer,
  41. this.props.style
  42. ] } >
  43. {
  44. _notifications.map(
  45. ({ props, uid }) => (
  46. <Notification
  47. { ...props }
  48. key = { uid }
  49. onDismissed = { this._onDismissed }
  50. uid = { uid } />))
  51. }
  52. </View>
  53. );
  54. }
  55. _onDismissed: number => void;
  56. }
  57. export default connect(_abstractMapStateToProps)(NotificationsContainer);