@shoutem/ui 6.4.3 → 6.5.0-rc.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.
- package/components/AnimatedScrollingText.js +99 -0
- package/components/Icon/assets/index.js +4 -0
- package/components/Icon/assets/playlist-play.svg +1 -0
- package/components/Icon/assets/skip-next.svg +1 -0
- package/components/TextInput.js +10 -2
- package/components/ToastMessage/README.md +2 -2
- package/index.js +1 -0
- package/package.json +1 -1
- package/theme.js +14 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { connectStyle } from '@shoutem/theme';
|
|
5
|
+
import { ScrollView } from './ScrollView';
|
|
6
|
+
import { Text } from './Text';
|
|
7
|
+
|
|
8
|
+
const DEFAULT_CONFIG = {
|
|
9
|
+
animationDuration: widthDiff => Math.max(widthDiff * 50, 2000),
|
|
10
|
+
waitDuration: 2000,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const AnimatedScrollingText = ({ text, config, style }) => {
|
|
14
|
+
const translateX = useRef(new Animated.Value(0)).current;
|
|
15
|
+
|
|
16
|
+
const [containerWidth, setContainerWidth] = useState();
|
|
17
|
+
const [textWidth, setTextWidth] = useState();
|
|
18
|
+
|
|
19
|
+
const widthDiff = textWidth - containerWidth;
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
let animation;
|
|
23
|
+
|
|
24
|
+
if (widthDiff > 0) {
|
|
25
|
+
animation = Animated.loop(
|
|
26
|
+
Animated.sequence([
|
|
27
|
+
// Animate scroll to the end of the text
|
|
28
|
+
Animated.timing(translateX, {
|
|
29
|
+
toValue: -widthDiff,
|
|
30
|
+
duration: config.animationDuration(widthDiff),
|
|
31
|
+
useNativeDriver: true,
|
|
32
|
+
}),
|
|
33
|
+
// Animate scroll back to start of the text
|
|
34
|
+
Animated.timing(translateX, {
|
|
35
|
+
toValue: 0,
|
|
36
|
+
duration: config.animationDuration(widthDiff),
|
|
37
|
+
useNativeDriver: true,
|
|
38
|
+
}),
|
|
39
|
+
// Wait X sec before starting animation again
|
|
40
|
+
Animated.timing(translateX, {
|
|
41
|
+
toValue: 0,
|
|
42
|
+
duration: config.waitDuration,
|
|
43
|
+
useNativeDriver: true,
|
|
44
|
+
}),
|
|
45
|
+
]),
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
animation.start();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return () => animation?.stop();
|
|
52
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
53
|
+
}, [widthDiff]);
|
|
54
|
+
|
|
55
|
+
const handleContainerLayout = e => {
|
|
56
|
+
setContainerWidth(e.nativeEvent.layout.width);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const handleTextLayout = e => {
|
|
60
|
+
setTextWidth(e.nativeEvent.layout.width);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<ScrollView
|
|
65
|
+
onLayout={handleContainerLayout}
|
|
66
|
+
horizontal
|
|
67
|
+
showsHorizontalScrollIndicator={false}
|
|
68
|
+
style={style.scrollContainer}
|
|
69
|
+
contentContainerStyle={style.scrollContentContainer}
|
|
70
|
+
>
|
|
71
|
+
<Animated.View
|
|
72
|
+
style={[
|
|
73
|
+
style.textContainer,
|
|
74
|
+
widthDiff > 0 ? { transform: [{ translateX }] } : {},
|
|
75
|
+
]}
|
|
76
|
+
>
|
|
77
|
+
<Text onLayout={handleTextLayout} style={style.text}>
|
|
78
|
+
{text}
|
|
79
|
+
</Text>
|
|
80
|
+
</Animated.View>
|
|
81
|
+
</ScrollView>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
AnimatedScrollingText.propTypes = {
|
|
86
|
+
text: PropTypes.string.isRequired,
|
|
87
|
+
config: PropTypes.object,
|
|
88
|
+
style: PropTypes.object,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
AnimatedScrollingText.defaultProps = {
|
|
92
|
+
config: DEFAULT_CONFIG,
|
|
93
|
+
style: {},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const StyledAnimatedScrollingText = connectStyle(
|
|
97
|
+
'shoutem.ui.AnimatedScrollingText',
|
|
98
|
+
)(AnimatedScrollingText);
|
|
99
|
+
export { StyledAnimatedScrollingText as AnimatedScrollingText };
|
|
@@ -79,6 +79,7 @@ import pause from './pause.svg';
|
|
|
79
79
|
import photo from './photo.svg';
|
|
80
80
|
import pin from './pin.svg';
|
|
81
81
|
import play from './play.svg';
|
|
82
|
+
import playlistPlay from './playlist-play.svg';
|
|
82
83
|
import plusButton from './plus-button.svg';
|
|
83
84
|
import podcasts from './podcasts.svg';
|
|
84
85
|
import products from './products.svg';
|
|
@@ -102,6 +103,7 @@ import settings from './settings.svg';
|
|
|
102
103
|
import share from './share.svg';
|
|
103
104
|
import shareAndroid from './share-android.svg';
|
|
104
105
|
import sidebar from './sidebar.svg';
|
|
106
|
+
import skipNext from './skip-next.svg';
|
|
105
107
|
import sleep from './sleep.svg';
|
|
106
108
|
import socialWall from './social-wall.svg';
|
|
107
109
|
import stamp from './stamp.svg';
|
|
@@ -202,6 +204,7 @@ export const defaultConfig = [
|
|
|
202
204
|
{ name: 'photo', icon: photo },
|
|
203
205
|
{ name: 'pin', icon: pin },
|
|
204
206
|
{ name: 'play', icon: play },
|
|
207
|
+
{ name: 'playlist-play', icon: playlistPlay },
|
|
205
208
|
{ name: 'plus-button', icon: plusButton },
|
|
206
209
|
{ name: 'podcasts', icon: podcasts },
|
|
207
210
|
{ name: 'products', icon: products },
|
|
@@ -225,6 +228,7 @@ export const defaultConfig = [
|
|
|
225
228
|
{ name: 'share', icon: share },
|
|
226
229
|
{ name: 'share-android', icon: shareAndroid },
|
|
227
230
|
{ name: 'sidebar', icon: sidebar },
|
|
231
|
+
{ name: 'skip-next', icon: skipNext },
|
|
228
232
|
{ name: 'sleep', icon: sleep },
|
|
229
233
|
{ name: 'social-wall', icon: socialWall },
|
|
230
234
|
{ name: 'stamp', icon: stamp },
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<?xml version="1.0" ?><svg enable-background="new 0 0 48 48" height="48px" id="Layer_1" version="1.1" viewBox="0 0 48 48" width="48px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g><path d="M0,0h48v48H0V0z" fill="none" id="XMLID_31_"/><g><rect height="4" id="XMLID_30_" width="24" x="8" y="20"/><rect height="4" id="XMLID_29_" width="24" x="8" y="12"/><rect height="4" id="XMLID_28_" width="16" x="8" y="28"/><polygon id="XMLID_27_" points="28,28 28,40 38,34 "/></g></g></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<?xml version="1.0" ?><svg height="48" viewBox="0 0 48 48" width="48" xmlns="http://www.w3.org/2000/svg"><path d="M12 36l17-12-17-12v24zm20-24v24h4V12h-4z"/><path d="M0 0h48v48H0z" fill="none"/></svg>
|
package/components/TextInput.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable react/no-multi-comp */
|
|
2
|
+
import React, { forwardRef, PureComponent } from 'react';
|
|
2
3
|
import { TextInput as RNTextInput } from 'react-native';
|
|
3
4
|
import autoBindReact from 'auto-bind/react';
|
|
4
5
|
import { TextInputPropTypes } from 'deprecated-react-native-prop-types';
|
|
@@ -45,6 +46,7 @@ class TextInput extends PureComponent {
|
|
|
45
46
|
errorMessage,
|
|
46
47
|
highlightOnFocus,
|
|
47
48
|
style,
|
|
49
|
+
forwardedRef,
|
|
48
50
|
...otherProps
|
|
49
51
|
} = this.props;
|
|
50
52
|
const { isFocused } = this.state;
|
|
@@ -79,6 +81,7 @@ class TextInput extends PureComponent {
|
|
|
79
81
|
...(errorMessage ? errorBorderColor : {}),
|
|
80
82
|
...otherStyle,
|
|
81
83
|
}}
|
|
84
|
+
ref={forwardedRef}
|
|
82
85
|
/>
|
|
83
86
|
</Wiggle>
|
|
84
87
|
{!!errorMessage && (
|
|
@@ -106,4 +109,9 @@ TextInput.defaultProps = {
|
|
|
106
109
|
const AnimatedTextInput = connectAnimation(TextInput);
|
|
107
110
|
const StyledTextInput = connectStyle('shoutem.ui.TextInput')(AnimatedTextInput);
|
|
108
111
|
|
|
109
|
-
|
|
112
|
+
const ForwardedTextInput = forwardRef((props, ref) => (
|
|
113
|
+
<StyledTextInput {...props} forwardedRef={ref} />
|
|
114
|
+
));
|
|
115
|
+
ForwardedTextInput.displayName = 'TextInput';
|
|
116
|
+
|
|
117
|
+
export { ForwardedTextInput as TextInput };
|
|
@@ -9,7 +9,7 @@ New component used for multiple types of alerts, or simple action prompts. The c
|
|
|
9
9
|
Most of the time, you will want to use one of the four standard methods of showing a toast using this package.
|
|
10
10
|
|
|
11
11
|
- Toast.showInfo
|
|
12
|
-
- Toast.
|
|
12
|
+
- Toast.showAction
|
|
13
13
|
- Toast.showError
|
|
14
14
|
- Toast.showSuccess
|
|
15
15
|
|
|
@@ -33,7 +33,7 @@ Toast.showInfo({
|
|
|
33
33
|
```jsx
|
|
34
34
|
import { Toast } from '@shoutem/ui';
|
|
35
35
|
...
|
|
36
|
-
Toast.
|
|
36
|
+
Toast.showAction({
|
|
37
37
|
title: 'Stop',
|
|
38
38
|
message: `Hammer time`,
|
|
39
39
|
iconSource: require('../assets/actionIcon.png'),
|
package/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export {
|
|
|
25
25
|
|
|
26
26
|
// Components
|
|
27
27
|
export { ActionSheet } from './components/ActionSheet';
|
|
28
|
+
export { AnimatedScrollingText } from './components/AnimatedScrollingText';
|
|
28
29
|
export { Button } from './components/Button';
|
|
29
30
|
export { Card } from './components/Card';
|
|
30
31
|
export { CategoryPicker } from './components/CategoryPicker';
|
package/package.json
CHANGED
package/theme.js
CHANGED
|
@@ -3225,5 +3225,19 @@ export default () => {
|
|
|
3225
3225
|
color: '#88C242',
|
|
3226
3226
|
},
|
|
3227
3227
|
},
|
|
3228
|
+
'shoutem.ui.AnimatedScrollingText': {
|
|
3229
|
+
text: {
|
|
3230
|
+
color: resolveVariable('text'),
|
|
3231
|
+
fontSize: responsiveHeight(15),
|
|
3232
|
+
fontWeight: resolveFontWeight('600'),
|
|
3233
|
+
flexWrap: 'nowrap',
|
|
3234
|
+
},
|
|
3235
|
+
scrollContainer: {
|
|
3236
|
+
maxHeight: responsiveHeight(20),
|
|
3237
|
+
},
|
|
3238
|
+
scrollContentContainer: {
|
|
3239
|
+
maxHeight: responsiveHeight(20),
|
|
3240
|
+
},
|
|
3241
|
+
},
|
|
3228
3242
|
};
|
|
3229
3243
|
};
|