2018-02-08 18:50:19 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React from 'react';
|
2018-04-16 16:39:26 +00:00
|
|
|
import { TabBarIOS } from 'react-native';
|
2018-03-20 13:51:51 +00:00
|
|
|
import { connect } from 'react-redux';
|
2018-02-08 18:50:19 +00:00
|
|
|
|
|
|
|
import { translate } from '../../base/i18n';
|
2018-04-16 18:07:38 +00:00
|
|
|
import { MeetingList } from '../../calendar-sync';
|
2018-02-08 18:50:19 +00:00
|
|
|
import { RecentList } from '../../recent-list';
|
|
|
|
|
|
|
|
import AbstractPagedList from './AbstractPagedList';
|
|
|
|
import styles from './styles';
|
|
|
|
|
|
|
|
const CALENDAR_ICON = require('../../../../images/calendar.png');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A platform specific component to render a paged or tabbed list/view.
|
|
|
|
*
|
|
|
|
* @extends PagedList
|
|
|
|
*/
|
|
|
|
class PagedList extends AbstractPagedList {
|
|
|
|
|
|
|
|
/**
|
2018-04-16 18:07:38 +00:00
|
|
|
* Initializes a new {@code PagedList} instance.
|
2018-02-08 18:50:19 +00:00
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2018-04-16 18:07:38 +00:00
|
|
|
|
|
|
|
// Bind event handlers so they are only bound once per instance.
|
2018-02-08 18:50:19 +00:00
|
|
|
this._onTabSelected = this._onTabSelected.bind(this);
|
|
|
|
}
|
|
|
|
|
2018-04-16 18:07:38 +00:00
|
|
|
_onTabSelected: number => Function;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs a callback to update the selected tab.
|
|
|
|
*
|
|
|
|
* @param {number} tabIndex - The selected tab.
|
|
|
|
* @private
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
_onTabSelected(tabIndex) {
|
|
|
|
return () => super._selectPage(tabIndex);
|
|
|
|
}
|
|
|
|
|
2018-02-08 18:50:19 +00:00
|
|
|
/**
|
2018-04-16 16:39:26 +00:00
|
|
|
* Renders the entire paged list if calendar is enabled.
|
2018-02-08 18:50:19 +00:00
|
|
|
*
|
2018-04-16 16:39:26 +00:00
|
|
|
* @param {boolean} disabled - True if the rendered lists should be
|
|
|
|
* disabled.
|
|
|
|
* @returns {ReactElement}
|
2018-02-08 18:50:19 +00:00
|
|
|
*/
|
2018-04-16 16:39:26 +00:00
|
|
|
_renderPagedList(disabled) {
|
2018-02-08 18:50:19 +00:00
|
|
|
const { pageIndex } = this.state;
|
2018-04-16 16:39:26 +00:00
|
|
|
const { t } = this.props;
|
2018-02-08 18:50:19 +00:00
|
|
|
|
|
|
|
return (
|
2018-04-16 16:39:26 +00:00
|
|
|
<TabBarIOS
|
|
|
|
itemPositioning = 'fill'
|
|
|
|
style = { styles.pagedList }>
|
|
|
|
<TabBarIOS.Item
|
|
|
|
onPress = { this._onTabSelected(0) }
|
|
|
|
selected = { pageIndex === 0 }
|
2018-04-16 18:07:38 +00:00
|
|
|
systemIcon = 'history'>
|
2018-04-16 16:39:26 +00:00
|
|
|
<RecentList disabled = { disabled } />
|
|
|
|
</TabBarIOS.Item>
|
|
|
|
<TabBarIOS.Item
|
|
|
|
icon = { CALENDAR_ICON }
|
|
|
|
onPress = { this._onTabSelected(1) }
|
|
|
|
selected = { pageIndex === 1 }
|
2018-04-16 18:07:38 +00:00
|
|
|
title = { t('welcomepage.calendar') }>
|
|
|
|
<MeetingList disabled = { disabled } />
|
2018-04-16 16:39:26 +00:00
|
|
|
</TabBarIOS.Item>
|
|
|
|
</TabBarIOS>
|
2018-02-08 18:50:19 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-20 13:51:51 +00:00
|
|
|
export default translate(connect()(PagedList));
|