@shoutem/ui 9.0.0-rc.5 → 9.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,24 +6,27 @@ import { connectAnimation } from '@shoutem/animation';
6
6
  import { connectStyle } from '@shoutem/theme';
7
7
  import VideoSourceReader from './VideoSourceReader';
8
8
 
9
- function getSource(sourceReader, poster) {
9
+ function getSource(sourceReader, poster, headers) {
10
10
  const url = sourceReader.getUrl();
11
+ let source;
11
12
 
12
13
  if (sourceReader.isEmbeddableVideo()) {
13
- return {
14
- uri: url,
15
- };
14
+ source = { uri: url };
15
+ } else {
16
+ const HTML = `
17
+ <video width="100%" height="auto" poster="${poster}" controls >
18
+ <source src="${url}" >
19
+ </video>
20
+ `;
21
+
22
+ source = { html: HTML };
16
23
  }
17
24
 
18
- const HTML = `
19
- <video width="100%" height="auto" poster="${poster}" controls >
20
- <source src="${url}" >
21
- </video>
22
- `;
25
+ if (headers) {
26
+ source.headers = headers;
27
+ }
23
28
 
24
- return {
25
- html: HTML,
26
- };
29
+ return source;
27
30
  }
28
31
 
29
32
  /**
@@ -44,7 +47,8 @@ class Video extends PureComponent {
44
47
  }
45
48
 
46
49
  render() {
47
- const { width, height = '100%', style, poster } = this.props;
50
+ const { width, height = '100%', style, poster, headers } = this.props;
51
+ const webViewSource = getSource(this.sourceReader, poster, headers);
48
52
 
49
53
  return (
50
54
  <View style={style.container}>
@@ -52,7 +56,7 @@ class Video extends PureComponent {
52
56
  allowsFullscreenVideo
53
57
  mediaPlaybackRequiresUserAction={false}
54
58
  style={{ width, height }}
55
- source={getSource(this.sourceReader, poster)}
59
+ source={webViewSource}
56
60
  scrollEnabled={false}
57
61
  originWhitelist={['*']}
58
62
  />
@@ -63,6 +67,7 @@ class Video extends PureComponent {
63
67
 
64
68
  Video.propTypes = {
65
69
  style: PropTypes.object.isRequired,
70
+ headers: PropTypes.object,
66
71
  height: PropTypes.number,
67
72
  // `playerParams` currently only works for Youtube
68
73
  playerParams: PropTypes.object,
@@ -75,6 +80,7 @@ Video.propTypes = {
75
80
 
76
81
  Video.defaultProps = {
77
82
  width: undefined,
83
+ headers: undefined,
78
84
  height: undefined,
79
85
  playerParams: { showinfo: 0 },
80
86
  source: undefined,
@@ -4,39 +4,35 @@ import PropTypes from 'prop-types';
4
4
  import { resolveDimensions } from '../services/Dimensions';
5
5
  import Image from './Image';
6
6
 
7
- const AttachmentRenderer = ({ id, type, style, attachments }) => {
8
- if (!attachments) {
7
+ const AttachmentRenderer = ({ tnode, style, attachments }) => {
8
+ if (!attachments || _.isEmpty(attachments)) {
9
9
  return null;
10
10
  }
11
11
 
12
- if (type === 'image') {
13
- const image = _.find(attachments, { id });
12
+ const image = _.find(attachments, { id: tnode?.id });
14
13
 
15
- if (image && image.src) {
16
- const source = { uri: image.src };
17
- const imageSize = { width: image.width, height: image.height };
18
- const { height, width } = resolveDimensions(imageSize, style);
19
- const resolvedStyle = { alignSelf: 'center', height, width };
20
-
21
- return <Image source={source} key={id} style={resolvedStyle} />;
22
- }
14
+ if (!image || !image.src) {
15
+ return null;
23
16
  }
24
17
 
25
- return null;
18
+ const source = { uri: image.src };
19
+ const imageSize = { width: image.width, height: image.height };
20
+ const { height, width } = resolveDimensions(imageSize, style);
21
+ const resolvedStyle = { alignSelf: 'center', height, width };
22
+
23
+ return <Image source={source} key={tnode?.id} style={resolvedStyle} />;
26
24
  };
27
25
 
28
26
  AttachmentRenderer.propTypes = {
29
- attachments: PropTypes.oneOf([PropTypes.array, PropTypes.object]),
30
- id: PropTypes.any,
27
+ attachments: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
31
28
  style: PropTypes.any,
32
- type: PropTypes.any,
29
+ tnode: PropTypes.object,
33
30
  };
34
31
 
35
32
  AttachmentRenderer.defaultProps = {
36
- id: undefined,
37
- type: undefined,
38
33
  attachments: undefined,
39
34
  style: undefined,
35
+ tnode: {},
40
36
  };
41
37
 
42
38
  export default AttachmentRenderer;
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react/prop-types */
1
2
  import React, { useCallback, useMemo } from 'react';
2
3
  import { Linking } from 'react-native';
3
4
  import Html, { defaultSystemFonts } from 'react-native-render-html';
@@ -11,7 +12,10 @@ import table, {
11
12
  import _ from 'lodash';
12
13
  import { connectStyle } from '@shoutem/theme';
13
14
  import VideoRenderer from '@shoutem/ui/html/components/VideoRenderer';
14
- import { videoModel } from '@shoutem/ui/html/services/HTMLElementModels';
15
+ import {
16
+ attachmentModel,
17
+ videoModel,
18
+ } from '@shoutem/ui/html/services/HTMLElementModels';
15
19
  import { View } from '../../components/View';
16
20
  import { resolveMaxWidth } from '../services/Dimensions';
17
21
  import { onElement } from '../services/DomVisitors';
@@ -75,7 +79,7 @@ const SimpleHtml = ({
75
79
  table,
76
80
  attachment: props => (
77
81
  <AttachmentRenderer
78
- {...props}
82
+ tnode={props.tnode}
79
83
  attachments={attachments}
80
84
  style={style}
81
85
  />
@@ -117,6 +121,7 @@ const SimpleHtml = ({
117
121
  table: tableModel,
118
122
  iframe: iframeModel,
119
123
  video: videoModel,
124
+ attachment: attachmentModel,
120
125
  ...customHtmlElementModels,
121
126
  }),
122
127
  [customHtmlElementModels],
@@ -5,3 +5,9 @@ export const videoModel = HTMLElementModel.fromCustomModel({
5
5
  tagName: 'video',
6
6
  isOpaque: true,
7
7
  });
8
+
9
+ export const attachmentModel = HTMLElementModel.fromCustomModel({
10
+ contentModel: HTMLContentModel.block,
11
+ tagName: 'attachment',
12
+ isOpaque: true,
13
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shoutem/ui",
3
- "version": "9.0.0-rc.5",
3
+ "version": "9.0.1",
4
4
  "description": "Styleable set of components for React Native applications",
5
5
  "scripts": {
6
6
  "lint": "eslint .",
@@ -15,9 +15,9 @@
15
15
  "@native-html/table-plugin": "5.3.1",
16
16
  "@openspacelabs/react-native-zoomable-view": "2.0.4",
17
17
  "@react-native-community/datetimepicker": "6.2.0",
18
- "@shoutem/animation": "1.0.0-rc.1",
18
+ "@shoutem/animation": "1.0.0",
19
19
  "@shoutem/eslint-config-react": "~1.0.6",
20
- "@shoutem/theme": "1.0.0-rc.4",
20
+ "@shoutem/theme": "1.0.0",
21
21
  "auto-bind": "4.0.0",
22
22
  "babel-plugin-transform-decorators-legacy": "1.3.5",
23
23
  "buffer": "5.6.0",
package/theme.js CHANGED
@@ -2407,8 +2407,11 @@ export default () => {
2407
2407
  paddingHorizontal: 20,
2408
2408
  paddingVertical: 16,
2409
2409
  borderBottomWidth: 1,
2410
- borderColor: 'rgba(130, 130, 130, 0.1)',
2411
2410
  alignItems: 'center',
2411
+ backgroundColor: resolveVariable('primaryButtonBackgroundColor'),
2412
+ borderColor: resolveVariable('primaryButtonBorderColor'),
2413
+ borderWidth: StyleSheet.hairlineWidth,
2414
+ borderRadius: 13,
2412
2415
  },
2413
2416
  text: {
2414
2417
  fontSize: 15,