Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

IncomingCallPage.js 4.3KB

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