2016-10-05 14:36:59 +00:00
|
|
|
import React from 'react';
|
2018-02-02 14:50:16 +00:00
|
|
|
import {
|
2018-02-16 16:06:03 +00:00
|
|
|
Animated,
|
2018-02-15 22:58:07 +00:00
|
|
|
Keyboard,
|
2018-02-02 14:50:16 +00:00
|
|
|
SafeAreaView,
|
|
|
|
TextInput,
|
|
|
|
TouchableHighlight,
|
|
|
|
TouchableOpacity,
|
|
|
|
View
|
|
|
|
} from 'react-native';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2019-06-26 14:59:20 +00:00
|
|
|
import { getName } from '../../app';
|
|
|
|
|
2019-03-05 17:41:39 +00:00
|
|
|
import { ColorSchemeRegistry } from '../../base/color-scheme';
|
2017-03-01 02:55:12 +00:00
|
|
|
import { translate } from '../../base/i18n';
|
2019-08-30 16:39:06 +00:00
|
|
|
import { Icon, IconMenu } from '../../base/icons';
|
2017-08-17 13:50:49 +00:00
|
|
|
import { MEDIA_TYPE } from '../../base/media';
|
2018-05-07 15:03:59 +00:00
|
|
|
import { Header, LoadingIndicator, Text } from '../../base/react';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../base/redux';
|
2018-03-06 16:58:26 +00:00
|
|
|
import { ColorPalette } from '../../base/styles';
|
2018-02-02 14:50:16 +00:00
|
|
|
import {
|
|
|
|
createDesiredLocalTracks,
|
|
|
|
destroyLocalTracks
|
|
|
|
} from '../../base/tracks';
|
2020-04-06 15:14:32 +00:00
|
|
|
import { HelpView } from '../../help';
|
2019-05-07 14:50:57 +00:00
|
|
|
import { DialInSummary } from '../../invite';
|
2018-02-26 16:14:46 +00:00
|
|
|
import { SettingsView } from '../../settings';
|
2018-02-02 14:50:16 +00:00
|
|
|
|
2019-06-26 14:59:20 +00:00
|
|
|
import { setSideBarVisible } from '../actions';
|
|
|
|
|
2019-03-05 17:41:39 +00:00
|
|
|
import {
|
|
|
|
AbstractWelcomePage,
|
|
|
|
_mapStateToProps as _abstractMapStateToProps
|
|
|
|
} from './AbstractWelcomePage';
|
2017-12-20 00:49:36 +00:00
|
|
|
import LocalVideoTrackUnderlay from './LocalVideoTrackUnderlay';
|
2018-05-07 15:03:59 +00:00
|
|
|
import styles, { PLACEHOLDER_TEXT_COLOR } from './styles';
|
2018-04-27 12:19:07 +00:00
|
|
|
import VideoSwitch from './VideoSwitch';
|
2018-04-24 13:11:25 +00:00
|
|
|
import WelcomePageLists from './WelcomePageLists';
|
2018-02-02 14:50:16 +00:00
|
|
|
import WelcomePageSideBar from './WelcomePageSideBar';
|
2016-11-29 20:04:56 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
|
|
|
* The native container rendering the welcome page.
|
|
|
|
*
|
|
|
|
* @extends AbstractWelcomePage
|
|
|
|
*/
|
|
|
|
class WelcomePage extends AbstractWelcomePage {
|
2018-02-02 14:50:16 +00:00
|
|
|
/**
|
|
|
|
* Constructor of the Component.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
2018-04-04 12:50:12 +00:00
|
|
|
this.state._fieldFocused = false;
|
2018-02-16 16:06:03 +00:00
|
|
|
this.state.hintBoxAnimation = new Animated.Value(0);
|
|
|
|
|
2018-02-26 16:14:46 +00:00
|
|
|
// Bind event handlers so they are only bound once per instance.
|
2018-02-16 16:06:03 +00:00
|
|
|
this._onFieldFocusChange = this._onFieldFocusChange.bind(this);
|
2018-02-02 14:50:16 +00:00
|
|
|
this._onShowSideBar = this._onShowSideBar.bind(this);
|
2018-02-16 16:06:03 +00:00
|
|
|
this._renderHintBox = this._renderHintBox.bind(this);
|
2018-05-29 12:51:55 +00:00
|
|
|
|
|
|
|
// Specially bind functions to avoid function definition on render.
|
|
|
|
this._onFieldBlur = this._onFieldFocusChange.bind(this, false);
|
|
|
|
this._onFieldFocus = this._onFieldFocusChange.bind(this, true);
|
2018-02-02 14:50:16 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 13:50:49 +00:00
|
|
|
/**
|
2018-10-29 19:27:12 +00:00
|
|
|
* Implements React's {@link Component#componentDidMount()}. Invoked
|
|
|
|
* immediately after mounting occurs. Creates a local video track if none
|
2018-07-12 09:23:26 +00:00
|
|
|
* is available and the camera permission was already granted.
|
2017-08-17 13:50:49 +00:00
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2018-10-29 19:27:12 +00:00
|
|
|
componentDidMount() {
|
|
|
|
super.componentDidMount();
|
2017-09-14 09:46:35 +00:00
|
|
|
|
2020-03-27 12:48:33 +00:00
|
|
|
this._updateRoomname();
|
|
|
|
|
2018-02-02 14:50:16 +00:00
|
|
|
const { dispatch } = this.props;
|
|
|
|
|
2018-04-12 19:58:20 +00:00
|
|
|
if (this.props._settings.startAudioOnly) {
|
2018-02-02 14:50:16 +00:00
|
|
|
dispatch(destroyLocalTracks());
|
|
|
|
} else {
|
2018-07-12 09:23:26 +00:00
|
|
|
// Make sure we don't request the permission for the camera from
|
|
|
|
// the start. We will, however, create a video track iff the user
|
|
|
|
// already granted the permission.
|
2018-09-04 21:43:10 +00:00
|
|
|
navigator.permissions.query({ name: 'camera' }).then(response => {
|
|
|
|
response === 'granted'
|
2018-07-12 09:23:26 +00:00
|
|
|
&& dispatch(createDesiredLocalTracks(MEDIA_TYPE.VIDEO));
|
|
|
|
});
|
2018-02-02 14:50:16 +00:00
|
|
|
}
|
2017-08-17 13:50:49 +00:00
|
|
|
}
|
2016-12-01 01:52:39 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
2017-09-14 09:46:35 +00:00
|
|
|
* Implements React's {@link Component#render()}. Renders a prompt for
|
|
|
|
* entering a room name.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
2017-09-14 09:46:35 +00:00
|
|
|
* @inheritdoc
|
2016-10-05 14:36:59 +00:00
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2019-07-23 14:07:55 +00:00
|
|
|
// We want to have the welcome page support the reduced UI layout,
|
|
|
|
// but we ran into serious issues enabling it so we disable it
|
|
|
|
// until we have a proper fix in place. We leave the code here though, because
|
|
|
|
// this part should be fine when the bug is fixed.
|
|
|
|
//
|
|
|
|
// NOTE: when re-enabling, don't forget to uncomment the respective _mapStateToProps line too
|
|
|
|
|
|
|
|
/*
|
2019-06-26 14:59:20 +00:00
|
|
|
const { _reducedUI } = this.props;
|
2017-09-05 22:45:20 +00:00
|
|
|
|
2019-06-26 14:59:20 +00:00
|
|
|
if (_reducedUI) {
|
|
|
|
return this._renderReducedUI();
|
|
|
|
}
|
2019-07-23 14:07:55 +00:00
|
|
|
*/
|
2019-06-26 14:59:20 +00:00
|
|
|
|
|
|
|
return this._renderFullUI();
|
2016-11-29 20:04:56 +00:00
|
|
|
}
|
|
|
|
|
2018-02-16 16:06:03 +00:00
|
|
|
/**
|
|
|
|
* Constructs a style array to handle the hint box animation.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {Array<Object>}
|
|
|
|
*/
|
|
|
|
_getHintBoxStyle() {
|
|
|
|
return [
|
|
|
|
styles.hintContainer,
|
|
|
|
{
|
|
|
|
opacity: this.state.hintBoxAnimation
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback for when the room field's focus changes so the hint box
|
|
|
|
* must be rendered or removed.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @param {boolean} focused - The focused state of the field.
|
2018-05-29 12:51:55 +00:00
|
|
|
* @returns {void}
|
2018-02-16 16:06:03 +00:00
|
|
|
*/
|
|
|
|
_onFieldFocusChange(focused) {
|
2018-05-29 12:51:55 +00:00
|
|
|
focused
|
|
|
|
&& this.setState({
|
|
|
|
_fieldFocused: true
|
|
|
|
});
|
|
|
|
|
|
|
|
Animated.timing(
|
|
|
|
this.state.hintBoxAnimation,
|
|
|
|
{
|
|
|
|
duration: 300,
|
|
|
|
toValue: focused ? 1 : 0
|
|
|
|
})
|
|
|
|
.start(animationState =>
|
|
|
|
animationState.finished
|
|
|
|
&& !focused
|
|
|
|
&& this.setState({
|
|
|
|
_fieldFocused: false
|
|
|
|
}));
|
2018-02-16 16:06:03 +00:00
|
|
|
}
|
|
|
|
|
2018-02-02 14:50:16 +00:00
|
|
|
/**
|
|
|
|
* Toggles the side bar.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onShowSideBar() {
|
2018-02-15 22:58:07 +00:00
|
|
|
Keyboard.dismiss();
|
2018-02-26 16:14:46 +00:00
|
|
|
this.props.dispatch(setSideBarVisible(true));
|
2018-02-02 14:50:16 +00:00
|
|
|
}
|
|
|
|
|
2018-02-16 16:06:03 +00:00
|
|
|
/**
|
|
|
|
* Renders the hint box if necessary.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {React$Node}
|
|
|
|
*/
|
|
|
|
_renderHintBox() {
|
|
|
|
if (this.state._fieldFocused) {
|
|
|
|
const { t } = this.props;
|
|
|
|
|
|
|
|
return (
|
2018-02-26 16:14:46 +00:00
|
|
|
<Animated.View style = { this._getHintBoxStyle() }>
|
2018-02-16 16:06:03 +00:00
|
|
|
<View style = { styles.hintTextContainer } >
|
2018-04-04 12:50:12 +00:00
|
|
|
<Text style = { styles.hintText }>
|
2018-02-26 16:14:46 +00:00
|
|
|
{ t('welcomepage.roomnameHint') }
|
2018-02-16 16:06:03 +00:00
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
<View style = { styles.hintButtonContainer } >
|
2018-02-26 16:14:46 +00:00
|
|
|
{ this._renderJoinButton() }
|
2018-02-16 16:06:03 +00:00
|
|
|
</View>
|
|
|
|
</Animated.View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2017-09-14 09:46:35 +00:00
|
|
|
/**
|
|
|
|
* Renders the join button.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderJoinButton() {
|
2018-06-07 20:32:18 +00:00
|
|
|
const { t } = this.props;
|
2017-09-14 09:46:35 +00:00
|
|
|
let children;
|
|
|
|
|
|
|
|
|
|
|
|
if (this.state.joining) {
|
|
|
|
// TouchableHighlight is picky about what its children can be, so
|
|
|
|
// wrap it in a native component, i.e. View to avoid having to
|
|
|
|
// modify non-native children.
|
|
|
|
children = (
|
|
|
|
<View>
|
2018-02-16 16:06:03 +00:00
|
|
|
<LoadingIndicator
|
|
|
|
color = { styles.buttonText.color }
|
|
|
|
size = 'small' />
|
2017-09-14 09:46:35 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
children = (
|
|
|
|
<Text style = { styles.buttonText }>
|
|
|
|
{ this.props.t('welcomepage.join') }
|
|
|
|
</Text>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<TouchableHighlight
|
2018-06-07 20:32:18 +00:00
|
|
|
accessibilityLabel =
|
|
|
|
{ t('welcomepage.accessibilityLabel.join') }
|
2017-09-14 09:46:35 +00:00
|
|
|
onPress = { this._onJoin }
|
2020-03-27 12:48:33 +00:00
|
|
|
style = { styles.button }
|
2017-09-14 09:46:35 +00:00
|
|
|
underlayColor = { ColorPalette.white }>
|
2018-05-07 15:03:59 +00:00
|
|
|
{ children }
|
2017-09-14 09:46:35 +00:00
|
|
|
</TouchableHighlight>
|
|
|
|
);
|
|
|
|
}
|
2019-06-26 14:59:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the full welcome page.
|
|
|
|
*
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderFullUI() {
|
|
|
|
const roomnameAccLabel = 'welcomepage.accessibilityLabel.roomname';
|
|
|
|
const { _headerStyles, t } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<LocalVideoTrackUnderlay style = { styles.welcomePage }>
|
|
|
|
<View style = { _headerStyles.page }>
|
|
|
|
<Header style = { styles.header }>
|
|
|
|
<TouchableOpacity onPress = { this._onShowSideBar } >
|
|
|
|
<Icon
|
2019-08-30 16:39:06 +00:00
|
|
|
src = { IconMenu }
|
2019-06-26 14:59:20 +00:00
|
|
|
style = { _headerStyles.headerButtonIcon } />
|
|
|
|
</TouchableOpacity>
|
|
|
|
<VideoSwitch />
|
|
|
|
</Header>
|
|
|
|
<SafeAreaView style = { styles.roomContainer } >
|
|
|
|
<View style = { styles.joinControls } >
|
2020-03-27 12:48:33 +00:00
|
|
|
<Text style = { styles.enterRoomText }>
|
|
|
|
{ t('welcomepage.roomname') }
|
|
|
|
</Text>
|
2019-06-26 14:59:20 +00:00
|
|
|
<TextInput
|
|
|
|
accessibilityLabel = { t(roomnameAccLabel) }
|
|
|
|
autoCapitalize = 'none'
|
|
|
|
autoComplete = 'off'
|
|
|
|
autoCorrect = { false }
|
|
|
|
autoFocus = { false }
|
|
|
|
onBlur = { this._onFieldBlur }
|
|
|
|
onChangeText = { this._onRoomChange }
|
|
|
|
onFocus = { this._onFieldFocus }
|
|
|
|
onSubmitEditing = { this._onJoin }
|
2020-03-27 12:48:33 +00:00
|
|
|
placeholder = { this.state.roomPlaceholder }
|
|
|
|
placeholderTextColor = { PLACEHOLDER_TEXT_COLOR }
|
2019-06-26 14:59:20 +00:00
|
|
|
returnKeyType = { 'go' }
|
|
|
|
style = { styles.textInput }
|
|
|
|
underlineColorAndroid = 'transparent'
|
|
|
|
value = { this.state.room } />
|
|
|
|
{
|
|
|
|
this._renderHintBox()
|
|
|
|
}
|
|
|
|
</View>
|
|
|
|
</SafeAreaView>
|
|
|
|
<WelcomePageLists disabled = { this.state._fieldFocused } />
|
|
|
|
</View>
|
|
|
|
<WelcomePageSideBar />
|
2020-04-06 15:14:32 +00:00
|
|
|
{ this._renderWelcomePageModals() }
|
2019-06-26 14:59:20 +00:00
|
|
|
</LocalVideoTrackUnderlay>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders a "reduced" version of the welcome page.
|
|
|
|
*
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderReducedUI() {
|
|
|
|
const { t } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View style = { styles.reducedUIContainer }>
|
|
|
|
<Text style = { styles.reducedUIText }>
|
|
|
|
{ t('welcomepage.reducedUIText', { app: getName() }) }
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2020-04-06 15:14:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders JitsiModals that are supposed to be on the welcome page.
|
|
|
|
*
|
|
|
|
* @returns {Array<ReactElement>}
|
|
|
|
*/
|
|
|
|
_renderWelcomePageModals() {
|
|
|
|
return [
|
|
|
|
<HelpView key = 'helpView' />,
|
|
|
|
<DialInSummary key = 'dialInSummary' />,
|
|
|
|
<SettingsView key = 'settings' />
|
|
|
|
];
|
|
|
|
}
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
|
2019-03-05 17:41:39 +00:00
|
|
|
/**
|
|
|
|
* Maps part of the Redux state to the props of this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
2019-06-26 14:59:20 +00:00
|
|
|
* @returns {Object}
|
2019-03-05 17:41:39 +00:00
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
|
|
|
return {
|
|
|
|
..._abstractMapStateToProps(state),
|
2019-07-23 14:07:55 +00:00
|
|
|
_headerStyles: ColorSchemeRegistry.get(state, 'Header')
|
|
|
|
|
|
|
|
// _reducedUI: state['features/base/responsive-ui'].reducedUI
|
2019-03-05 17:41:39 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-02-23 16:56:25 +00:00
|
|
|
export default translate(connect(_mapStateToProps)(WelcomePage));
|