From e08d240a89279b088410ded2bb99dd17139c8eb8 Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Mon, 25 Sep 2017 14:42:15 -0500 Subject: [PATCH] [RN] Render bold text in WaitForOwnerDialog --- .../components/LoginDialog.native.js | 6 +-- .../components/WaitForOwnerDialog.native.js | 44 +++++++++++++++++-- .../authentication/components/styles.js | 29 ++++++++---- 3 files changed, 63 insertions(+), 16 deletions(-) diff --git a/react/features/authentication/components/LoginDialog.native.js b/react/features/authentication/components/LoginDialog.native.js index 0cc66c008d..103ec7ae84 100644 --- a/react/features/authentication/components/LoginDialog.native.js +++ b/react/features/authentication/components/LoginDialog.native.js @@ -159,15 +159,15 @@ class LoginDialog extends Component { autoCorrect = { false } onChangeText = { this._onUsernameChange } placeholder = { 'user@domain.com' } - style = { styles.loginDialogTextInput } + style = { styles.dialogTextInput } value = { this.state.username } /> - + { messageKey ? t(messageKey, messageOptions || {}) diff --git a/react/features/authentication/components/WaitForOwnerDialog.native.js b/react/features/authentication/components/WaitForOwnerDialog.native.js index 2e16ae925e..3fe0c1cfff 100644 --- a/react/features/authentication/components/WaitForOwnerDialog.native.js +++ b/react/features/authentication/components/WaitForOwnerDialog.native.js @@ -104,13 +104,49 @@ class WaitForOwnerDialog extends Component { * * @param {string} html - The string which may contain HTML to * render. - * @returns {string} + * @returns {ReactElement[]|string} */ _renderHTML(html) { if (typeof html === 'string') { - // TODO Limited styling may easily be provided by utilizing Text - // with style. - return html.replace(/<\/?b>/gi, ''); + // 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 text 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( + + { html.substring(opening.lastIndex, c.index) } + ); + opening.lastIndex + = prevClosingLastIndex + = closing.lastIndex; + } else { + break; + } + } + if (prevClosingLastIndex < html.length) { + r.push(html.substring(prevClosingLastIndex)); + } + + return r; } return html; diff --git a/react/features/authentication/components/styles.js b/react/features/authentication/components/styles.js index 54b70ef646..696f7d8604 100644 --- a/react/features/authentication/components/styles.js +++ b/react/features/authentication/components/styles.js @@ -20,31 +20,42 @@ const text = { */ export default createStyleSheet({ /** - * The style of LoginDialog. + * The style of bold Text rendered by the Dialogs of the + * feature authentication. */ - loginDialog: { - ...dialog, - flex: 0, - flexDirection: 'column' + boldDialogText: { + ...text, + fontWeight: 'bold' }, /** - * The style of Text rendered by LoginDialog. + * The style of Text rendered by the Dialogs of the + * feature authentication. */ - loginDialogText: { + dialogText: { ...text }, /** - * The style of TextInput rendered by LoginDialog. + * The style of TextInput rendered by the Dialogs of the + * feature authentication. */ - loginDialogTextInput: { + dialogTextInput: { // XXX Matches react-native-prompt's dialogInput because base/dialog's // Dialog is implemented using react-native-prompt. fontSize: 18, height: 50 }, + /** + * The style of LoginDialog. + */ + loginDialog: { + ...dialog, + flex: 0, + flexDirection: 'column' + }, + /** * The style of WaitForOwnerDialog. */