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.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // @flow
  2. import React from 'react';
  3. import { View, TabBarIOS } from 'react-native';
  4. import { connect } from 'react-redux';
  5. import { translate } from '../../base/i18n';
  6. import { MeetingList, refreshCalendarEntryList } 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. * Constructor of the PagedList Component.
  19. *
  20. * @inheritdoc
  21. */
  22. constructor(props) {
  23. super(props);
  24. this._onTabSelected = this._onTabSelected.bind(this);
  25. }
  26. /**
  27. * Renders the paged list.
  28. *
  29. * @inheritdoc
  30. */
  31. render() {
  32. const { pageIndex } = this.state;
  33. const { disabled, t } = this.props;
  34. return (
  35. <View
  36. style = { [
  37. styles.pagedListContainer,
  38. disabled ? styles.pagedListContainerDisabled : null
  39. ] }>
  40. <TabBarIOS
  41. itemPositioning = 'fill'
  42. style = { styles.pagedList }>
  43. <TabBarIOS.Item
  44. onPress = { this._onTabSelected(0) }
  45. selected = { pageIndex === 0 }
  46. systemIcon = 'history' >
  47. <RecentList disabled = { disabled } />
  48. </TabBarIOS.Item>
  49. <TabBarIOS.Item
  50. icon = { CALENDAR_ICON }
  51. onPress = { this._onTabSelected(1) }
  52. selected = { pageIndex === 1 }
  53. title = { t('welcomepage.calendar') } >
  54. <MeetingList
  55. disabled = { disabled } />
  56. </TabBarIOS.Item>
  57. </TabBarIOS>
  58. </View>
  59. );
  60. }
  61. _onTabSelected: number => Function;
  62. /**
  63. * Constructs a callback to update the selected tab.
  64. *
  65. * @private
  66. * @param {number} tabIndex - The selected tab.
  67. * @returns {Function}
  68. */
  69. _onTabSelected(tabIndex) {
  70. return () => {
  71. this.setState({
  72. pageIndex: tabIndex
  73. });
  74. if (tabIndex === 1) {
  75. /**
  76. * This is a workaround as TabBarIOS doesn't invoke
  77. * componentWillReciveProps on prop change of the
  78. * MeetingList component.
  79. */
  80. this.props.dispatch(refreshCalendarEntryList());
  81. }
  82. };
  83. }
  84. }
  85. export default translate(connect()(PagedList));