From ee3cd30b590cd60d2774147c52c5e163f1b4ce2c Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Sat, 10 Jun 2017 17:52:36 -0500 Subject: [PATCH] [RN] Fix call/ring overlay --- react/features/jwt/components/CallOverlay.js | 67 +++++++++++++++++-- .../features/jwt/components/styles.native.js | 51 ++++++++++++++ react/features/jwt/components/styles.web.js | 0 3 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 react/features/jwt/components/styles.native.js create mode 100644 react/features/jwt/components/styles.web.js diff --git a/react/features/jwt/components/CallOverlay.js b/react/features/jwt/components/CallOverlay.js index ec52d3b2d..87d35d584 100644 --- a/react/features/jwt/components/CallOverlay.js +++ b/react/features/jwt/components/CallOverlay.js @@ -8,6 +8,8 @@ import { Avatar } from '../../base/participants'; import { Container, Text } from '../../base/react'; import UIEvents from '../../../../service/UI/UIEvents'; +import styles from './styles'; + declare var $: Object; declare var APP: Object; declare var interfaceConfig: Object; @@ -160,17 +162,22 @@ class CallOverlay extends Component { return ( - - { ringing ? Calling... : null } + + + { ringing ? 'Calling...' : '' } + - - + + { name } - { ringing ? null : ' isn\'t available' } + { ringing ? '' : ' isn\'t available' } @@ -263,6 +270,52 @@ class CallOverlay extends Component { _setAudio(audio) { this._audio = audio; } + + /** + * Attempts to convert specified CSS class names into React + * {@link Component} props {@code style} or {@code className}. + * + * @param {Array} classNames - The CSS class names to convert + * into React {@code Component} props {@code style} or {@code className}. + * @returns {{ + * className: string, + * style: Object + * }} + */ + _style(...classNames: Array) { + let className = ''; + let style; + + for (const aClassName of classNames) { + if (aClassName) { + // Attemp to convert aClassName into style. + if (styles && aClassName in styles) { + // React Native will accept an Array as the value of the + // style prop. However, I do not know about React. + style = { + ...style, + ...styles[aClassName] + }; + } else { + // Otherwise, leave it as className. + className += aClassName; + } + } + } + + // Choose which of the className and/or style props has a value and, + // consequently, must be returned. + const props = {}; + + if (className) { + props.className = className; + } + if (style) { + props.style = style; + } + + return props; + } } /** diff --git a/react/features/jwt/components/styles.native.js b/react/features/jwt/components/styles.native.js new file mode 100644 index 000000000..8fa3b0cfd --- /dev/null +++ b/react/features/jwt/components/styles.native.js @@ -0,0 +1,51 @@ +import { ColorPalette, createStyleSheet } from '../../base/styles'; + +export default createStyleSheet({ + // XXX The names bellow were preserved for the purposes of compatibility + // with the existing CSS class names on Web. + + /** + * The style of {@code CallOverlay}. + */ + ringing: { + alignItems: 'center', + backgroundColor: ColorPalette.black, + bottom: 0, + flex: 0, + flexDirection: 'column', + justifyContent: 'center', + left: 0, + opacity: 0.8, + position: 'absolute', + right: 0, + top: 0 + }, + + 'ringing__avatar': { + borderRadius: 50, + flex: 0, + height: 100, + width: 100 + }, + + 'ringing__caller-info': { + alignItems: 'center', + flex: 0, + flexDirection: 'row', + justifyContent: 'center' + }, + + 'ringing__content': { + alignItems: 'center', + flex: 0, + flexDirection: 'column', + justifyContent: 'center' + }, + + /** + * The style of {@code Text} within {@code CallOverlay}. + */ + 'ringing__text': { + color: ColorPalette.white + } +}); diff --git a/react/features/jwt/components/styles.web.js b/react/features/jwt/components/styles.web.js new file mode 100644 index 000000000..e69de29bb