You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IncomingCallPage.js 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { Image, Text, View } from 'react-native';
  4. import LinearGradient from 'react-native-linear-gradient';
  5. import { connect } from 'react-redux';
  6. import { translate } from '../../../base/i18n';
  7. import { Avatar } from '../../../base/participants';
  8. import AnswerButton from './AnswerButton';
  9. import DeclineButton from './DeclineButton';
  10. import styles, {
  11. AVATAR_BORDER_GRADIENT,
  12. BACKGROUND_OVERLAY_GRADIENT,
  13. CALLER_AVATAR_SIZE
  14. } from './styles';
  15. /**
  16. * The type of React {@code Component} props of {@link IncomingCallPage}.
  17. */
  18. type Props = {
  19. /**
  20. * Caller's avatar URL.
  21. */
  22. _callerAvatarUrl: string,
  23. /**
  24. * Caller's name.
  25. */
  26. _callerName: string,
  27. /**
  28. * Whether the call has video or not.
  29. */
  30. _hasVideo: boolean,
  31. /**
  32. * Helper for translating strings.
  33. */
  34. t: Function
  35. };
  36. /**
  37. * The React {@code Component} displays an incoming call screen.
  38. */
  39. class IncomingCallPage extends Component<Props> {
  40. /**
  41. * Implements React's {@link Component#render()}.
  42. *
  43. * @inheritdoc
  44. * @returns {ReactElement}
  45. */
  46. render() {
  47. const { t, _callerName, _hasVideo } = this.props;
  48. const callTitle
  49. = _hasVideo
  50. ? t('incomingCall.videoCallTitle')
  51. : t('incomingCall.audioCallTitle');
  52. return (
  53. <View style = { styles.pageContainer }>
  54. <View style = { styles.backgroundAvatar }>
  55. <Image
  56. source = {{ uri: this.props._callerAvatarUrl }}
  57. style = { styles.backgroundAvatarImage } />
  58. </View>
  59. <LinearGradient
  60. colors = { BACKGROUND_OVERLAY_GRADIENT }
  61. style = { styles.backgroundOverlayGradient } />
  62. <Text style = { styles.title }>
  63. { callTitle }
  64. </Text>
  65. <Text
  66. numberOfLines = { 6 }
  67. style = { styles.callerName } >
  68. { _callerName }
  69. </Text>
  70. <Text style = { styles.productLabel }>
  71. { t('incomingCall.productLabel') }
  72. </Text>
  73. { this._renderCallerAvatar() }
  74. { this._renderButtons() }
  75. </View>
  76. );
  77. }
  78. /**
  79. * Renders caller avatar.
  80. *
  81. * @private
  82. * @returns {React$Node}
  83. */
  84. _renderCallerAvatar() {
  85. return (
  86. <View style = { styles.avatarContainer }>
  87. <LinearGradient
  88. colors = { AVATAR_BORDER_GRADIENT }
  89. style = { styles.avatarBorder } />
  90. <View style = { styles.avatar }>
  91. <Avatar
  92. size = { CALLER_AVATAR_SIZE }
  93. uri = { this.props._callerAvatarUrl } />
  94. </View>
  95. </View>
  96. );
  97. }
  98. /**
  99. * Renders buttons.
  100. *
  101. * @private
  102. * @returns {React$Node}
  103. */
  104. _renderButtons() {
  105. const { t } = this.props;
  106. return (
  107. <View style = { styles.buttonsContainer }>
  108. <View style = { styles.buttonWrapper } >
  109. <DeclineButton
  110. styles = { styles.declineButtonStyles } />
  111. <Text style = { styles.buttonText }>
  112. { t('incomingCall.decline') }
  113. </Text>
  114. </View>
  115. <View style = { styles.buttonWrapper }>
  116. <AnswerButton
  117. styles = { styles.answerButtonStyles } />
  118. <Text style = { styles.buttonText }>
  119. { t('incomingCall.answer') }
  120. </Text>
  121. </View>
  122. </View>
  123. );
  124. }
  125. }
  126. /**
  127. * Maps (parts of) the redux state to the component's props.
  128. *
  129. * @param {Object} state - The redux state.
  130. * @param {Object} ownProps - The component's own props.
  131. * @private
  132. * @returns {{
  133. * _callerName: string,
  134. * _callerAvatarUrl: string,
  135. * _hasVideo: boolean
  136. * }}
  137. */
  138. function _mapStateToProps(state) {
  139. const { caller } = state['features/mobile/incoming-call'] || {};
  140. return {
  141. /**
  142. * The caller's avatar url.
  143. *
  144. * @private
  145. * @type {string}
  146. */
  147. _callerAvatarUrl: caller.avatarUrl,
  148. /**
  149. * The caller's name.
  150. *
  151. * @private
  152. * @type {string}
  153. */
  154. _callerName: caller.name,
  155. /**
  156. * Whether the call has video or not.
  157. *
  158. * @private
  159. * @type {boolean}
  160. */
  161. _hasVideo: caller.hasVideo
  162. };
  163. }
  164. export default translate(connect(_mapStateToProps)(IncomingCallPage));