2019-05-07 14:50:57 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React, { Component } from 'react';
|
2022-02-11 09:49:49 +00:00
|
|
|
import { Linking, Platform, View } from 'react-native';
|
2019-05-07 14:50:57 +00:00
|
|
|
import { WebView } from 'react-native-webview';
|
|
|
|
import { type Dispatch } from 'redux';
|
|
|
|
|
|
|
|
import { openDialog } from '../../../../base/dialog';
|
|
|
|
import { translate } from '../../../../base/i18n';
|
2022-02-11 09:49:49 +00:00
|
|
|
import { IconClose } from '../../../../base/icons';
|
2021-11-11 14:32:56 +00:00
|
|
|
import JitsiScreen from '../../../../base/modal/components/JitsiScreen';
|
2020-04-06 15:25:30 +00:00
|
|
|
import { LoadingIndicator } from '../../../../base/react';
|
2019-05-07 14:50:57 +00:00
|
|
|
import { connect } from '../../../../base/redux';
|
2022-02-11 09:49:49 +00:00
|
|
|
import HeaderNavigationButton
|
|
|
|
from '../../../../mobile/navigation/components/HeaderNavigationButton';
|
|
|
|
import { navigateRoot } from '../../../../mobile/navigation/rootNavigationContainerRef';
|
2022-01-25 12:55:57 +00:00
|
|
|
import { screen } from '../../../../mobile/navigation/routes';
|
2019-05-07 14:50:57 +00:00
|
|
|
import { getDialInfoPageURLForURIString } from '../../../functions';
|
|
|
|
|
|
|
|
import DialInSummaryErrorDialog from './DialInSummaryErrorDialog';
|
|
|
|
import styles, { INDICATOR_COLOR } from './styles';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
2021-11-11 14:32:56 +00:00
|
|
|
dispatch: Dispatch<any>,
|
|
|
|
|
2019-05-07 14:50:57 +00:00
|
|
|
/**
|
2021-11-11 14:32:56 +00:00
|
|
|
* Default prop for navigating between screen components(React Navigation).
|
2019-05-07 14:50:57 +00:00
|
|
|
*/
|
2021-11-11 14:32:56 +00:00
|
|
|
navigation: Object,
|
2019-05-07 14:50:57 +00:00
|
|
|
|
2021-11-11 14:32:56 +00:00
|
|
|
/**
|
|
|
|
* Default prop for navigating between screen components(React Navigation).
|
|
|
|
*/
|
2022-02-11 09:49:49 +00:00
|
|
|
route: Object,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Translation function.
|
|
|
|
*/
|
|
|
|
t: Function
|
2019-05-07 14:50:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a React native component that displays the dial in info page for a specific room.
|
|
|
|
*/
|
|
|
|
class DialInSummary extends Component<Props> {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes a new instance.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
2022-02-11 09:49:49 +00:00
|
|
|
this._onNavigateToRoot = this._onNavigateToRoot.bind(this);
|
2019-05-07 14:50:57 +00:00
|
|
|
this._onError = this._onError.bind(this);
|
|
|
|
this._onNavigate = this._onNavigate.bind(this);
|
|
|
|
this._renderLoading = this._renderLoading.bind(this);
|
|
|
|
}
|
|
|
|
|
2021-11-11 14:32:56 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#componentDidMount()}. Invoked
|
|
|
|
* immediately after mounting occurs.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
componentDidMount() {
|
2022-02-11 09:49:49 +00:00
|
|
|
const { navigation, t } = this.props;
|
2021-11-11 14:32:56 +00:00
|
|
|
|
|
|
|
navigation.setOptions({
|
2022-02-11 09:49:49 +00:00
|
|
|
headerLeft: () => {
|
|
|
|
if (Platform.OS === 'ios') {
|
|
|
|
return (
|
|
|
|
<HeaderNavigationButton
|
|
|
|
label = { t('dialog.close') }
|
|
|
|
onPress = { this._onNavigateToRoot } />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<HeaderNavigationButton
|
|
|
|
onPress = { this._onNavigateToRoot }
|
|
|
|
src = { IconClose } />
|
|
|
|
);
|
|
|
|
}
|
2021-11-11 14:32:56 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-05-07 14:50:57 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
render() {
|
2021-11-11 14:32:56 +00:00
|
|
|
const { route } = this.props;
|
|
|
|
const summaryUrl = route.params?.summaryUrl;
|
2019-05-07 14:50:57 +00:00
|
|
|
|
|
|
|
return (
|
2021-11-11 14:32:56 +00:00
|
|
|
<JitsiScreen
|
2021-05-14 16:03:23 +00:00
|
|
|
style = { styles.backDrop }>
|
2020-04-06 15:25:30 +00:00
|
|
|
<WebView
|
|
|
|
onError = { this._onError }
|
|
|
|
onShouldStartLoadWithRequest = { this._onNavigate }
|
|
|
|
renderLoading = { this._renderLoading }
|
2021-11-11 14:32:56 +00:00
|
|
|
setSupportMultipleWindows = { false }
|
|
|
|
source = {{ uri: getDialInfoPageURLForURIString(summaryUrl) }}
|
2020-04-06 15:25:30 +00:00
|
|
|
startInLoadingState = { true }
|
|
|
|
style = { styles.webView } />
|
2021-11-11 14:32:56 +00:00
|
|
|
</JitsiScreen>
|
2019-05-07 14:50:57 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-02-11 09:49:49 +00:00
|
|
|
_onNavigateToRoot: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to handle navigation back to root.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onNavigateToRoot() {
|
|
|
|
navigateRoot(screen.root);
|
|
|
|
}
|
|
|
|
|
2019-05-07 14:50:57 +00:00
|
|
|
_onError: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to handle the error if the page fails to load.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onError() {
|
|
|
|
this.props.dispatch(openDialog(DialInSummaryErrorDialog));
|
|
|
|
}
|
|
|
|
|
|
|
|
_onNavigate: Object => Boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback to intercept navigation inside the webview and make the native app handle the dial requests.
|
|
|
|
*
|
|
|
|
* NOTE: We don't navigate to anywhere else form that view.
|
|
|
|
*
|
|
|
|
* @param {any} request - The request object.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
_onNavigate(request) {
|
|
|
|
const { url } = request;
|
2021-11-11 14:32:56 +00:00
|
|
|
const { route } = this.props;
|
|
|
|
const summaryUrl = route.params?.summaryUrl;
|
2019-05-07 14:50:57 +00:00
|
|
|
|
|
|
|
if (url.startsWith('tel:')) {
|
|
|
|
Linking.openURL(url);
|
|
|
|
}
|
|
|
|
|
2021-11-11 14:32:56 +00:00
|
|
|
return url === getDialInfoPageURLForURIString(summaryUrl);
|
2019-05-07 14:50:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_renderLoading: () => React$Component<any>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the loading indicator.
|
|
|
|
*
|
|
|
|
* @returns {React$Component<any>}
|
|
|
|
*/
|
|
|
|
_renderLoading() {
|
|
|
|
return (
|
|
|
|
<View style = { styles.indicatorWrapper }>
|
|
|
|
<LoadingIndicator
|
|
|
|
color = { INDICATOR_COLOR }
|
|
|
|
size = 'large' />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-11 14:32:56 +00:00
|
|
|
export default translate(connect()(DialInSummary));
|