Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

BrandingImageBackground.tsx 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import React from 'react';
  2. import { Image, ImageStyle, StyleProp, ViewStyle } from 'react-native';
  3. import { SvgUri } from 'react-native-svg';
  4. import { connect } from '../../../base/redux/functions';
  5. import styles from './styles';
  6. interface Props {
  7. uri?: any;
  8. }
  9. /**
  10. * Component that displays a branding background image.
  11. *
  12. * @param {Props} props - The props of the component.
  13. * @returns {ReactElement}
  14. */
  15. const BrandingImageBackground: React.FC<Props> = ({ uri }:Props) => {
  16. const imageType = uri?.substr(uri.lastIndexOf('/') + 1);
  17. const imgSrc = uri ? uri : undefined;
  18. let backgroundImage;
  19. if (!uri) {
  20. return null;
  21. }
  22. if (imageType?.includes('.svg')) {
  23. backgroundImage
  24. = (
  25. <SvgUri
  26. height = '100%'
  27. // Force uniform scaling.
  28. // Align the <min-x> of the element's viewBox
  29. // with the smallest X value of the viewport.
  30. // Align the <min-y> of the element's viewBox
  31. // with the smallest Y value of the viewport.
  32. preserveAspectRatio = 'xMinYMin'
  33. style = { styles.brandingImageBackgroundSvg as StyleProp<ViewStyle> }
  34. uri = { imgSrc }
  35. viewBox = '0 0 400 650'
  36. width = '100%' />
  37. );
  38. } else {
  39. backgroundImage
  40. = (
  41. <Image
  42. source = {{ uri: imgSrc }}
  43. style = { styles.brandingImageBackground as StyleProp<ImageStyle> } />
  44. );
  45. }
  46. return backgroundImage;
  47. };
  48. /**
  49. * Maps (parts of) the Redux state to the associated props for the
  50. * {@code DialInLink} component.
  51. *
  52. * @param {Object} state - The Redux state.
  53. * @private
  54. * @returns {Props}
  55. */
  56. function _mapStateToProps(state: any) {
  57. const { backgroundImageUrl } = state['features/dynamic-branding'];
  58. return {
  59. uri: backgroundImageUrl
  60. };
  61. }
  62. export default connect(_mapStateToProps)(BrandingImageBackground);