import React from 'react';
import { Animated, SafeAreaView, TouchableHighlight, View } from 'react-native';
import { getName } from '../../app/functions';
import { translate } from '../../base/i18n';
import { Icon, IconWarning } from '../../base/icons';
import { LoadingIndicator, Text } from '../../base/react';
import { connect } from '../../base/redux';
import BaseTheme from '../../base/ui/components/BaseTheme.native';
import Button from '../../base/ui/components/native/Button';
import Input from '../../base/ui/components/native/Input';
import { BUTTON_TYPES } from '../../base/ui/constants.native';
import WelcomePageTabs
from '../../mobile/navigation/components/welcome/components/WelcomePageTabs';
import {
type Props as AbstractProps,
AbstractWelcomePage,
_mapStateToProps as _abstractMapStateToProps
} from './AbstractWelcomePage';
import styles from './styles';
type Props = AbstractProps & {
/**
* Default prop for navigating between screen components(React Navigation).
*/
navigation: Object,
/**
* The translate function.
*/
t: Function
};
/**
* The native container rendering the welcome page.
*
* @augments AbstractWelcomePage
*/
class WelcomePage extends AbstractWelcomePage<*> {
/**
* Constructor of the Component.
*
* @inheritdoc
*/
constructor(props: Props) {
super(props);
this.state._fieldFocused = false;
this.state.isSettingsScreenFocused = false;
this.state.roomNameInputAnimation = new Animated.Value(1);
this.state.hintBoxAnimation = new Animated.Value(0);
// Bind event handlers so they are only bound once per instance.
this._onFieldFocusChange = this._onFieldFocusChange.bind(this);
this._renderHintBox = this._renderHintBox.bind(this);
// Specially bind functions to avoid function definition on render.
this._onFieldBlur = this._onFieldFocusChange.bind(this, false);
this._onFieldFocus = this._onFieldFocusChange.bind(this, true);
this._onSettingsScreenFocused = this._onSettingsScreenFocused.bind(this);
}
_onFieldBlur: () => void;
_onFieldFocus: () => void;
_onJoin: () => void;
_onRoomChange: (string) => void;
_updateRoomname: () => void;
/**
* Implements React's {@link Component#componentDidMount()}. Invoked
* immediately after mounting occurs. Creates a local video track if none
* is available and the camera permission was already granted.
*
* @inheritdoc
* @returns {void}
*/
componentDidMount() {
super.componentDidMount();
const {
navigation,
t
} = this.props;
navigation.setOptions({
headerTitle: t('welcomepage.headerTitle')
});
navigation.addListener('focus', () => {
this._updateRoomname();
});
navigation.addListener('blur', () => {
this._clearTimeouts();
this.setState({
generatedRoomname: '',
insecureRoomName: false,
room: ''
});
});
}
/**
* Implements React's {@link Component#render()}. Renders a prompt for
* entering a room name.
*
* @inheritdoc
* @returns {ReactElement}
*/
render() {
// 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
/*
const { _reducedUI } = this.props;
if (_reducedUI) {
return this._renderReducedUI();
}
*/
return this._renderFullUI();
}
/**
* Renders the insecure room name warning.
*
* @inheritdoc
*/
_doRenderInsecureRoomNameWarning() {
return (
{ this.props.t('security.insecureRoomNameWarning') }
);
}
/**
* Constructs a style array to handle the hint box animation.
*
* @private
* @returns {Array