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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 disabled = { disabled } />
  54. </TabBarIOS.Item>
  55. </TabBarIOS>
  56. </View>
  57. );
  58. }
  59. _onTabSelected: number => Function;
  60. /**
  61. * Constructs a callback to update the selected tab.
  62. *
  63. * @private
  64. * @param {number} tabIndex - The selected tab.
  65. * @returns {Function}
  66. */
  67. _onTabSelected(tabIndex) {
  68. return () => {
  69. this.setState({
  70. pageIndex: tabIndex
  71. });
  72. };
  73. }
  74. }
  75. export default translate(PagedList);