@holper/react-native-holper-storybook 0.6.38 → 0.6.39
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/lib/components/Button/index.js +14 -7
- package/lib/components/ConfirmationModal/index.js +60 -36
- package/lib/components/TakePicture/confirmPictureModal.js +64 -0
- package/lib/components/TakePicture/index.js +10 -31
- package/lib/components/UploadDocument/index.js +7 -5
- package/package.json +1 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { TouchableOpacity, ActivityIndicator } from 'react-native';
|
|
4
4
|
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
5
5
|
import withPreventDoubleClick from './../PreventDoubleClick';
|
|
6
6
|
import { Colors } from '../../configs/constants';
|
|
7
|
-
import { useDebounce } from '../../hooks';
|
|
8
7
|
import style from './style';
|
|
9
8
|
|
|
10
9
|
const Button = ({
|
|
@@ -16,10 +15,10 @@ const Button = ({
|
|
|
16
15
|
size,
|
|
17
16
|
noShadow,
|
|
18
17
|
style: customStyle,
|
|
19
|
-
debounceDelay,
|
|
18
|
+
debounceDelay = 0,
|
|
20
19
|
children,
|
|
21
20
|
}) => {
|
|
22
|
-
const
|
|
21
|
+
const [isDisabled, setIsDisabled] = useState(disabled);
|
|
23
22
|
const getSpinnerColor = () => {
|
|
24
23
|
switch (variant) {
|
|
25
24
|
case 'primary':
|
|
@@ -31,6 +30,14 @@ const Button = ({
|
|
|
31
30
|
}
|
|
32
31
|
};
|
|
33
32
|
|
|
33
|
+
const handleTap = () => {
|
|
34
|
+
onPress();
|
|
35
|
+
setIsDisabled(true);
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
setIsDisabled(false);
|
|
38
|
+
}, debounceDelay);
|
|
39
|
+
};
|
|
40
|
+
|
|
34
41
|
return (
|
|
35
42
|
<TouchableOpacity
|
|
36
43
|
style={[
|
|
@@ -38,12 +45,12 @@ const Button = ({
|
|
|
38
45
|
style[variant],
|
|
39
46
|
style[size],
|
|
40
47
|
bordered ? style.bordered : {},
|
|
41
|
-
|
|
48
|
+
isDisabled ? style.disabled : {},
|
|
42
49
|
noShadow ? style.noShadow : {},
|
|
43
50
|
customStyle,
|
|
44
51
|
]}
|
|
45
|
-
disabled={isLoading ||
|
|
46
|
-
onPress={
|
|
52
|
+
disabled={isLoading || isDisabled}
|
|
53
|
+
onPress={handleTap}
|
|
47
54
|
>
|
|
48
55
|
{isLoading ? (
|
|
49
56
|
<ActivityIndicator color={getSpinnerColor()} size={28} />
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
Keyboard,
|
|
7
7
|
TouchableWithoutFeedback,
|
|
8
8
|
Platform,
|
|
9
|
-
KeyboardAvoidingView
|
|
9
|
+
KeyboardAvoidingView,
|
|
10
10
|
} from 'react-native';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
12
|
import Ionicons from 'react-native-vector-icons/Ionicons';
|
|
@@ -16,49 +16,57 @@ import { Colors } from '../../configs/constants';
|
|
|
16
16
|
import style from './style';
|
|
17
17
|
|
|
18
18
|
const ConfirmationModal = ({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
visible,
|
|
20
|
+
title,
|
|
21
|
+
confirmText,
|
|
22
|
+
cancelText,
|
|
23
|
+
onConfirm,
|
|
24
|
+
onCancel,
|
|
25
|
+
closeButton,
|
|
26
|
+
onClose,
|
|
27
|
+
alertMode,
|
|
28
|
+
infoMode,
|
|
29
|
+
inverted,
|
|
30
|
+
children,
|
|
31
|
+
}) => (
|
|
32
32
|
<Modal
|
|
33
|
-
animationType=
|
|
33
|
+
animationType='slide'
|
|
34
34
|
transparent={true}
|
|
35
35
|
visible={visible}
|
|
36
36
|
onRequestClose={() => {}}
|
|
37
37
|
>
|
|
38
|
-
<KeyboardAvoidingView
|
|
38
|
+
<KeyboardAvoidingView
|
|
39
|
+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
40
|
+
>
|
|
39
41
|
<TouchableWithoutFeedback onPress={() => Keyboard.dismiss()}>
|
|
40
42
|
<View style={style.container}>
|
|
41
43
|
<View style={style.content}>
|
|
42
|
-
|
|
43
|
-
<View style={(alertMode && !closeButton) ? {} : style.title}>
|
|
44
|
+
<View style={alertMode && !closeButton ? {} : style.title}>
|
|
44
45
|
<Text
|
|
45
|
-
style={
|
|
46
|
+
style={alertMode && !closeButton ? {} : style.titleText}
|
|
46
47
|
size='large'
|
|
47
|
-
align={
|
|
48
|
+
align={alertMode && !closeButton ? 'center' : 'left'}
|
|
48
49
|
weight='semiBold'
|
|
49
50
|
numberOfLines={1}
|
|
50
51
|
>
|
|
51
52
|
{title}
|
|
52
53
|
</Text>
|
|
53
54
|
{(!alertMode || closeButton) && (
|
|
54
|
-
<TouchableOpacity
|
|
55
|
-
|
|
56
|
-
onClose
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
<TouchableOpacity
|
|
56
|
+
onPress={() => {
|
|
57
|
+
if (onClose) {
|
|
58
|
+
onClose();
|
|
59
|
+
} else {
|
|
60
|
+
onCancel();
|
|
61
|
+
}
|
|
62
|
+
}}
|
|
63
|
+
style={style.button}
|
|
64
|
+
>
|
|
65
|
+
<Ionicons
|
|
66
|
+
name='close-outline'
|
|
67
|
+
size={24}
|
|
68
|
+
color={Colors.darkblue}
|
|
69
|
+
/>
|
|
62
70
|
</TouchableOpacity>
|
|
63
71
|
)}
|
|
64
72
|
</View>
|
|
@@ -70,22 +78,38 @@ const ConfirmationModal = ({
|
|
|
70
78
|
{!infoMode && (
|
|
71
79
|
<>
|
|
72
80
|
{alertMode ? (
|
|
73
|
-
<Button
|
|
74
|
-
|
|
81
|
+
<Button
|
|
82
|
+
size='fit'
|
|
83
|
+
variant={inverted ? 'inverted' : 'primary'}
|
|
84
|
+
onPress={onConfirm}
|
|
85
|
+
>
|
|
86
|
+
<Text size='large' color='white'>
|
|
87
|
+
{confirmText}
|
|
88
|
+
</Text>
|
|
75
89
|
</Button>
|
|
76
90
|
) : (
|
|
77
91
|
<View style={style.buttons}>
|
|
78
|
-
<Button
|
|
92
|
+
<Button
|
|
93
|
+
size='small'
|
|
94
|
+
bordered
|
|
95
|
+
variant='inverted'
|
|
96
|
+
onPress={onCancel}
|
|
97
|
+
>
|
|
79
98
|
<Text size='large'>{cancelText}</Text>
|
|
80
99
|
</Button>
|
|
81
|
-
<Button
|
|
82
|
-
|
|
100
|
+
<Button
|
|
101
|
+
variant={inverted ? 'inverted' : 'primary'}
|
|
102
|
+
size='small'
|
|
103
|
+
onPress={onConfirm}
|
|
104
|
+
>
|
|
105
|
+
<Text size='large' color='white'>
|
|
106
|
+
{confirmText}
|
|
107
|
+
</Text>
|
|
83
108
|
</Button>
|
|
84
109
|
</View>
|
|
85
110
|
)}
|
|
86
111
|
</>
|
|
87
112
|
)}
|
|
88
|
-
|
|
89
113
|
</View>
|
|
90
114
|
</View>
|
|
91
115
|
</TouchableWithoutFeedback>
|
|
@@ -105,7 +129,7 @@ ConfirmationModal.defaultProps = {
|
|
|
105
129
|
closeButton: false,
|
|
106
130
|
infoMode: false,
|
|
107
131
|
inverted: false,
|
|
108
|
-
children: null
|
|
132
|
+
children: null,
|
|
109
133
|
};
|
|
110
134
|
|
|
111
135
|
ConfirmationModal.propTypes = {
|
|
@@ -120,7 +144,7 @@ ConfirmationModal.propTypes = {
|
|
|
120
144
|
closeButton: PropTypes.bool,
|
|
121
145
|
infoMode: PropTypes.bool,
|
|
122
146
|
inverted: PropTypes.bool,
|
|
123
|
-
children: PropTypes.node
|
|
147
|
+
children: PropTypes.node,
|
|
124
148
|
};
|
|
125
149
|
|
|
126
150
|
export default ConfirmationModal;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Modal, TouchableOpacity, View } from 'react-native';
|
|
4
|
+
import Text from '../Text';
|
|
5
|
+
import ImageResponsive from '../ImageResponsive';
|
|
6
|
+
import style from './style';
|
|
7
|
+
|
|
8
|
+
export const ConfirmPictureModal = ({
|
|
9
|
+
avatar,
|
|
10
|
+
visible,
|
|
11
|
+
onRepeatPhoto,
|
|
12
|
+
onUsePhoto,
|
|
13
|
+
image,
|
|
14
|
+
repeatPictureText,
|
|
15
|
+
usePictureText,
|
|
16
|
+
}) => {
|
|
17
|
+
return (
|
|
18
|
+
<Modal
|
|
19
|
+
animationType='slide'
|
|
20
|
+
transparent={false}
|
|
21
|
+
visible={visible}
|
|
22
|
+
onRequestClose={() => {}}
|
|
23
|
+
>
|
|
24
|
+
<View style={style.cameraTakenImageContainer}>
|
|
25
|
+
<ImageResponsive
|
|
26
|
+
source={{
|
|
27
|
+
uri: image ? image.uri : null,
|
|
28
|
+
cache: 'only-if-cached',
|
|
29
|
+
}}
|
|
30
|
+
style={avatar ? style.cameraTakenImage : style.cameraContainer}
|
|
31
|
+
/>
|
|
32
|
+
|
|
33
|
+
<View style={style.cameraRetakePhoto}>
|
|
34
|
+
<TouchableOpacity onPress={onRepeatPhoto}>
|
|
35
|
+
<Text style={style.cameraRetakePhotoText}>{repeatPictureText}</Text>
|
|
36
|
+
</TouchableOpacity>
|
|
37
|
+
<TouchableOpacity onPress={onUsePhoto}>
|
|
38
|
+
<Text style={style.cameraRetakePhotoText}>{usePictureText}</Text>
|
|
39
|
+
</TouchableOpacity>
|
|
40
|
+
</View>
|
|
41
|
+
</View>
|
|
42
|
+
</Modal>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
ConfirmPictureModal.defaultProps = {
|
|
47
|
+
visible: false,
|
|
48
|
+
avatar: false,
|
|
49
|
+
repeatPictureText: ' ',
|
|
50
|
+
usePictureText: ' ',
|
|
51
|
+
image: null,
|
|
52
|
+
onRepeatPhoto: () => {},
|
|
53
|
+
onUsePhoto: () => {},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
ConfirmPictureModal.propTypes = {
|
|
57
|
+
visible: PropTypes.bool.isRequired,
|
|
58
|
+
avatar: PropTypes.bool,
|
|
59
|
+
repeatPictureText: PropTypes.string.isRequired,
|
|
60
|
+
usePictureText: PropTypes.string.isRequired,
|
|
61
|
+
image: PropTypes.object,
|
|
62
|
+
onRepeatPhoto: PropTypes.func.isRequired,
|
|
63
|
+
onUsePhoto: PropTypes.func.isRequired,
|
|
64
|
+
};
|
|
@@ -15,6 +15,7 @@ import Text from '../Text';
|
|
|
15
15
|
import Container from '../Container';
|
|
16
16
|
import ImageResponsive from '../ImageResponsive';
|
|
17
17
|
import { Colors } from '../../configs/constants';
|
|
18
|
+
import { ConfirmPictureModal } from './confirmPictureModal';
|
|
18
19
|
import style from './style';
|
|
19
20
|
|
|
20
21
|
const DESIRED_RATIO = '16:9';
|
|
@@ -92,7 +93,7 @@ const TakePicture = ({
|
|
|
92
93
|
const tempImage = await camera.current.takePictureAsync({ quality: 1.0 });
|
|
93
94
|
|
|
94
95
|
if (avatar) {
|
|
95
|
-
const
|
|
96
|
+
const avatarImage = await ImageManipulator.manipulateAsync(
|
|
96
97
|
tempImage.localUri || tempImage.uri,
|
|
97
98
|
[
|
|
98
99
|
{
|
|
@@ -107,7 +108,7 @@ const TakePicture = ({
|
|
|
107
108
|
{ compress: 1.0, format: ImageManipulator.SaveFormat.PNG }
|
|
108
109
|
);
|
|
109
110
|
|
|
110
|
-
setImage(
|
|
111
|
+
setImage(avatarImage);
|
|
111
112
|
setTakingPicture(false);
|
|
112
113
|
} else {
|
|
113
114
|
setImage(tempImage);
|
|
@@ -193,36 +194,14 @@ const TakePicture = ({
|
|
|
193
194
|
<Text color='white'>{processingPictureMessage} ...</Text>
|
|
194
195
|
</View>
|
|
195
196
|
)}
|
|
196
|
-
|
|
197
|
-
<Modal
|
|
198
|
-
animationType='slide'
|
|
199
|
-
transparent={false}
|
|
197
|
+
<ConfirmPictureModal
|
|
200
198
|
visible={image !== null}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
cache: 'only-if-cached',
|
|
208
|
-
}}
|
|
209
|
-
style={avatar ? style.cameraTakenImage : style.cameraContainer}
|
|
210
|
-
/>
|
|
211
|
-
|
|
212
|
-
<View style={style.cameraRetakePhoto}>
|
|
213
|
-
<TouchableOpacity onPress={repeatPhoto}>
|
|
214
|
-
<Text style={style.cameraRetakePhotoText}>
|
|
215
|
-
{repeatPictureText}
|
|
216
|
-
</Text>
|
|
217
|
-
</TouchableOpacity>
|
|
218
|
-
<TouchableOpacity onPress={usePhoto}>
|
|
219
|
-
<Text style={style.cameraRetakePhotoText}>
|
|
220
|
-
{usePictureText}
|
|
221
|
-
</Text>
|
|
222
|
-
</TouchableOpacity>
|
|
223
|
-
</View>
|
|
224
|
-
</View>
|
|
225
|
-
</Modal>
|
|
199
|
+
image={image}
|
|
200
|
+
repeatPictureText={repeatPictureText}
|
|
201
|
+
usePictureText={usePictureText}
|
|
202
|
+
onRepeatPhoto={repeatPhoto}
|
|
203
|
+
onUsePhoto={usePhoto}
|
|
204
|
+
/>
|
|
226
205
|
</Container>
|
|
227
206
|
</Modal>
|
|
228
207
|
);
|
|
@@ -47,7 +47,7 @@ const UploadDocument = ({
|
|
|
47
47
|
? await MediaLibrary.requestPermissionsAsync()
|
|
48
48
|
: await ExpoImagePicker.getMediaLibraryPermissionsAsync();
|
|
49
49
|
})();
|
|
50
|
-
});
|
|
50
|
+
}, []);
|
|
51
51
|
|
|
52
52
|
useEffect(() => {
|
|
53
53
|
if (!image) {
|
|
@@ -171,11 +171,13 @@ const UploadDocument = ({
|
|
|
171
171
|
repeatPictureText={takePicture.repeatPictureText}
|
|
172
172
|
usePictureText={takePicture.usePictureText}
|
|
173
173
|
avatar={isAvatarPicker}
|
|
174
|
-
onClose={(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
selectImage(image);
|
|
174
|
+
onClose={(selectedImage) => {
|
|
175
|
+
if (selectedImage) {
|
|
176
|
+
selectImage(selectedImage);
|
|
178
177
|
}
|
|
178
|
+
setTimeout(() => {
|
|
179
|
+
setShowCamera(false);
|
|
180
|
+
}, 0);
|
|
179
181
|
}}
|
|
180
182
|
/>
|
|
181
183
|
</View>
|