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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // @flow
  2. import React from 'react';
  3. import { View, TabBarIOS } from 'react-native';
  4. import { translate } from '../../base/i18n';
  5. import { MeetingList } from '../../calendar-sync';
  6. import { RecentList } from '../../recent-list';
  7. import AbstractPagedList from './AbstractPagedList';
  8. import styles from './styles';
  9. const CALENDAR_ICON = require('../../../../images/calendar.png');
  10. /**
  11. * A platform specific component to render a paged or tabbed list/view.
  12. *
  13. * @extends PagedList
  14. */
  15. class PagedList extends AbstractPagedList {
  16. /**
  17. * Constructor of the PagedList Component.
  18. *
  19. * @inheritdoc
  20. */
  21. constructor(props) {
  22. super(props);
  23. this._onTabSelected = this._onTabSelected.bind(this);
  24. }
  25. /**
  26. * Renders the paged list.
  27. *
  28. * @inheritdoc
  29. */
  30. render() {
  31. const { pageIndex } = this.state;
  32. const { disabled, t } = this.props;
  33. return (
  34. <View
  35. style = { [
  36. styles.pagedListContainer,
  37. disabled ? styles.pagedListContainerDisabled : null
  38. ] }>
  39. <TabBarIOS
  40. itemPositioning = 'fill'
  41. style = { styles.pagedList }>
  42. <TabBarIOS.Item
  43. onPress = { this._onTabSelected(0) }
  44. selected = { pageIndex === 0 }
  45. systemIcon = 'history' >
  46. <RecentList disabled = { disabled } />
  47. </TabBarIOS.Item>
  48. <TabBarIOS.Item
  49. icon = { CALENDAR_ICON }
  50. onPress = { this._onTabSelected(1) }
  51. selected = { pageIndex === 1 }
  52. title = { t('welcomepage.calendar') } >
  53. <MeetingList
  54. disabled = { disabled }
  55. displayed = { pageIndex === 1 } />
  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. };
  75. }
  76. }
  77. export default translate(PagedList);