@shoutem/ui 4.6.1 → 4.6.5
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.
- package/components/ListView.js +15 -2
- package/html/components/SimpleHtml.js +54 -15
- package/package.json +2 -2
- package/theme.js +6 -7
package/components/ListView.js
CHANGED
|
@@ -77,6 +77,7 @@ class ListView extends PureComponent {
|
|
|
77
77
|
|
|
78
78
|
this.state = {
|
|
79
79
|
status: props.loading ? Status.LOADING : Status.IDLE,
|
|
80
|
+
isScrolling: false,
|
|
80
81
|
};
|
|
81
82
|
}
|
|
82
83
|
|
|
@@ -196,17 +197,21 @@ class ListView extends PureComponent {
|
|
|
196
197
|
// reference
|
|
197
198
|
mappedProps.ref = this.handleListViewRef;
|
|
198
199
|
|
|
200
|
+
mappedProps.onMomentumScrollBegin = this.setStartedScrolling;
|
|
201
|
+
|
|
202
|
+
mappedProps.onMomentumScrollEnd = this.setEndedScrolling;
|
|
203
|
+
|
|
199
204
|
return mappedProps;
|
|
200
205
|
}
|
|
201
206
|
|
|
202
207
|
// eslint-disable-next-line consistent-return
|
|
203
208
|
createOnLoadMore() {
|
|
204
209
|
const { onLoadMore, data } = this.props;
|
|
205
|
-
const { status } = this.state;
|
|
210
|
+
const { isScrolling, status } = this.state;
|
|
206
211
|
if (onLoadMore) {
|
|
207
212
|
return _.throttle(
|
|
208
213
|
() => {
|
|
209
|
-
if (!_.isEmpty(data) && status === Status.IDLE) {
|
|
214
|
+
if (!_.isEmpty(data) && isScrolling && status === Status.IDLE) {
|
|
210
215
|
onLoadMore();
|
|
211
216
|
}
|
|
212
217
|
},
|
|
@@ -216,6 +221,14 @@ class ListView extends PureComponent {
|
|
|
216
221
|
}
|
|
217
222
|
}
|
|
218
223
|
|
|
224
|
+
setStartedScrolling() {
|
|
225
|
+
this.setState({ isScrolling: true });
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
setEndedScrolling() {
|
|
229
|
+
this.setState({ isScrolling: true });
|
|
230
|
+
}
|
|
231
|
+
|
|
219
232
|
autoHideHeader({
|
|
220
233
|
nativeEvent: {
|
|
221
234
|
layout: { height },
|
|
@@ -25,6 +25,34 @@ import getEmptyObjectKeys from '../services/getEmptyObjectKeys';
|
|
|
25
25
|
import isValidVideoFormat from '../services/isValidVideoFormat';
|
|
26
26
|
import Image from './Image';
|
|
27
27
|
|
|
28
|
+
function resolveMaxWidth(style) {
|
|
29
|
+
// parentContainerPadding - padding between screen & SimpleHtml. Parent container
|
|
30
|
+
// can have it's own padding. If it does, we have to include it in calculation,
|
|
31
|
+
// otherwise maxWidth will be more than max & images will go over the edge
|
|
32
|
+
const parentContainerPadding = style.outerPadding || 0;
|
|
33
|
+
const paddingValue =
|
|
34
|
+
style.container.paddingLeft ||
|
|
35
|
+
0 + style.container.paddingRight ||
|
|
36
|
+
0 + parentContainerPadding;
|
|
37
|
+
|
|
38
|
+
return Dimensions.get('window').width - paddingValue;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function resolveDimensions(objectToResize, style) {
|
|
42
|
+
const { width, height } = objectToResize;
|
|
43
|
+
|
|
44
|
+
if (!width || !height) {
|
|
45
|
+
return { width, height };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const maxWidth = resolveMaxWidth(style);
|
|
49
|
+
const objectToResizeRatio = height / width;
|
|
50
|
+
const resolvedWidth = width > maxWidth ? maxWidth : width;
|
|
51
|
+
const resolvedHeight = Math.round(resolvedWidth * objectToResizeRatio);
|
|
52
|
+
|
|
53
|
+
return { width: resolvedWidth, height: resolvedHeight };
|
|
54
|
+
}
|
|
55
|
+
|
|
28
56
|
class SimpleHtml extends PureComponent {
|
|
29
57
|
static propTypes = {
|
|
30
58
|
body: PropTypes.string,
|
|
@@ -33,6 +61,7 @@ class SimpleHtml extends PureComponent {
|
|
|
33
61
|
customTagStyles: PropTypes.object,
|
|
34
62
|
customHandleLinkPress: PropTypes.func,
|
|
35
63
|
unsupportedVideoFormatMessage: PropTypes.string,
|
|
64
|
+
customAlterNode: PropTypes.func,
|
|
36
65
|
};
|
|
37
66
|
|
|
38
67
|
constructor(props) {
|
|
@@ -56,10 +85,22 @@ class SimpleHtml extends PureComponent {
|
|
|
56
85
|
* video iframe tags in when video format is unsupported
|
|
57
86
|
*/
|
|
58
87
|
alterNode(node) {
|
|
59
|
-
const { style } = this.props;
|
|
88
|
+
const { customAlterNode, style } = this.props;
|
|
60
89
|
|
|
61
90
|
const styleAttrib = _.get(node, 'attribs.style', '').trim();
|
|
62
91
|
|
|
92
|
+
if (customAlterNode && _.isFunction(customAlterNode)) {
|
|
93
|
+
const resolvedNode = customAlterNode(
|
|
94
|
+
node,
|
|
95
|
+
cssObjectToString,
|
|
96
|
+
cssStringToObject,
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
if (resolvedNode) {
|
|
100
|
+
return resolvedNode;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
63
104
|
if (node.name === 'table') {
|
|
64
105
|
return tableAlterNode(node);
|
|
65
106
|
}
|
|
@@ -81,18 +122,15 @@ class SimpleHtml extends PureComponent {
|
|
|
81
122
|
}
|
|
82
123
|
}
|
|
83
124
|
|
|
84
|
-
const nodeWidth =
|
|
125
|
+
const nodeWidth = node.attribs?.width;
|
|
85
126
|
|
|
86
127
|
if (!styleAttrib && !nodeWidth) {
|
|
87
128
|
return false;
|
|
88
129
|
}
|
|
89
130
|
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
const nodeRatio = nodeWidth / nodeHeight;
|
|
94
|
-
const resolvedWidth = nodeWidth > maxWidth ? maxWidth : nodeWidth;
|
|
95
|
-
const resolvedHeight = Math.round(resolvedWidth * nodeRatio);
|
|
131
|
+
const nodeHeight = node.attribus?.height;
|
|
132
|
+
const nodeDimensions = { width: nodeWidth, height: nodeHeight };
|
|
133
|
+
const { width, height } = resolveDimensions(nodeDimensions, style);
|
|
96
134
|
|
|
97
135
|
const nodeStyle = cssStringToObject(styleAttrib);
|
|
98
136
|
const invalidKeys = getEmptyObjectKeys(nodeStyle);
|
|
@@ -100,8 +138,8 @@ class SimpleHtml extends PureComponent {
|
|
|
100
138
|
if (invalidKeys.length || nodeWidth) {
|
|
101
139
|
const styleFiltered = _.omit(style, invalidKeys);
|
|
102
140
|
node.attribs.style = cssObjectToString(styleFiltered);
|
|
103
|
-
node.attribs.width =
|
|
104
|
-
node.attribs.height =
|
|
141
|
+
node.attribs.width = width;
|
|
142
|
+
node.attribs.height = height;
|
|
105
143
|
|
|
106
144
|
return node;
|
|
107
145
|
}
|
|
@@ -157,7 +195,7 @@ class SimpleHtml extends PureComponent {
|
|
|
157
195
|
* Currently only supports rendering image attachments.
|
|
158
196
|
*/
|
|
159
197
|
renderAttachments({ id, type }) {
|
|
160
|
-
const { attachments } = this.props;
|
|
198
|
+
const { attachments, style } = this.props;
|
|
161
199
|
|
|
162
200
|
if (!attachments) {
|
|
163
201
|
return null;
|
|
@@ -168,9 +206,11 @@ class SimpleHtml extends PureComponent {
|
|
|
168
206
|
|
|
169
207
|
if (image && image.src) {
|
|
170
208
|
const source = { uri: image.src };
|
|
171
|
-
const
|
|
209
|
+
const imageSize = { width: image.width, height: image.height };
|
|
210
|
+
const { height, width } = resolveDimensions(imageSize, style);
|
|
211
|
+
const resolvedStyle = { alignSelf: 'center', height, width };
|
|
172
212
|
|
|
173
|
-
return <Image source={source} key={id} style={
|
|
213
|
+
return <Image source={source} key={id} style={resolvedStyle} />;
|
|
174
214
|
}
|
|
175
215
|
}
|
|
176
216
|
|
|
@@ -220,8 +260,7 @@ class SimpleHtml extends PureComponent {
|
|
|
220
260
|
render() {
|
|
221
261
|
const { style, body, customTagStyles, ...otherProps } = this.props;
|
|
222
262
|
|
|
223
|
-
const
|
|
224
|
-
const maxWidth = Dimensions.get('window').width - paddingValue;
|
|
263
|
+
const maxWidth = resolveMaxWidth(style);
|
|
225
264
|
|
|
226
265
|
const tagStyles = {
|
|
227
266
|
...style.tags,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shoutem/ui",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.5",
|
|
4
4
|
"description": "Styleable set of components for React Native applications",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "eslint .",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"react-native-transformable-image": "shoutem/react-native-transformable-image#v0.0.20",
|
|
36
36
|
"react-native-vector-icons": "~6.6.0",
|
|
37
37
|
"react-native-webview": "~11.0.0",
|
|
38
|
-
"react-native-youtube-iframe": "~2.
|
|
38
|
+
"react-native-youtube-iframe": "~2.1.2",
|
|
39
39
|
"stream": "0.0.2",
|
|
40
40
|
"tinycolor2": "1.4.1"
|
|
41
41
|
},
|
package/theme.js
CHANGED
|
@@ -1979,7 +1979,7 @@ export default (variables = defaultThemeVariables) => ({
|
|
|
1979
1979
|
input: {
|
|
1980
1980
|
backgroundColor: '#f0f0f0',
|
|
1981
1981
|
color: '#888888',
|
|
1982
|
-
minWidth:
|
|
1982
|
+
minWidth: 230,
|
|
1983
1983
|
fontSize: 15,
|
|
1984
1984
|
height: 30,
|
|
1985
1985
|
paddingVertical: 6,
|
|
@@ -2041,10 +2041,9 @@ export default (variables = defaultThemeVariables) => ({
|
|
|
2041
2041
|
minHeight: 40,
|
|
2042
2042
|
maxHeight: 200,
|
|
2043
2043
|
justifyContent: 'center',
|
|
2044
|
-
backgroundColor:
|
|
2045
|
-
variables.
|
|
2046
|
-
5,
|
|
2047
|
-
),
|
|
2044
|
+
backgroundColor:
|
|
2045
|
+
variables.categoryDropdownBackgroundColor ||
|
|
2046
|
+
inverseColorBrightnessForAmount(variables.paperColor, 5),
|
|
2048
2047
|
width: window.width,
|
|
2049
2048
|
marginTop: 0,
|
|
2050
2049
|
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
@@ -2052,7 +2051,7 @@ export default (variables = defaultThemeVariables) => ({
|
|
|
2052
2051
|
},
|
|
2053
2052
|
selectedOption: {
|
|
2054
2053
|
'shoutem.ui.Icon': {
|
|
2055
|
-
color: variables.text.color,
|
|
2054
|
+
color: variables.categoryDropdownTextColor || variables.text.color,
|
|
2056
2055
|
},
|
|
2057
2056
|
'shoutem.ui.Text': {
|
|
2058
2057
|
...variables.navBarText,
|
|
@@ -2061,7 +2060,7 @@ export default (variables = defaultThemeVariables) => ({
|
|
|
2061
2060
|
'normal',
|
|
2062
2061
|
variables.navBarText.fontStyle,
|
|
2063
2062
|
),
|
|
2064
|
-
color: variables.text.color,
|
|
2063
|
+
color: variables.categoryDropdownTextColor || variables.text.color,
|
|
2065
2064
|
fontWeight: resolveFontWeight('normal'),
|
|
2066
2065
|
fontStyle: resolveFontStyle(variables.navBarText.fontStyle),
|
|
2067
2066
|
textAlign: 'center',
|