mirror of https://github.com/jitsi/jitsi-meet
parent
2ee8f1ef58
commit
68608478f6
After Width: | Height: | Size: 612 B |
After Width: | Height: | Size: 889 B |
@ -0,0 +1,198 @@ |
||||
// @flow
|
||||
|
||||
import React from 'react'; |
||||
import { Text, TouchableOpacity, View, ViewPagerAndroid } from 'react-native'; |
||||
import { connect } from 'react-redux'; |
||||
|
||||
import { Icon } from '../../../font-icons'; |
||||
|
||||
import AbstractPagedList from './AbstractPagedList'; |
||||
import styles from './styles'; |
||||
|
||||
/** |
||||
* An Android specific component to render a paged list. |
||||
* |
||||
* @extends PagedList |
||||
*/ |
||||
class PagedList extends AbstractPagedList { |
||||
/** |
||||
* A reference to the viewpager. |
||||
*/ |
||||
_viewPager: ViewPagerAndroid; |
||||
|
||||
/** |
||||
* Initializes a new {@code PagedList} instance. |
||||
* |
||||
* @inheritdoc |
||||
*/ |
||||
constructor(props) { |
||||
super(props); |
||||
|
||||
// Bind event handlers so they are only bound once per instance.
|
||||
this._onIconPress = this._onIconPress.bind(this); |
||||
this._getIndicatorStyle = this._getIndicatorStyle.bind(this); |
||||
this._onPageSelected = this._onPageSelected.bind(this); |
||||
this._setViewPager = this._setViewPager.bind(this); |
||||
} |
||||
|
||||
_onIconPress: number => Function; |
||||
|
||||
/** |
||||
* Constructs a function to be used as a callback for the icons in the tab |
||||
* bar. |
||||
* |
||||
* @param {number} pageIndex - The index of the page to activate via the |
||||
* callback. |
||||
* @private |
||||
* @returns {Function} |
||||
*/ |
||||
_onIconPress(pageIndex) { |
||||
return () => { |
||||
this._viewPager.setPage(pageIndex); |
||||
this._selectPage(pageIndex); |
||||
}; |
||||
} |
||||
|
||||
_getIndicatorStyle: number => Object; |
||||
|
||||
/** |
||||
* Constructs the style of an indicator. |
||||
* |
||||
* @param {number} indicatorIndex - The index of the indicator. |
||||
* @private |
||||
* @returns {Object} |
||||
*/ |
||||
_getIndicatorStyle(indicatorIndex) { |
||||
if (this.state.pageIndex === indicatorIndex) { |
||||
return styles.pageIndicatorActive; |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
_onPageSelected: Object => void; |
||||
|
||||
/** |
||||
* Updates the index of the currently selected page, based on the native |
||||
* event received from the {@link ViewPagerAndroid} component. |
||||
* |
||||
* @param {Object} event - The native event of the callback. |
||||
* @private |
||||
* @returns {void} |
||||
*/ |
||||
_onPageSelected({ nativeEvent: { position } }) { |
||||
if (this.state.pageIndex !== position) { |
||||
this._selectPage(position); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Renders a single page of the page list. |
||||
* |
||||
* @private |
||||
* @param {Object} page - The page to render. |
||||
* @param {number} index - The index of the rendered page. |
||||
* @param {boolean} disabled - Renders the page disabled. |
||||
* @returns {React$Node} |
||||
*/ |
||||
_renderPage(page, index, disabled) { |
||||
return page.component |
||||
? <View key = { index }> |
||||
{ |
||||
React.createElement( |
||||
page.component, |
||||
{ |
||||
disabled |
||||
}) |
||||
} |
||||
</View> |
||||
: null; |
||||
} |
||||
|
||||
/** |
||||
* Renders a page indicator (icon) for the page. |
||||
* |
||||
* @private |
||||
* @param {Object} page - The page the indicator is rendered for. |
||||
* @param {number} index - The index of the page the indicator is rendered |
||||
* for. |
||||
* @param {boolean} disabled - Renders the indicator disabled. |
||||
* @returns {React$Node} |
||||
*/ |
||||
_renderPageIndicator(page, index, disabled) { |
||||
return page.component |
||||
? <TouchableOpacity |
||||
disabled = { disabled } |
||||
onPress = { this._onIconPress(index) } |
||||
style = { styles.pageIndicator } > |
||||
<View style = { styles.pageIndicator }> |
||||
<Icon |
||||
name = { page.icon } |
||||
style = { [ |
||||
styles.pageIndicatorIcon, |
||||
this._getIndicatorStyle(index) |
||||
] } /> |
||||
<Text |
||||
style = { [ |
||||
styles.pageIndicatorText, |
||||
this._getIndicatorStyle(index) |
||||
] }> |
||||
{ page.title } |
||||
</Text> |
||||
</View> |
||||
</TouchableOpacity> |
||||
: null; |
||||
} |
||||
|
||||
/** |
||||
* Renders the paged list if multiple pages are to be rendered. This is the |
||||
* platform dependent part of the component. |
||||
* |
||||
* @param {boolean} disabled - True if the rendered lists should be |
||||
* disabled. |
||||
* @returns {ReactElement} |
||||
*/ |
||||
_renderPagedList(disabled) { |
||||
const { defaultPage, pages } = this.props; |
||||
|
||||
return ( |
||||
<View style = { styles.pagedListContainer }> |
||||
<ViewPagerAndroid |
||||
initialPage = { defaultPage } |
||||
onPageSelected = { this._onPageSelected } |
||||
peekEnabled = { true } |
||||
ref = { this._setViewPager } |
||||
style = { styles.pagedList }> |
||||
{ |
||||
pages.map((page, index) => this._renderPage( |
||||
page, index, disabled |
||||
)) |
||||
} |
||||
</ViewPagerAndroid> |
||||
<View style = { styles.pageIndicatorContainer }> |
||||
{ |
||||
pages.map((page, index) => this._renderPageIndicator( |
||||
page, index, disabled |
||||
)) |
||||
} |
||||
</View> |
||||
</View> |
||||
); |
||||
} |
||||
|
||||
_setViewPager: Object => void; |
||||
|
||||
/** |
||||
* Sets the {@link ViewPagerAndroid} instance. |
||||
* |
||||
* @param {ViewPagerAndroid} viewPager - The {@code ViewPagerAndroid} |
||||
* instance. |
||||
* @private |
||||
* @returns {void} |
||||
*/ |
||||
_setViewPager(viewPager) { |
||||
this._viewPager = viewPager; |
||||
} |
||||
} |
||||
|
||||
export default connect()(PagedList); |
@ -0,0 +1,100 @@ |
||||
// @flow
|
||||
|
||||
import React from 'react'; |
||||
import { TabBarIOS } from 'react-native'; |
||||
import { connect } from 'react-redux'; |
||||
|
||||
import AbstractPagedList from './AbstractPagedList'; |
||||
import styles from './styles'; |
||||
|
||||
/** |
||||
* An iOS specific component to render a paged list. |
||||
* |
||||
* @extends PagedList |
||||
*/ |
||||
class PagedList extends AbstractPagedList { |
||||
|
||||
/** |
||||
* Initializes a new {@code PagedList} instance. |
||||
* |
||||
* @inheritdoc |
||||
*/ |
||||
constructor(props) { |
||||
super(props); |
||||
|
||||
// Bind event handlers so they are only bound once per instance.
|
||||
this._onTabSelected = this._onTabSelected.bind(this); |
||||
} |
||||
|
||||
_onTabSelected: number => Function; |
||||
|
||||
/** |
||||
* Constructs a callback to update the selected tab when the bottom bar icon |
||||
* is pressed. |
||||
* |
||||
* @param {number} tabIndex - The selected tab. |
||||
* @private |
||||
* @returns {Function} |
||||
*/ |
||||
_onTabSelected(tabIndex) { |
||||
return () => super._selectPage(tabIndex); |
||||
} |
||||
|
||||
_renderPage: (Object, number, boolean) => React$Node |
||||
|
||||
/** |
||||
* Renders a single page of the page list. |
||||
* |
||||
* @private |
||||
* @param {Object} page - The page to render. |
||||
* @param {number} index - The index of the rendered page. |
||||
* @param {boolean} disabled - Renders the page disabled. |
||||
* @returns {React$Node} |
||||
*/ |
||||
_renderPage(page, index, disabled) { |
||||
const { pageIndex } = this.state; |
||||
|
||||
return page.component |
||||
? <TabBarIOS.Item |
||||
icon = { page.icon } |
||||
key = { index } |
||||
onPress = { this._onTabSelected(index) } |
||||
selected = { pageIndex === index } |
||||
title = { page.title }> |
||||
{ |
||||
React.createElement( |
||||
page.component, |
||||
{ |
||||
disabled |
||||
}) |
||||
} |
||||
</TabBarIOS.Item> |
||||
: null; |
||||
} |
||||
|
||||
/** |
||||
* Renders the paged list if multiple pages are to be rendered. This is the |
||||
* platform dependent part of the component. |
||||
* |
||||
* @param {boolean} disabled - True if the rendered lists should be |
||||
* disabled. |
||||
* @returns {ReactElement} |
||||
*/ |
||||
_renderPagedList(disabled) { |
||||
const { pages } = this.props; |
||||
|
||||
return ( |
||||
<TabBarIOS |
||||
itemPositioning = 'fill' |
||||
style = { styles.pagedList }> |
||||
{ |
||||
pages.map((page, index) => this._renderPage( |
||||
page, index, disabled |
||||
)) |
||||
} |
||||
</TabBarIOS> |
||||
); |
||||
} |
||||
} |
||||
|
||||
export default connect()(PagedList); |
@ -1,173 +0,0 @@ |
||||
// @flow
|
||||
|
||||
import React from 'react'; |
||||
import { Text, TouchableOpacity, View, ViewPagerAndroid } from 'react-native'; |
||||
import { connect } from 'react-redux'; |
||||
|
||||
import { Icon } from '../../base/font-icons'; |
||||
import { MeetingList } from '../../calendar-sync'; |
||||
import { RecentList } from '../../recent-list'; |
||||
|
||||
import AbstractPagedList, { DEFAULT_PAGE } from './AbstractPagedList'; |
||||
import styles from './styles'; |
||||
|
||||
/** |
||||
* A platform specific component to render a paged or tabbed list/view. |
||||
* |
||||
* @extends PagedList |
||||
*/ |
||||
class PagedList extends AbstractPagedList { |
||||
/** |
||||
* A reference to the viewpager. |
||||
*/ |
||||
_viewPager: Object; |
||||
|
||||
/** |
||||
* Initializes a new {@code PagedList} instance. |
||||
* |
||||
* @inheritdoc |
||||
*/ |
||||
constructor(props) { |
||||
super(props); |
||||
|
||||
// Bind event handlers so they are only bound once per instance.
|
||||
this._getIndicatorStyle = this._getIndicatorStyle.bind(this); |
||||
this._onPageSelected = this._onPageSelected.bind(this); |
||||
this._onSelectPage = this._onSelectPage.bind(this); |
||||
this._setViewPager = this._setViewPager.bind(this); |
||||
} |
||||
|
||||
_getIndicatorStyle: number => Object; |
||||
|
||||
/** |
||||
* Constructs the style of an indicator. |
||||
* |
||||
* @param {number} indicatorIndex - The index of the indicator. |
||||
* @private |
||||
* @returns {Object} |
||||
*/ |
||||
_getIndicatorStyle(indicatorIndex) { |
||||
if (this.state.pageIndex === indicatorIndex) { |
||||
return styles.pageIndicatorTextActive; |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
_onPageSelected: Object => void; |
||||
|
||||
/** |
||||
* Updates the index of the currently selected page. |
||||
* |
||||
* @param {Object} event - The native event of the callback. |
||||
* @private |
||||
* @returns {void} |
||||
*/ |
||||
_onPageSelected({ nativeEvent: { position } }) { |
||||
if (this.state.pageIndex !== position) { |
||||
this._selectPage(position); |
||||
} |
||||
} |
||||
|
||||
_onSelectPage: number => Function; |
||||
|
||||
/** |
||||
* Constructs a function to be used as a callback for the tab bar. |
||||
* |
||||
* @param {number} pageIndex - The index of the page to activate via the |
||||
* callback. |
||||
* @private |
||||
* @returns {Function} |
||||
*/ |
||||
_onSelectPage(pageIndex) { |
||||
return () => { |
||||
this._viewPager.setPage(pageIndex); |
||||
this._selectPage(pageIndex); |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* Renders the entire paged list if calendar is enabled. |
||||
* |
||||
* @param {boolean} disabled - True if the rendered lists should be |
||||
* disabled. |
||||
* @returns {ReactElement} |
||||
*/ |
||||
_renderPagedList(disabled) { |
||||
return ( |
||||
<View style = { styles.pagedListContainer }> |
||||
<ViewPagerAndroid |
||||
initialPage = { DEFAULT_PAGE } |
||||
onPageSelected = { this._onPageSelected } |
||||
peekEnabled = { true } |
||||
ref = { this._setViewPager } |
||||
style = { styles.pagedList }> |
||||
<View key = { 0 }> |
||||
<RecentList disabled = { disabled } /> |
||||
</View> |
||||
<View key = { 1 }> |
||||
<MeetingList disabled = { disabled } /> |
||||
</View> |
||||
</ViewPagerAndroid> |
||||
<View style = { styles.pageIndicatorContainer }> |
||||
<TouchableOpacity |
||||
disabled = { disabled } |
||||
onPress = { this._onSelectPage(0) } |
||||
style = { styles.pageIndicator } > |
||||
<View style = { styles.pageIndicator }> |
||||
<Icon |
||||
name = 'restore' |
||||
style = { [ |
||||
styles.pageIndicatorIcon, |
||||
this._getIndicatorStyle(0) |
||||
] } /> |
||||
<Text |
||||
style = { [ |
||||
styles.pageIndicatorText, |
||||
this._getIndicatorStyle(0) |
||||
] }> |
||||
History |
||||
</Text> |
||||
</View> |
||||
</TouchableOpacity> |
||||
<TouchableOpacity |
||||
disabled = { disabled } |
||||
onPress = { this._onSelectPage(1) } |
||||
style = { styles.pageIndicator } > |
||||
<View style = { styles.pageIndicator }> |
||||
<Icon |
||||
name = 'event_note' |
||||
style = { [ |
||||
styles.pageIndicatorIcon, |
||||
this._getIndicatorStyle(1) |
||||
] } /> |
||||
<Text |
||||
style = { [ |
||||
styles.pageIndicatorText, |
||||
this._getIndicatorStyle(1) |
||||
] }> |
||||
Calendar |
||||
</Text> |
||||
</View> |
||||
</TouchableOpacity> |
||||
</View> |
||||
</View> |
||||
); |
||||
} |
||||
|
||||
_setViewPager: Object => void; |
||||
|
||||
/** |
||||
* Sets the {@link ViewPagerAndroid} instance. |
||||
* |
||||
* @param {ViewPagerAndroid} viewPager - The {@code ViewPagerAndroid} |
||||
* instance. |
||||
* @private |
||||
* @returns {void} |
||||
*/ |
||||
_setViewPager(viewPager) { |
||||
this._viewPager = viewPager; |
||||
} |
||||
} |
||||
|
||||
export default connect()(PagedList); |
@ -1,81 +0,0 @@ |
||||
// @flow
|
||||
|
||||
import React from 'react'; |
||||
import { TabBarIOS } from 'react-native'; |
||||
import { connect } from 'react-redux'; |
||||
|
||||
import { translate } from '../../base/i18n'; |
||||
import { MeetingList } from '../../calendar-sync'; |
||||
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 { |
||||
|
||||
/** |
||||
* Initializes a new {@code PagedList} instance. |
||||
* |
||||
* @inheritdoc |
||||
*/ |
||||
constructor(props) { |
||||
super(props); |
||||
|
||||
// Bind event handlers so they are only bound once per instance.
|
||||
this._onTabSelected = this._onTabSelected.bind(this); |
||||
} |
||||
|
||||
_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); |
||||
} |
||||
|
||||
/** |
||||
* Renders the entire paged list if calendar is enabled. |
||||
* |
||||
* @param {boolean} disabled - True if the rendered lists should be |
||||
* disabled. |
||||
* @returns {ReactElement} |
||||
*/ |
||||
_renderPagedList(disabled) { |
||||
const { pageIndex } = this.state; |
||||
const { t } = this.props; |
||||
|
||||
return ( |
||||
<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') }> |
||||
<MeetingList disabled = { disabled } /> |
||||
</TabBarIOS.Item> |
||||
</TabBarIOS> |
||||
); |
||||
} |
||||
} |
||||
|
||||
export default translate(connect()(PagedList)); |
@ -0,0 +1,88 @@ |
||||
// @flow
|
||||
|
||||
import React, { Component } from 'react'; |
||||
import { Platform } from 'react-native'; |
||||
|
||||
import { translate } from '../../base/i18n'; |
||||
import { PagedList } from '../../base/react'; |
||||
import { MeetingList } from '../../calendar-sync'; |
||||
import { RecentList } from '../../recent-list'; |
||||
|
||||
type Props = { |
||||
|
||||
/** |
||||
* Renders the lists disabled. |
||||
*/ |
||||
disabled: boolean, |
||||
|
||||
/** |
||||
* The i18n translate function. |
||||
*/ |
||||
t: Function |
||||
}; |
||||
|
||||
/** |
||||
* Icon to be used for the calendar page on iOS. |
||||
*/ |
||||
const IOS_CALENDAR_ICON = require('../../../../images/calendar.png'); |
||||
|
||||
/** |
||||
* Icon to be used for the recent list page on iOS. |
||||
*/ |
||||
const IOS_RECENT_LIST_ICON = require('../../../../images/history.png'); |
||||
|
||||
/** |
||||
* Implements the lists displayed on the mobile welcome screen. |
||||
*/ |
||||
class WelcomePageLists extends Component<Props> { |
||||
/** |
||||
* The pages to be rendered. |
||||
* Note: The component field may be undefined if a feature (such as |
||||
* Calendar) is disabled, and that means that the page must not be rendered. |
||||
*/ |
||||
pages: Array<{ |
||||
component: Object, |
||||
icon: string | number, |
||||
title: string |
||||
}> |
||||
|
||||
/** |
||||
* Component contructor. |
||||
* |
||||
* @inheritdoc |
||||
*/ |
||||
constructor(props) { |
||||
super(props); |
||||
|
||||
const { t } = props; |
||||
const isAndroid = Platform.OS === 'android'; |
||||
|
||||
this.pages = [ { |
||||
component: RecentList, |
||||
icon: isAndroid ? 'restore' : IOS_RECENT_LIST_ICON, |
||||
title: t('welcomepage.recentList') |
||||
}, { |
||||
component: MeetingList, |
||||
icon: isAndroid ? 'event_note' : IOS_CALENDAR_ICON, |
||||
title: t('welcomepage.calendar') |
||||
} ]; |
||||
} |
||||
|
||||
/** |
||||
* Implements React Component's render. |
||||
* |
||||
* @inheritdoc |
||||
*/ |
||||
render() { |
||||
const { disabled } = this.props; |
||||
|
||||
return ( |
||||
<PagedList |
||||
defaultPage = { 0 } |
||||
disabled = { disabled } |
||||
pages = { this.pages } /> |
||||
); |
||||
} |
||||
} |
||||
|
||||
export default translate(WelcomePageLists); |
Loading…
Reference in new issue