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.

PagedList.ios.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // @flow
  2. import React from 'react';
  3. import { TabBarIOS } from 'react-native';
  4. import { connect } from 'react-redux';
  5. import { translate } from '../../base/i18n';
  6. import { MeetingList } from '../../calendar-sync';
  7. import { RecentList } from '../../recent-list';
  8. import AbstractPagedList from './AbstractPagedList';
  9. import styles from './styles';
  10. const CALENDAR_ICON = require('../../../../images/calendar.png');
  11. /**
  12. * A platform specific component to render a paged or tabbed list/view.
  13. *
  14. * @extends PagedList
  15. */
  16. class PagedList extends AbstractPagedList {
  17. /**
  18. * Initializes a new {@code PagedList} instance.
  19. *
  20. * @inheritdoc
  21. */
  22. constructor(props) {
  23. super(props);
  24. // Bind event handlers so they are only bound once per instance.
  25. this._onTabSelected = this._onTabSelected.bind(this);
  26. }
  27. _onTabSelected: number => Function;
  28. /**
  29. * Constructs a callback to update the selected tab.
  30. *
  31. * @param {number} tabIndex - The selected tab.
  32. * @private
  33. * @returns {Function}
  34. */
  35. _onTabSelected(tabIndex) {
  36. return () => super._selectPage(tabIndex);
  37. }
  38. /**
  39. * Renders the entire paged list if calendar is enabled.
  40. *
  41. * @param {boolean} disabled - True if the rendered lists should be
  42. * disabled.
  43. * @returns {ReactElement}
  44. */
  45. _renderPagedList(disabled) {
  46. const { pageIndex } = this.state;
  47. const { t } = this.props;
  48. return (
  49. <TabBarIOS
  50. itemPositioning = 'fill'
  51. style = { styles.pagedList }>
  52. <TabBarIOS.Item
  53. onPress = { this._onTabSelected(0) }
  54. selected = { pageIndex === 0 }
  55. systemIcon = 'history'>
  56. <RecentList disabled = { disabled } />
  57. </TabBarIOS.Item>
  58. <TabBarIOS.Item
  59. icon = { CALENDAR_ICON }
  60. onPress = { this._onTabSelected(1) }
  61. selected = { pageIndex === 1 }
  62. title = { t('welcomepage.calendar') }>
  63. <MeetingList disabled = { disabled } />
  64. </TabBarIOS.Item>
  65. </TabBarIOS>
  66. );
  67. }
  68. }
  69. export default translate(connect()(PagedList));