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.

WelcomePageLists.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { Platform } from 'react-native';
  4. import { connect } from 'react-redux';
  5. import { translate } from '../../base/i18n';
  6. import { PagedList } from '../../base/react';
  7. import { MeetingList } from '../../calendar-sync';
  8. import { RecentList } from '../../recent-list';
  9. type Props = {
  10. /**
  11. * True if the calendar feature has fetched entries, false otherwise
  12. */
  13. _hasCalendarEntries: boolean,
  14. /**
  15. * Renders the lists disabled.
  16. */
  17. disabled: boolean,
  18. /**
  19. * The i18n translate function.
  20. */
  21. t: Function
  22. };
  23. /**
  24. * Icon to be used for the calendar page on iOS.
  25. */
  26. const IOS_CALENDAR_ICON = require('../../../../images/calendar.png');
  27. /**
  28. * Icon to be used for the recent list page on iOS.
  29. */
  30. const IOS_RECENT_LIST_ICON = require('../../../../images/history.png');
  31. /**
  32. * Implements the lists displayed on the mobile welcome screen.
  33. */
  34. class WelcomePageLists extends Component<Props> {
  35. /**
  36. * The pages to be rendered.
  37. * Note: The component field may be undefined if a feature (such as
  38. * Calendar) is disabled, and that means that the page must not be rendered.
  39. */
  40. pages: Array<{
  41. component: Object,
  42. icon: string | number,
  43. title: string
  44. }>
  45. /**
  46. * Component contructor.
  47. *
  48. * @inheritdoc
  49. */
  50. constructor(props) {
  51. super(props);
  52. const { t } = props;
  53. const isAndroid = Platform.OS === 'android';
  54. this.pages = [ {
  55. component: RecentList,
  56. icon: isAndroid ? 'restore' : IOS_RECENT_LIST_ICON,
  57. title: t('welcomepage.recentList')
  58. }, {
  59. component: MeetingList,
  60. icon: isAndroid ? 'event_note' : IOS_CALENDAR_ICON,
  61. title: t('welcomepage.calendar')
  62. } ];
  63. }
  64. /**
  65. * Implements React Component's render.
  66. *
  67. * @inheritdoc
  68. */
  69. render() {
  70. const { disabled, _hasCalendarEntries } = this.props;
  71. return (
  72. <PagedList
  73. defaultPage = { _hasCalendarEntries ? 1 : 0 }
  74. disabled = { disabled }
  75. pages = { this.pages } />
  76. );
  77. }
  78. }
  79. /**
  80. * Maps (parts of) the redux state to the React {@code Component} props of
  81. * {@code WelcomePageLists}.
  82. *
  83. * @param {Object} state - The redux state.
  84. * @protected
  85. * @returns {{
  86. * _hasCalendarEntries: boolean
  87. * }}
  88. */
  89. function _mapStateToProps(state: Object) {
  90. const { events } = state['features/calendar-sync'];
  91. return {
  92. _hasCalendarEntries: Boolean(events && events.length)
  93. };
  94. }
  95. export default translate(connect(_mapStateToProps)(WelcomePageLists));