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.

AbstractPagedList.native.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { View } from 'react-native';
  4. import { isCalendarEnabled } from '../../calendar-sync';
  5. import { RecentList } from '../../recent-list';
  6. import styles from './styles';
  7. /**
  8. * The page to be displayed on render.
  9. */
  10. export const DEFAULT_PAGE = 0;
  11. type Props = {
  12. /**
  13. * Indicates if the list is disabled or not.
  14. */
  15. disabled: boolean,
  16. /**
  17. * The Redux dispatch function.
  18. */
  19. dispatch: Function,
  20. /**
  21. * The i18n translate function
  22. */
  23. t: Function
  24. }
  25. type State = {
  26. /**
  27. * The currently selected page.
  28. */
  29. pageIndex: number
  30. }
  31. /**
  32. * Abstract class for the platform specific paged lists.
  33. */
  34. export default class AbstractPagedList extends Component<Props, State> {
  35. /**
  36. * True if the calendar feature is enabled on the platform, false otherwise.
  37. */
  38. _calendarEnabled: boolean
  39. /**
  40. * Constructor of the component.
  41. *
  42. * @inheritdoc
  43. */
  44. constructor(props: Props) {
  45. super(props);
  46. this._calendarEnabled = isCalendarEnabled();
  47. this.state = {
  48. pageIndex: DEFAULT_PAGE
  49. };
  50. }
  51. /**
  52. * Renders the component.
  53. *
  54. * @inheritdoc
  55. */
  56. render() {
  57. const { disabled } = this.props;
  58. return (
  59. <View
  60. style = { [
  61. styles.pagedListContainer,
  62. disabled ? styles.pagedListContainerDisabled : null
  63. ] }>
  64. {
  65. (this._calendarEnabled && this._renderPagedList(disabled))
  66. || <RecentList
  67. disabled = { disabled }
  68. style = { styles.pagedList } />
  69. }
  70. </View>
  71. );
  72. }
  73. _renderPagedList: boolean => Object
  74. }