2018-02-08 18:50:19 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import { View, 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 02:04:57 +00:00
|
|
|
import { MeetingList, refreshCalendar } 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 {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor of the PagedList Component.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this._onTabSelected = this._onTabSelected.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the paged list.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const { pageIndex } = this.state;
|
|
|
|
const { disabled, t } = this.props;
|
|
|
|
|
|
|
|
return (
|
2018-02-13 23:33:03 +00:00
|
|
|
<View
|
|
|
|
style = { [
|
|
|
|
styles.pagedListContainer,
|
|
|
|
disabled ? styles.pagedListContainerDisabled : null
|
|
|
|
] }>
|
2018-02-08 18:50:19 +00:00
|
|
|
<TabBarIOS
|
|
|
|
itemPositioning = 'fill'
|
|
|
|
style = { styles.pagedList }>
|
|
|
|
<TabBarIOS.Item
|
|
|
|
onPress = { this._onTabSelected(0) }
|
|
|
|
selected = { pageIndex === 0 }
|
|
|
|
systemIcon = 'history' >
|
|
|
|
<RecentList disabled = { disabled } />
|
|
|
|
</TabBarIOS.Item>
|
|
|
|
<TabBarIOS.Item
|
|
|
|
icon = { CALENDAR_ICON }
|
|
|
|
onPress = { this._onTabSelected(1) }
|
|
|
|
selected = { pageIndex === 1 }
|
|
|
|
title = { t('welcomepage.calendar') } >
|
2018-03-06 16:30:59 +00:00
|
|
|
<MeetingList
|
2018-03-20 13:51:51 +00:00
|
|
|
disabled = { disabled } />
|
2018-02-08 18:50:19 +00:00
|
|
|
</TabBarIOS.Item>
|
|
|
|
</TabBarIOS>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onTabSelected: number => Function;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs a callback to update the selected tab.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {number} tabIndex - The selected tab.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
_onTabSelected(tabIndex) {
|
|
|
|
return () => {
|
|
|
|
this.setState({
|
|
|
|
pageIndex: tabIndex
|
|
|
|
});
|
2018-03-20 13:51:51 +00:00
|
|
|
|
|
|
|
if (tabIndex === 1) {
|
|
|
|
/**
|
|
|
|
* This is a workaround as TabBarIOS doesn't invoke
|
2018-04-16 02:04:57 +00:00
|
|
|
* componentWillReciveProps on prop change of the MeetingList
|
|
|
|
* component.
|
2018-03-20 13:51:51 +00:00
|
|
|
*/
|
2018-04-16 02:04:57 +00:00
|
|
|
this.props.dispatch(refreshCalendar());
|
2018-03-20 13:51:51 +00:00
|
|
|
}
|
2018-02-08 18:50:19 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-20 13:51:51 +00:00
|
|
|
export default translate(connect()(PagedList));
|