@shoutem/ui 7.1.0-beta.3 → 7.1.0-beta.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.
|
@@ -1,183 +1,62 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import
|
|
3
|
-
import autoBindReact from 'auto-bind/react';
|
|
1
|
+
import React, { useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import ActionSheetNative from 'react-native-actions-sheet';
|
|
4
3
|
import _ from 'lodash';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
6
5
|
import { connectStyle } from '@shoutem/theme';
|
|
7
|
-
import { IPHONE_X_HOME_INDICATOR_PADDING } from '../../const';
|
|
8
|
-
import { Device } from '../../helpers';
|
|
9
6
|
import { View } from '../View';
|
|
10
7
|
import ActionSheetOption, { optionPropType } from './ActionSheetOption';
|
|
11
8
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (active
|
|
30
|
-
|
|
9
|
+
const ActionSheet = ({
|
|
10
|
+
active = false,
|
|
11
|
+
cancelOptions = undefined,
|
|
12
|
+
confirmOptions = undefined,
|
|
13
|
+
style,
|
|
14
|
+
onDismiss = undefined,
|
|
15
|
+
}) => {
|
|
16
|
+
const actionSheetRef = useRef(null);
|
|
17
|
+
|
|
18
|
+
const hasConfirmOptions = useMemo(() => !_.isEmpty(confirmOptions), [
|
|
19
|
+
confirmOptions,
|
|
20
|
+
]);
|
|
21
|
+
const hasCancelOptions = useMemo(() => !_.isEmpty(cancelOptions), [
|
|
22
|
+
cancelOptions,
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (active) {
|
|
27
|
+
actionSheetRef.current?.show();
|
|
28
|
+
} else {
|
|
29
|
+
actionSheetRef.current?.hide();
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
componentDidUpdate(prevProps) {
|
|
49
|
-
const { active } = this.props;
|
|
50
|
-
const { active: prevActive } = prevProps;
|
|
51
|
-
|
|
52
|
-
if (active && !prevActive) {
|
|
53
|
-
this.handleEntryAnimation();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (!active && prevActive) {
|
|
57
|
-
this.handleExitAnimation();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
hideComponent() {
|
|
62
|
-
this.setState({ visible: false });
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
handleContentLayout(event) {
|
|
66
|
-
const height = _.get(event, 'nativeEvent.layout.height', 0);
|
|
67
|
-
|
|
68
|
-
this.setState({ height });
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
handleEntryAnimation() {
|
|
72
|
-
const { yPos, opacity } = this.state;
|
|
73
|
-
|
|
74
|
-
const toValue = 1;
|
|
75
|
-
|
|
76
|
-
Animated.parallel([
|
|
77
|
-
Animated.spring(yPos, {
|
|
78
|
-
toValue,
|
|
79
|
-
useNativeDriver: true,
|
|
80
|
-
}),
|
|
81
|
-
Animated.timing(opacity, {
|
|
82
|
-
toValue,
|
|
83
|
-
useNativeDriver: false,
|
|
84
|
-
}),
|
|
85
|
-
]).start();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
handleExitAnimation() {
|
|
89
|
-
const { yPos, opacity } = this.state;
|
|
90
|
-
|
|
91
|
-
const toValue = 0;
|
|
92
|
-
|
|
93
|
-
Animated.parallel([
|
|
94
|
-
Animated.spring(yPos, {
|
|
95
|
-
toValue,
|
|
96
|
-
useNativeDriver: true,
|
|
97
|
-
}),
|
|
98
|
-
Animated.timing(opacity, {
|
|
99
|
-
toValue,
|
|
100
|
-
delay: 100,
|
|
101
|
-
duration: 150,
|
|
102
|
-
useNativeDriver: false,
|
|
103
|
-
}),
|
|
104
|
-
]).start(this.hideComponent);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
handleInactiveAreaPress() {
|
|
108
|
-
const { onDismiss } = this.props;
|
|
109
|
-
|
|
110
|
-
if (onDismiss) {
|
|
111
|
-
onDismiss();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
render() {
|
|
116
|
-
const { confirmOptions, cancelOptions, style } = this.props;
|
|
117
|
-
const { opacity, yPos, visible, height } = this.state;
|
|
118
|
-
|
|
119
|
-
const hasConfirmOptions = !_.isEmpty(confirmOptions);
|
|
120
|
-
const hasCancelOptions = !_.isEmpty(cancelOptions);
|
|
121
|
-
|
|
122
|
-
if (!visible || (!hasConfirmOptions && !hasCancelOptions)) {
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return (
|
|
127
|
-
<AnimatedTouchable
|
|
128
|
-
activeOpacity={1}
|
|
129
|
-
onPress={this.handleInactiveAreaPress}
|
|
130
|
-
style={[
|
|
131
|
-
style.container,
|
|
132
|
-
{
|
|
133
|
-
backgroundColor: opacity.interpolate({
|
|
134
|
-
inputRange: [0, 1],
|
|
135
|
-
outputRange: ['rgba(0, 0, 0, 0)', 'rgba(0, 0, 0, 0.3)'],
|
|
136
|
-
}),
|
|
137
|
-
},
|
|
138
|
-
]}
|
|
139
|
-
>
|
|
140
|
-
<Animated.View
|
|
141
|
-
onLayout={this.handleContentLayout}
|
|
142
|
-
style={[
|
|
143
|
-
style.contentContainer,
|
|
144
|
-
{
|
|
145
|
-
transform: [
|
|
146
|
-
{
|
|
147
|
-
translateY: yPos.interpolate({
|
|
148
|
-
inputRange: [0, 1],
|
|
149
|
-
outputRange: [getContentOffset(height), 0],
|
|
150
|
-
}),
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
},
|
|
154
|
-
]}
|
|
155
|
-
>
|
|
156
|
-
{hasConfirmOptions && (
|
|
31
|
+
}, [active]);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<ActionSheetNative gestureEnabled ref={actionSheetRef} onClose={onDismiss}>
|
|
35
|
+
<View style={style.contentContainer}>
|
|
36
|
+
{hasConfirmOptions && (
|
|
37
|
+
<View style={style.segmentContainer}>
|
|
38
|
+
{_.map(confirmOptions, option => (
|
|
39
|
+
<ActionSheetOption key={option.title} option={option} />
|
|
40
|
+
))}
|
|
41
|
+
</View>
|
|
42
|
+
)}
|
|
43
|
+
{hasCancelOptions && (
|
|
44
|
+
<View styleName="md-gutter-top">
|
|
157
45
|
<View style={style.segmentContainer}>
|
|
158
|
-
{_.map(
|
|
159
|
-
<ActionSheetOption
|
|
46
|
+
{_.map(cancelOptions, option => (
|
|
47
|
+
<ActionSheetOption
|
|
48
|
+
key={option.title}
|
|
49
|
+
cancelOption
|
|
50
|
+
option={option}
|
|
51
|
+
/>
|
|
160
52
|
))}
|
|
161
53
|
</View>
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
key={option.title}
|
|
169
|
-
cancelOption
|
|
170
|
-
option={option}
|
|
171
|
-
/>
|
|
172
|
-
))}
|
|
173
|
-
</View>
|
|
174
|
-
</View>
|
|
175
|
-
)}
|
|
176
|
-
</Animated.View>
|
|
177
|
-
</AnimatedTouchable>
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
54
|
+
</View>
|
|
55
|
+
)}
|
|
56
|
+
</View>
|
|
57
|
+
</ActionSheetNative>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
181
60
|
|
|
182
61
|
ActionSheet.propTypes = {
|
|
183
62
|
style: PropTypes.object.isRequired,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shoutem/ui",
|
|
3
|
-
"version": "7.1.0-beta.
|
|
3
|
+
"version": "7.1.0-beta.5",
|
|
4
4
|
"description": "Styleable set of components for React Native applications",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "eslint .",
|
|
@@ -41,12 +41,14 @@
|
|
|
41
41
|
"react-native-vimeo-iframe": "^1.2.1",
|
|
42
42
|
"react-native-webview": "11.23.0",
|
|
43
43
|
"react-native-youtube-iframe": "2.2.2",
|
|
44
|
+
"react-native-actions-sheet": "0.9.6",
|
|
44
45
|
"stream": "0.0.2",
|
|
45
46
|
"tinycolor2": "1.4.1"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
49
|
"react": ">=16.9.0",
|
|
49
|
-
"react-native": ">=0.61.5"
|
|
50
|
+
"react-native": ">=0.61.5",
|
|
51
|
+
"react-native-gesture-handler": "*"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
52
54
|
"@babel/core": "7.16.7",
|
package/web/style/Alert.scss
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
.alert-actions {
|
|
20
|
-
border-top: 1px solid;
|
|
20
|
+
border-top: 1px solid #DEDEDE;
|
|
21
21
|
margin: 20px 0px 0px 0px;
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -56,10 +56,14 @@
|
|
|
56
56
|
width: 50%;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
.
|
|
60
|
-
|
|
59
|
+
.button-height {
|
|
60
|
+
height: 50px;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
.border-right {
|
|
64
|
-
border-right: 1px solid
|
|
64
|
+
border-right: 1px solid #DEDEDE;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.border-bottom {
|
|
68
|
+
border-bottom: 1px solid #DEDEDE;
|
|
65
69
|
}
|