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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 style = { styles.pagedListContainer }>
  35. <TabBarIOS
  36. itemPositioning = 'fill'
  37. style = { styles.pagedList }>
  38. <TabBarIOS.Item
  39. onPress = { this._onTabSelected(0) }
  40. selected = { pageIndex === 0 }
  41. systemIcon = 'history' >
  42. <RecentList disabled = { disabled } />
  43. </TabBarIOS.Item>
  44. <TabBarIOS.Item
  45. icon = { CALENDAR_ICON }
  46. onPress = { this._onTabSelected(1) }
  47. selected = { pageIndex === 1 }
  48. title = { t('welcomepage.calendar') } >
  49. <MeetingList disabled = { disabled } />
  50. </TabBarIOS.Item>
  51. </TabBarIOS>
  52. </View>
  53. );
  54. }
  55. _onTabSelected: number => Function;
  56. /**
  57. * Constructs a callback to update the selected tab.
  58. *
  59. * @private
  60. * @param {number} tabIndex - The selected tab.
  61. * @returns {Function}
  62. */
  63. _onTabSelected(tabIndex) {
  64. return () => {
  65. this.setState({
  66. pageIndex: tabIndex
  67. });
  68. };
  69. }
  70. }
  71. export default translate(PagedList);