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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. * @returns {ReactElement}
  31. */
  32. render() {
  33. const { _notifications } = this.props;
  34. if (!_notifications || !_notifications.length) {
  35. return null;
  36. }
  37. return (
  38. <View
  39. pointerEvents = 'box-none'
  40. style = { [
  41. styles.notificationContainer,
  42. this.props.style
  43. ] } >
  44. {
  45. _notifications.map(
  46. ({ props, uid }) => (
  47. <Notification
  48. { ...props }
  49. key = { uid }
  50. onDismissed = { this._onDismissed }
  51. uid = { uid } />))
  52. }
  53. </View>
  54. );
  55. }
  56. _onDismissed: number => void;
  57. }
  58. export default connect(_abstractMapStateToProps)(NotificationsContainer);