import React from 'react';
import { Image, View } from 'react-native';
import { Text } from 'react-native-paper';
import { connect } from 'react-redux';
import { translate } from '../../../../base/i18n/functions';
import Icon from '../../../../base/icons/components/Icon';
import { IconArrowDown, IconArrowRight } from '../../../../base/icons/svg';
import LoadingIndicator from '../../../../base/react/components/native/LoadingIndicator';
import Button from '../../../../base/ui/components/native/Button';
import Switch from '../../../../base/ui/components/native/Switch';
import { BUTTON_TYPES } from '../../../../base/ui/constants.native';
import { RECORDING_TYPES } from '../../../constants';
import { getRecordingDurationEstimation } from '../../../functions';
import AbstractStartRecordingDialogContent, { mapStateToProps } from '../AbstractStartRecordingDialogContent';
import {
DROPBOX_LOGO,
ICON_CLOUD,
ICON_INFO,
ICON_USERS
} from '../styles.native';
/**
* The start recording dialog content for the mobile application.
*/
class StartRecordingDialogContent extends AbstractStartRecordingDialogContent {
/**
* Renders the component.
*
* @protected
* @returns {React$Component}
*/
render() {
const { _styles: styles } = this.props;
return (
{ this._renderNoIntegrationsContent() }
{ this._renderFileSharingContent() }
{ this._renderUploadToTheCloudInfo() }
{ this._renderIntegrationsContent() }
{ this._renderAdvancedOptions() }
);
}
/**
* Renders the save transcription switch.
*
* @returns {React$Component}
*/
_renderAdvancedOptions() {
const { selectedRecordingService } = this.props;
if (selectedRecordingService !== RECORDING_TYPES.JITSI_REC_SERVICE || !this._canStartTranscribing()) {
return null;
}
const { showAdvancedOptions } = this.state;
const {
_dialogStyles,
_styles: styles,
shouldRecordAudioAndVideo,
shouldRecordTranscription,
t
} = this.props;
return (
<>
{ t('recording.showAdvancedOptions') }
{showAdvancedOptions && (
<>
{ t('recording.recordTranscription') }
{ t('recording.recordAudioAndVideo') }
>
)}
>
);
}
/**
* Renders the content in case no integrations were enabled.
*
* @returns {React$Component}
*/
_renderNoIntegrationsContent() {
const {
_dialogStyles,
_styles: styles,
integrationsEnabled,
isValidating,
selectedRecordingService,
shouldRecordAudioAndVideo,
t
} = this.props;
if (!this._shouldRenderNoIntegrationsContent()) {
return null;
}
const switchContent
= integrationsEnabled
? (
) : null;
return (
{ t('recording.serviceDescription') }
{ switchContent }
);
}
/**
* Renders the file recording service sharing options, if enabled.
*
* @returns {React$Component}
*/
_renderFileSharingContent() {
if (!this._shouldRenderFileSharingContent()) {
return null;
}
const {
_dialogStyles,
_styles: styles,
isValidating,
onSharingSettingChanged,
sharingSetting,
shouldRecordAudioAndVideo,
t
} = this.props;
return (
{ t('recording.fileSharingdescription') }
);
}
/**
* Renders the info in case recording is uploaded to the cloud.
*
* @returns {React$Component}
*/
_renderUploadToTheCloudInfo() {
const {
_dialogStyles,
_hideStorageWarning,
_styles: styles,
isVpaas,
selectedRecordingService,
t
} = this.props;
if (!(isVpaas && selectedRecordingService === RECORDING_TYPES.JITSI_REC_SERVICE) || _hideStorageWarning) {
return null;
}
return (
{ t('recording.serviceDescriptionCloudInfo') }
);
}
/**
* Renders a spinner component.
*
* @returns {React$Component}
*/
_renderSpinner() {
return (
);
}
/**
* Renders the screen with the account information of a logged in user.
*
* @returns {React$Component}
*/
_renderSignOut() {
const { _styles: styles, spaceLeft, t, userName } = this.props;
const duration = getRecordingDurationEstimation(spaceLeft);
return (
{ t('recording.loggedIn', { userName }) }
{
t('recording.availableSpace', {
spaceLeft,
duration
})
}
);
}
/**
* Renders the content in case integrations were enabled.
*
* @protected
* @returns {React$Component}
*/
_renderIntegrationsContent() {
if (!this._shouldRenderIntegrationsContent()) {
return null;
}
const {
_dialogStyles,
_styles: styles,
fileRecordingsServiceEnabled,
isTokenValid,
isValidating,
selectedRecordingService,
shouldRecordAudioAndVideo,
t
} = this.props;
let content = null;
let switchContent = null;
if (isValidating) {
content = this._renderSpinner();
switchContent = ;
} else if (isTokenValid) {
content = this._renderSignOut();
switchContent = (
);
} else {
switchContent = (
);
}
if (fileRecordingsServiceEnabled) {
switchContent = (
);
}
return (
{ t('recording.authDropboxText') }
{ switchContent }
{ content }
);
}
}
export default translate(connect(mapStateToProps)(StartRecordingDialogContent));