[RN] Make feature dialogs branded: authentication
This commit is contained in:
committed by
Saúl Ibarra Corretgé
parent
22a602768c
commit
9645de33bc
@@ -1,14 +1,12 @@
|
||||
// @flow
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import { Text } from 'react-native';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { Dialog } from '../../base/dialog';
|
||||
import { ConfirmDialog } from '../../base/dialog';
|
||||
import { translate } from '../../base/i18n';
|
||||
|
||||
import { cancelWaitForOwner, _openLoginDialog } from '../actions';
|
||||
import styles from './styles';
|
||||
|
||||
/**
|
||||
* The type of the React {@code Component} props of {@link WaitForOwnerDialog}.
|
||||
@@ -60,22 +58,19 @@ class WaitForOwnerDialog extends Component<Props> {
|
||||
*/
|
||||
render() {
|
||||
const {
|
||||
_room: room,
|
||||
t
|
||||
_room: room
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
okTitleKey = { 'dialog.IamHost' }
|
||||
onCancel = { this._onCancel }
|
||||
onSubmit = { this._onLogin }
|
||||
titleKey = 'dialog.WaitingForHost'>
|
||||
<Text style = { styles.waitForOwnerDialog }>
|
||||
<ConfirmDialog
|
||||
contentKey = {
|
||||
{
|
||||
this._renderHTML(t('dialog.WaitForHostMsg', { room }))
|
||||
key: 'dialog.WaitForHostMsgWOk',
|
||||
params: { room }
|
||||
}
|
||||
</Text>
|
||||
</Dialog>
|
||||
}
|
||||
onCancel = { this._onCancel }
|
||||
onSubmit = { this._onLogin } />
|
||||
);
|
||||
}
|
||||
|
||||
@@ -102,59 +97,6 @@ class WaitForOwnerDialog extends Component<Props> {
|
||||
_onLogin() {
|
||||
this.props.dispatch(_openLoginDialog());
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a specific {@code string} which may contain HTML.
|
||||
*
|
||||
* @param {string|undefined} html - The {@code string} which may
|
||||
* contain HTML to render.
|
||||
* @returns {ReactElement[]|string}
|
||||
*/
|
||||
_renderHTML(html: ?string) {
|
||||
if (typeof html === 'string') {
|
||||
// At the time of this writing, the specified HTML contains a couple
|
||||
// of spaces one after the other. They do not cause a visible
|
||||
// problem on Web, because the specified HTML is rendered as, well,
|
||||
// HTML. However, we're not rendering HTML here.
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
html = html.replace(/\s{2,}/gi, ' ');
|
||||
|
||||
// Render text in <b>text</b> in bold.
|
||||
const opening = /<\s*b\s*>/gi;
|
||||
const closing = /<\s*\/\s*b\s*>/gi;
|
||||
let o;
|
||||
let c;
|
||||
let prevClosingLastIndex = 0;
|
||||
const r = [];
|
||||
|
||||
// eslint-disable-next-line no-cond-assign
|
||||
while (o = opening.exec(html)) {
|
||||
closing.lastIndex = opening.lastIndex;
|
||||
|
||||
// eslint-disable-next-line no-cond-assign
|
||||
if (c = closing.exec(html)) {
|
||||
r.push(html.substring(prevClosingLastIndex, o.index));
|
||||
r.push(
|
||||
<Text style = { styles.boldDialogText }>
|
||||
{ html.substring(opening.lastIndex, c.index) }
|
||||
</Text>);
|
||||
opening.lastIndex
|
||||
= prevClosingLastIndex
|
||||
= closing.lastIndex;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (prevClosingLastIndex < html.length) {
|
||||
r.push(html.substring(prevClosingLastIndex));
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user