@holper/react-native-holper-storybook 0.7.0 → 0.7.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/README.md +1 -1
- package/package.json +5 -1
- package/.expo/README.md +0 -8
- package/.nvmrc +0 -1
- package/.prettierignore +0 -5
- package/.storybook/index.jsx +0 -11
- package/.storybook/main.js +0 -8
- package/.storybook/preview.jsx +0 -51
- package/.storybook/storybook.requires.js +0 -43
- package/.yarn/releases/yarn-4.5.0.cjs +0 -925
- package/.yarnrc.yml +0 -3
- package/App.jsx +0 -29
- package/app.config.js +0 -77
- package/assets/adaptive-icon.png +0 -0
- package/assets/favicon.png +0 -0
- package/assets/fonts/Poppins-Bold.ttf +0 -0
- package/assets/fonts/Poppins-Regular.ttf +0 -0
- package/assets/fonts/Poppins-SemiBold.ttf +0 -0
- package/assets/icon.png +0 -0
- package/assets/splash.png +0 -0
- package/babel.config.js +0 -7
- package/build.sh +0 -11
- package/components/Button/index.tsx +0 -66
- package/components/Button/style.ts +0 -111
- package/components/Card/index.tsx +0 -33
- package/components/Card/style.ts +0 -34
- package/components/ConfirmationModal/index.tsx +0 -104
- package/components/ConfirmationModal/style.tsx +0 -53
- package/components/Container/index.tsx +0 -33
- package/components/Container/style.ts +0 -13
- package/components/CustomChatView/index.tsx +0 -65
- package/components/CustomChatView/style.ts +0 -10
- package/components/DeckSwiper/index.tsx +0 -90
- package/components/DeckSwiper/style.ts +0 -59
- package/components/DonutCountdown/index.tsx +0 -86
- package/components/DonutCountdown/style.ts +0 -8
- package/components/FloatingContainer/index.tsx +0 -35
- package/components/FloatingContainer/style.ts +0 -25
- package/components/Footer/index.tsx +0 -35
- package/components/Footer/style.ts +0 -40
- package/components/Header/index.tsx +0 -21
- package/components/Header/style.ts +0 -34
- package/components/ImagePicker/index.tsx +0 -18
- package/components/ImageResponsive/index.tsx +0 -24
- package/components/ImageResponsive/style.ts +0 -9
- package/components/ImageViewer/index.tsx +0 -36
- package/components/ImageViewer/style.ts +0 -38
- package/components/Input/index.tsx +0 -62
- package/components/Input/style.ts +0 -91
- package/components/InputPin/index.tsx +0 -21
- package/components/InputPin/style.ts +0 -22
- package/components/MenuItem/index.tsx +0 -25
- package/components/MenuItem/style.ts +0 -44
- package/components/NavigationTitle/index.tsx +0 -53
- package/components/NavigationTitle/style.ts +0 -49
- package/components/Notification/index.tsx +0 -44
- package/components/Notification/style.ts +0 -50
- package/components/PreventDoubleClick/index.tsx +0 -28
- package/components/Select/index.tsx +0 -51
- package/components/Select/style.ts +0 -64
- package/components/SwipeablePanel/index.tsx +0 -208
- package/components/SwipeablePanel/style.ts +0 -81
- package/components/Switch/index.tsx +0 -30
- package/components/TakePicture/confirmPictureModal.tsx +0 -37
- package/components/TakePicture/index.tsx +0 -148
- package/components/TakePicture/style.ts +0 -95
- package/components/Text/index.tsx +0 -33
- package/components/Text/style.ts +0 -101
- package/components/Textarea/index.tsx +0 -26
- package/components/Textarea/style.ts +0 -38
- package/components/TimeOutButton/index.tsx +0 -67
- package/components/TimeOutButton/style.ts +0 -42
- package/components/Toast/index.tsx +0 -34
- package/components/Toast/style.ts +0 -12
- package/components/UploadDocument/index.tsx +0 -179
- package/components/UploadDocument/style.ts +0 -57
- package/components/VirtualKeyboard/index.tsx +0 -75
- package/components/VirtualKeyboard/style.ts +0 -25
- package/components/index.ts +0 -29
- package/configs/constants.ts +0 -273
- package/configs/types.ts +0 -326
- package/eas.json +0 -27
- package/eslint.config.mjs +0 -205
- package/hooks/index.ts +0 -2
- package/hooks/useDebounce.tsx +0 -24
- package/hooks/useLoadFonts.tsx +0 -13
- package/metro.config.js +0 -11
- package/prettier.config.mjs +0 -23
- package/stories/Button.stories.tsx +0 -181
- package/stories/Card.stories.tsx +0 -22
- package/stories/Colors.stories.tsx +0 -57
- package/stories/ConfirmationModal.stories.tsx +0 -142
- package/stories/Container.stories.tsx +0 -105
- package/stories/DeckSwiper.stories.tsx +0 -43
- package/stories/DonutCountdown.stories.tsx +0 -134
- package/stories/FloatingContainer.stories.tsx +0 -139
- package/stories/Footer.stories.tsx +0 -65
- package/stories/Header.stories.tsx +0 -37
- package/stories/ImagePicker.stories.tsx +0 -14
- package/stories/ImageResponsive.stories.tsx +0 -18
- package/stories/ImageViewer.stories.tsx +0 -24
- package/stories/Input.stories.tsx +0 -119
- package/stories/InputPin.stories.tsx +0 -40
- package/stories/Menu.stories.tsx +0 -53
- package/stories/MenuItem.stories.tsx +0 -30
- package/stories/NavigationTitle.stories.tsx +0 -51
- package/stories/Notification.stories.tsx +0 -58
- package/stories/Select.stories.tsx +0 -270
- package/stories/SwipeablePanel.stories.tsx +0 -360
- package/stories/Switch.stories.tsx +0 -36
- package/stories/TakePicture.stories.tsx +0 -59
- package/stories/Text.stories.tsx +0 -61
- package/stories/Textarea.stories.tsx +0 -48
- package/stories/TimeOutButton.stories.tsx +0 -55
- package/stories/Toast.stories.tsx +0 -37
- package/stories/UploadDocument.stories.tsx +0 -179
- package/stories/VirtualKeyboard.stories.tsx +0 -14
- package/tsconfig.json +0 -21
- package/utilities/ScrollView.tsx +0 -19
- package/utilities/index.ts +0 -2
- package/utilities/utils.ts +0 -29
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { Ionicons } from '@expo/vector-icons';
|
|
2
|
-
import Constants from 'expo-constants';
|
|
3
|
-
import { useEffect, useRef, useState } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
Animated,
|
|
6
|
-
Dimensions,
|
|
7
|
-
PanResponder,
|
|
8
|
-
Platform,
|
|
9
|
-
ScrollView,
|
|
10
|
-
TouchableOpacity,
|
|
11
|
-
TouchableWithoutFeedback,
|
|
12
|
-
View,
|
|
13
|
-
} from 'react-native';
|
|
14
|
-
|
|
15
|
-
import { Colors } from '../../configs/constants';
|
|
16
|
-
import DonutCountdown from '../DonutCountdown';
|
|
17
|
-
import style from './style';
|
|
18
|
-
|
|
19
|
-
import type { SwipeablePanelProps } from '../../configs/types';
|
|
20
|
-
|
|
21
|
-
const { height: screenHeight } = Dimensions.get('window');
|
|
22
|
-
|
|
23
|
-
const STATUS = {
|
|
24
|
-
MEDIUM: 0,
|
|
25
|
-
LARGE: 1,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const calcMarginTop = () => {
|
|
29
|
-
if (Platform.OS === 'ios') {
|
|
30
|
-
return Constants.statusBarHeight === 44 ? 10 : -50;
|
|
31
|
-
} else {
|
|
32
|
-
return -50;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const SwipeablePanel = ({
|
|
37
|
-
offset = 0,
|
|
38
|
-
maximized,
|
|
39
|
-
lockPanel,
|
|
40
|
-
autoMaximize,
|
|
41
|
-
closeButton,
|
|
42
|
-
closeAfterSeconds = 0,
|
|
43
|
-
onClose,
|
|
44
|
-
avoidScroll,
|
|
45
|
-
children,
|
|
46
|
-
}: SwipeablePanelProps) => {
|
|
47
|
-
const LARGE_PANEL_HEIGHT = screenHeight - offset - calcMarginTop(); // This is the margin top
|
|
48
|
-
const MEDIUM_PANEL_HEIGHT = 400; // Fixed height
|
|
49
|
-
|
|
50
|
-
const [closeButtonClicked, setCloseButtonClicked] = useState(false);
|
|
51
|
-
const [status, setStatus] = useState(STATUS.LARGE);
|
|
52
|
-
const [animatedValueY, setAnimatedValueY] = useState(LARGE_PANEL_HEIGHT);
|
|
53
|
-
const pan = useRef(new Animated.ValueXY({ x: 0, y: LARGE_PANEL_HEIGHT })).current;
|
|
54
|
-
|
|
55
|
-
const _animateTo = (newStatus = 0, firstAnimate?: boolean) => {
|
|
56
|
-
if (!firstAnimate && lockPanel) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (status === newStatus) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
let newY = 0;
|
|
65
|
-
|
|
66
|
-
if (newStatus === STATUS.MEDIUM) {
|
|
67
|
-
newY = MEDIUM_PANEL_HEIGHT;
|
|
68
|
-
} else if (newStatus === STATUS.LARGE) {
|
|
69
|
-
newY = LARGE_PANEL_HEIGHT;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
setStatus(newStatus);
|
|
73
|
-
|
|
74
|
-
Animated.spring(pan, {
|
|
75
|
-
toValue: { x: 0, y: newY },
|
|
76
|
-
tension: 80,
|
|
77
|
-
friction: 25,
|
|
78
|
-
useNativeDriver: true,
|
|
79
|
-
restDisplacementThreshold: 10,
|
|
80
|
-
restSpeedThreshold: 10,
|
|
81
|
-
}).start();
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
useEffect(() => {
|
|
85
|
-
pan.y.addListener(({ value }) => setAnimatedValueY(value));
|
|
86
|
-
_animateTo(maximized ? STATUS.MEDIUM : STATUS.LARGE, true);
|
|
87
|
-
if (autoMaximize) {
|
|
88
|
-
setTimeout(() => _animateTo(STATUS.MEDIUM), 2000);
|
|
89
|
-
}
|
|
90
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
|
-
}, [offset, autoMaximize]);
|
|
92
|
-
|
|
93
|
-
const panResponder = useRef(
|
|
94
|
-
PanResponder.create({
|
|
95
|
-
onStartShouldSetPanResponder: (evt, gestureState) => true,
|
|
96
|
-
onPanResponderGrant: (evt, gestureState) => {
|
|
97
|
-
if (status === STATUS.LARGE) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
pan.setOffset({
|
|
102
|
-
x: 0,
|
|
103
|
-
y: animatedValueY,
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
pan.setValue({ x: 0, y: 0 });
|
|
107
|
-
},
|
|
108
|
-
onPanResponderMove: (evt, gestureState) => {
|
|
109
|
-
// @ts-expect-error omit ._value and ._offset
|
|
110
|
-
if (status === STATUS.MEDIUM && Math.abs(pan.y._value) <= pan.y._offset) {
|
|
111
|
-
pan.setValue({
|
|
112
|
-
x: 0,
|
|
113
|
-
y: gestureState.dy,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
onPanResponderRelease: (evt, gestureState) => {
|
|
118
|
-
pan.flattenOffset();
|
|
119
|
-
|
|
120
|
-
if (gestureState.dy === 0) {
|
|
121
|
-
_animateTo(status);
|
|
122
|
-
} else if (gestureState.dy < -100 || gestureState.vy < -0.5) {
|
|
123
|
-
_animateTo(STATUS.MEDIUM);
|
|
124
|
-
} else if (gestureState.dy > 100 || gestureState.vy > 0.5) {
|
|
125
|
-
_animateTo(STATUS.MEDIUM);
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
})
|
|
129
|
-
).current;
|
|
130
|
-
|
|
131
|
-
const renderContent = () => (
|
|
132
|
-
<TouchableWithoutFeedback onPress={() => _animateTo(STATUS.MEDIUM)}>
|
|
133
|
-
<View style={style.contentContainer}>{children}</View>
|
|
134
|
-
</TouchableWithoutFeedback>
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
return (
|
|
138
|
-
<Animated.View style={style.background}>
|
|
139
|
-
<TouchableWithoutFeedback onPress={() => (maximized ? null : _animateTo(STATUS.LARGE))}>
|
|
140
|
-
<View style={style.backgroundLayer} />
|
|
141
|
-
</TouchableWithoutFeedback>
|
|
142
|
-
<Animated.View
|
|
143
|
-
style={[
|
|
144
|
-
style.panel,
|
|
145
|
-
{
|
|
146
|
-
bottom: MEDIUM_PANEL_HEIGHT - 1,
|
|
147
|
-
height: LARGE_PANEL_HEIGHT,
|
|
148
|
-
transform: pan.getTranslateTransform(),
|
|
149
|
-
},
|
|
150
|
-
]}
|
|
151
|
-
{...panResponder.panHandlers}
|
|
152
|
-
>
|
|
153
|
-
<View style={style.barContainer}>
|
|
154
|
-
<View style={style.bar} />
|
|
155
|
-
</View>
|
|
156
|
-
|
|
157
|
-
{closeButton && (
|
|
158
|
-
<TouchableOpacity
|
|
159
|
-
onPress={() => {
|
|
160
|
-
setCloseButtonClicked(true);
|
|
161
|
-
if (onClose) {
|
|
162
|
-
onClose();
|
|
163
|
-
}
|
|
164
|
-
}}
|
|
165
|
-
style={style.closeButton}
|
|
166
|
-
>
|
|
167
|
-
<Ionicons name="close-outline" size={20} color={Colors.darkblue} />
|
|
168
|
-
</TouchableOpacity>
|
|
169
|
-
)}
|
|
170
|
-
|
|
171
|
-
{closeAfterSeconds > 0 && (
|
|
172
|
-
<View style={style.autoClose}>
|
|
173
|
-
<DonutCountdown
|
|
174
|
-
duration={closeAfterSeconds}
|
|
175
|
-
color={Colors.green}
|
|
176
|
-
onComplete={() => {
|
|
177
|
-
if (!closeButtonClicked) {
|
|
178
|
-
if (onClose) {
|
|
179
|
-
onClose();
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}}
|
|
183
|
-
radius={16}
|
|
184
|
-
strokeWidth={4}
|
|
185
|
-
textSize="small"
|
|
186
|
-
/>
|
|
187
|
-
</View>
|
|
188
|
-
)}
|
|
189
|
-
|
|
190
|
-
{avoidScroll ? (
|
|
191
|
-
<>{renderContent()}</>
|
|
192
|
-
) : (
|
|
193
|
-
<ScrollView
|
|
194
|
-
onTouchStart={() => false}
|
|
195
|
-
onTouchEnd={() => false}
|
|
196
|
-
showsVerticalScrollIndicator={false}
|
|
197
|
-
fadingEdgeLength={150}
|
|
198
|
-
scrollEnabled={status === STATUS.MEDIUM}
|
|
199
|
-
>
|
|
200
|
-
{renderContent()}
|
|
201
|
-
</ScrollView>
|
|
202
|
-
)}
|
|
203
|
-
</Animated.View>
|
|
204
|
-
</Animated.View>
|
|
205
|
-
);
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
export default SwipeablePanel;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { Dimensions, StyleSheet } from 'react-native';
|
|
2
|
-
|
|
3
|
-
import { Colors } from '../../configs/constants';
|
|
4
|
-
|
|
5
|
-
const { width } = Dimensions.get('window');
|
|
6
|
-
|
|
7
|
-
export default StyleSheet.create({
|
|
8
|
-
background: {
|
|
9
|
-
position: 'relative',
|
|
10
|
-
width,
|
|
11
|
-
zIndex: 1,
|
|
12
|
-
flex: 1,
|
|
13
|
-
justifyContent: 'center',
|
|
14
|
-
alignItems: 'center',
|
|
15
|
-
overflow: 'hidden',
|
|
16
|
-
},
|
|
17
|
-
backgroundLayer: {
|
|
18
|
-
width,
|
|
19
|
-
flex: 1,
|
|
20
|
-
},
|
|
21
|
-
panel: {
|
|
22
|
-
position: 'absolute',
|
|
23
|
-
width,
|
|
24
|
-
display: 'flex',
|
|
25
|
-
flexDirection: 'column',
|
|
26
|
-
backgroundColor: Colors.white,
|
|
27
|
-
borderColor: Colors.lightblue,
|
|
28
|
-
borderWidth: 1,
|
|
29
|
-
borderBottomColor: Colors.transparent,
|
|
30
|
-
borderTopLeftRadius: 20,
|
|
31
|
-
borderTopRightRadius: 20,
|
|
32
|
-
borderBottomLeftRadius: 0,
|
|
33
|
-
borderBottomRightRadius: 0,
|
|
34
|
-
overflow: 'hidden',
|
|
35
|
-
shadowColor: Colors.darkgray,
|
|
36
|
-
shadowOffset: {
|
|
37
|
-
width: 0,
|
|
38
|
-
height: 1,
|
|
39
|
-
},
|
|
40
|
-
shadowOpacity: 0.18,
|
|
41
|
-
shadowRadius: 1.0,
|
|
42
|
-
elevation: 1,
|
|
43
|
-
zIndex: 2,
|
|
44
|
-
paddingHorizontal: 20,
|
|
45
|
-
paddingBottom: 20,
|
|
46
|
-
},
|
|
47
|
-
barContainer: {
|
|
48
|
-
height: 50,
|
|
49
|
-
justifyContent: 'center',
|
|
50
|
-
alignItems: 'center',
|
|
51
|
-
},
|
|
52
|
-
bar: {
|
|
53
|
-
backgroundColor: Colors.lightblue,
|
|
54
|
-
height: 5,
|
|
55
|
-
width: width * 0.12,
|
|
56
|
-
borderRadius: 5,
|
|
57
|
-
},
|
|
58
|
-
content: {
|
|
59
|
-
paddingHorizontal: 20,
|
|
60
|
-
},
|
|
61
|
-
contentContainer: {
|
|
62
|
-
width: '100%',
|
|
63
|
-
flex: 1,
|
|
64
|
-
},
|
|
65
|
-
closeButton: {
|
|
66
|
-
position: 'absolute',
|
|
67
|
-
right: 10,
|
|
68
|
-
top: 10,
|
|
69
|
-
height: 30,
|
|
70
|
-
width: 30,
|
|
71
|
-
borderRadius: 15,
|
|
72
|
-
backgroundColor: Colors.lightblue,
|
|
73
|
-
alignItems: 'center',
|
|
74
|
-
justifyContent: 'center',
|
|
75
|
-
},
|
|
76
|
-
autoClose: {
|
|
77
|
-
position: 'absolute',
|
|
78
|
-
left: 10,
|
|
79
|
-
top: 10,
|
|
80
|
-
},
|
|
81
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Platform, Switch as RNSwitch } from 'react-native';
|
|
2
|
-
|
|
3
|
-
import { Colors } from '../../configs/constants';
|
|
4
|
-
|
|
5
|
-
import type { SwitchProps } from '../../configs/types';
|
|
6
|
-
|
|
7
|
-
const Switch = ({ value, size = 'medium', ...props }: SwitchProps) => (
|
|
8
|
-
<RNSwitch
|
|
9
|
-
trackColor={{
|
|
10
|
-
false: Colors.lightblue,
|
|
11
|
-
true: Colors.lightblue,
|
|
12
|
-
}}
|
|
13
|
-
thumbColor={value ? Colors.green : Colors.midblue}
|
|
14
|
-
ios_backgroundColor={Colors.white}
|
|
15
|
-
value={value}
|
|
16
|
-
style={{
|
|
17
|
-
transform: [
|
|
18
|
-
{
|
|
19
|
-
scaleX: size === 'small' ? (Platform.OS === 'ios' ? 0.5 : 0.7) : Platform.OS === 'ios' ? 0.7 : 0.9,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
scaleY: size === 'small' ? (Platform.OS === 'ios' ? 0.5 : 0.7) : Platform.OS === 'ios' ? 0.7 : 0.9,
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
}}
|
|
26
|
-
{...props}
|
|
27
|
-
/>
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
export default Switch;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Modal, TouchableOpacity, View } from 'react-native';
|
|
2
|
-
|
|
3
|
-
import ImageResponsive from '../ImageResponsive';
|
|
4
|
-
import Text from '../Text';
|
|
5
|
-
import style from './style';
|
|
6
|
-
|
|
7
|
-
import type { ConfirmPictureModalProps } from '../../configs/types';
|
|
8
|
-
|
|
9
|
-
export const ConfirmPictureModal = ({
|
|
10
|
-
avatar,
|
|
11
|
-
visible,
|
|
12
|
-
onRepeatPhoto,
|
|
13
|
-
onUsePhoto,
|
|
14
|
-
image,
|
|
15
|
-
repeatPictureText,
|
|
16
|
-
usePictureText,
|
|
17
|
-
}: ConfirmPictureModalProps) => (
|
|
18
|
-
<Modal animationType="slide" transparent={false} visible={visible} onRequestClose={() => {}}>
|
|
19
|
-
<View style={style.cameraTakenImageContainer}>
|
|
20
|
-
<ImageResponsive
|
|
21
|
-
source={
|
|
22
|
-
image && typeof image === 'object' && 'uri' in image ? { uri: image.uri } : image === null ? undefined : image
|
|
23
|
-
}
|
|
24
|
-
style={avatar ? style.cameraTakenImage : style.cameraContainer}
|
|
25
|
-
/>
|
|
26
|
-
|
|
27
|
-
<View style={style.cameraRetakePhoto}>
|
|
28
|
-
<TouchableOpacity onPress={onRepeatPhoto}>
|
|
29
|
-
<Text style={style.cameraRetakePhotoText}>{repeatPictureText}</Text>
|
|
30
|
-
</TouchableOpacity>
|
|
31
|
-
<TouchableOpacity onPress={onUsePhoto}>
|
|
32
|
-
<Text style={style.cameraRetakePhotoText}>{usePictureText}</Text>
|
|
33
|
-
</TouchableOpacity>
|
|
34
|
-
</View>
|
|
35
|
-
</View>
|
|
36
|
-
</Modal>
|
|
37
|
-
);
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import type { CameraType } from 'expo-camera';
|
|
2
|
-
|
|
3
|
-
import { Ionicons } from '@expo/vector-icons';
|
|
4
|
-
import { CameraView, useCameraPermissions } from 'expo-camera';
|
|
5
|
-
import * as ImageManipulator from 'expo-image-manipulator';
|
|
6
|
-
import { useRef, useState } from 'react';
|
|
7
|
-
import { ActivityIndicator, Modal, TouchableOpacity, View } from 'react-native';
|
|
8
|
-
import { Circle, Defs, Mask, Rect, Svg } from 'react-native-svg';
|
|
9
|
-
|
|
10
|
-
import { Colors } from '../../configs/constants';
|
|
11
|
-
import Button from '../Button';
|
|
12
|
-
import Container from '../Container';
|
|
13
|
-
import Text from '../Text';
|
|
14
|
-
import { ConfirmPictureModal } from './confirmPictureModal';
|
|
15
|
-
import style from './style';
|
|
16
|
-
|
|
17
|
-
import type { TakePictureProps } from '../../configs/types';
|
|
18
|
-
|
|
19
|
-
const DESIRED_RATIO = '16:9';
|
|
20
|
-
|
|
21
|
-
const SvgCircle = () => (
|
|
22
|
-
<Svg height="100%" width="100%">
|
|
23
|
-
<Defs>
|
|
24
|
-
<Mask id="mask" x="0" y="0" height="100%" width="100%">
|
|
25
|
-
<Rect height="100%" width="100%" fill={Colors.white} />
|
|
26
|
-
<Circle r="29%" cx="50%" cy="50%" fill={Colors.darkgray} />
|
|
27
|
-
</Mask>
|
|
28
|
-
</Defs>
|
|
29
|
-
<Rect height="100%" width="100%" fill="rgba(0, 0, 0, 0.8)" mask="url(#mask)" fill-opacity="0" />
|
|
30
|
-
</Svg>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const TakePicture = ({
|
|
34
|
-
visible,
|
|
35
|
-
onClose,
|
|
36
|
-
avatar,
|
|
37
|
-
cameraErrorMessage,
|
|
38
|
-
requestPermissionsMessage,
|
|
39
|
-
processingPictureMessage,
|
|
40
|
-
repeatPictureText,
|
|
41
|
-
usePictureText,
|
|
42
|
-
}: TakePictureProps) => {
|
|
43
|
-
const [permission, requestPermission] = useCameraPermissions();
|
|
44
|
-
const [type, setType] = useState<CameraType>('back');
|
|
45
|
-
const [image, setImage] = useState<ImageManipulator.ImageResult | null>(null);
|
|
46
|
-
const [takingPicture, setTakingPicture] = useState<boolean>(false);
|
|
47
|
-
const camera = useRef<CameraView>(null);
|
|
48
|
-
|
|
49
|
-
const flipCamera = () => {
|
|
50
|
-
setType((current) => (current === 'back' ? 'front' : 'back'));
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const takePicture = async () => {
|
|
54
|
-
if (camera.current) {
|
|
55
|
-
setTakingPicture(true);
|
|
56
|
-
const tempImage = await camera.current.takePictureAsync({ quality: 1.0 });
|
|
57
|
-
|
|
58
|
-
if (avatar) {
|
|
59
|
-
const avatarImage = await ImageManipulator.manipulateAsync(
|
|
60
|
-
tempImage.uri,
|
|
61
|
-
[
|
|
62
|
-
{
|
|
63
|
-
crop: {
|
|
64
|
-
originX: 0,
|
|
65
|
-
originY: (tempImage.height - tempImage.width) / 2,
|
|
66
|
-
width: tempImage.width,
|
|
67
|
-
height: tempImage.width,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
{ compress: 1.0, format: ImageManipulator.SaveFormat.PNG }
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
setImage(avatarImage);
|
|
75
|
-
setTakingPicture(false);
|
|
76
|
-
} else {
|
|
77
|
-
setImage(tempImage);
|
|
78
|
-
setTakingPicture(false);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const repeatPhoto = () => {
|
|
84
|
-
setImage(null);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const usePhoto = () => {
|
|
88
|
-
if (image) {
|
|
89
|
-
onClose(typeof image === 'object' ? image.uri : image);
|
|
90
|
-
setImage(null);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const closeModal = () => {
|
|
95
|
-
setImage(null);
|
|
96
|
-
onClose();
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
if (!permission?.granted) {
|
|
100
|
-
return (
|
|
101
|
-
<View style={style.cameraPermissionsContainer}>
|
|
102
|
-
<Text color="red">{cameraErrorMessage}</Text>
|
|
103
|
-
<Button onPress={requestPermission} variant="inverted">
|
|
104
|
-
<Text color="white">{requestPermissionsMessage}</Text>
|
|
105
|
-
</Button>
|
|
106
|
-
</View>
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return (
|
|
111
|
-
<Modal animationType="slide" transparent={false} visible={visible} onRequestClose={() => onClose()}>
|
|
112
|
-
<Container style={style.cameraContainer}>
|
|
113
|
-
<CameraView ref={camera} style={style.cameraContainer} facing={type} ratio={DESIRED_RATIO}>
|
|
114
|
-
{avatar && <SvgCircle />}
|
|
115
|
-
|
|
116
|
-
<View style={style.cameraFlipContainer}>
|
|
117
|
-
<TouchableOpacity onPress={closeModal} style={style.closeIcon}>
|
|
118
|
-
<Ionicons name="close-outline" color={Colors.darkblue} size={24} />
|
|
119
|
-
</TouchableOpacity>
|
|
120
|
-
<TouchableOpacity style={style.cameraFlipBtn} onPress={flipCamera}>
|
|
121
|
-
<Ionicons name="camera-reverse-outline" style={style.cameraFlipIcon} color={Colors.white} size={40} />
|
|
122
|
-
</TouchableOpacity>
|
|
123
|
-
<TouchableOpacity style={style.cameraRecordBtn} onPress={takePicture}>
|
|
124
|
-
<Ionicons name="radio-button-on-outline" color={Colors.red} size={60} />
|
|
125
|
-
</TouchableOpacity>
|
|
126
|
-
</View>
|
|
127
|
-
</CameraView>
|
|
128
|
-
|
|
129
|
-
{takingPicture && (
|
|
130
|
-
<View style={style.cameraTakingPictureOverlay}>
|
|
131
|
-
<ActivityIndicator color={Colors.darkblue} />
|
|
132
|
-
<Text color="white">{processingPictureMessage} ...</Text>
|
|
133
|
-
</View>
|
|
134
|
-
)}
|
|
135
|
-
<ConfirmPictureModal
|
|
136
|
-
visible={image !== null}
|
|
137
|
-
image={image}
|
|
138
|
-
repeatPictureText={repeatPictureText}
|
|
139
|
-
usePictureText={usePictureText}
|
|
140
|
-
onRepeatPhoto={repeatPhoto}
|
|
141
|
-
onUsePhoto={usePhoto}
|
|
142
|
-
/>
|
|
143
|
-
</Container>
|
|
144
|
-
</Modal>
|
|
145
|
-
);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
export default TakePicture;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { Dimensions, StyleSheet } from 'react-native';
|
|
2
|
-
|
|
3
|
-
import { Colors } from '../../configs/constants';
|
|
4
|
-
|
|
5
|
-
const { width } = Dimensions.get('window');
|
|
6
|
-
|
|
7
|
-
export default StyleSheet.create({
|
|
8
|
-
cameraContainer: {
|
|
9
|
-
flex: 1,
|
|
10
|
-
...StyleSheet.absoluteFillObject,
|
|
11
|
-
position: 'absolute',
|
|
12
|
-
},
|
|
13
|
-
closeIcon: {
|
|
14
|
-
position: 'absolute',
|
|
15
|
-
right: 25,
|
|
16
|
-
top: 50,
|
|
17
|
-
zIndex: 9999,
|
|
18
|
-
height: 30,
|
|
19
|
-
width: 30,
|
|
20
|
-
borderRadius: 15,
|
|
21
|
-
backgroundColor: Colors.lightblue,
|
|
22
|
-
alignItems: 'center',
|
|
23
|
-
justifyContent: 'center',
|
|
24
|
-
},
|
|
25
|
-
cameraFlipContainer: {
|
|
26
|
-
flex: 1,
|
|
27
|
-
backgroundColor: Colors.transparent,
|
|
28
|
-
flexDirection: 'row',
|
|
29
|
-
marginBottom: 20,
|
|
30
|
-
...StyleSheet.absoluteFillObject,
|
|
31
|
-
},
|
|
32
|
-
cameraFlipBtn: {
|
|
33
|
-
flex: 0.2,
|
|
34
|
-
alignSelf: 'flex-end',
|
|
35
|
-
alignItems: 'center',
|
|
36
|
-
paddingLeft: 15,
|
|
37
|
-
paddingBottom: 10,
|
|
38
|
-
height: 60,
|
|
39
|
-
},
|
|
40
|
-
cameraFlipIcon: {
|
|
41
|
-
position: 'absolute',
|
|
42
|
-
bottom: 10,
|
|
43
|
-
left: 25,
|
|
44
|
-
},
|
|
45
|
-
cameraRecordBtn: {
|
|
46
|
-
position: 'absolute',
|
|
47
|
-
bottom: 0,
|
|
48
|
-
left: width / 2 - 25,
|
|
49
|
-
},
|
|
50
|
-
cameraRetakePhoto: {
|
|
51
|
-
height: 40,
|
|
52
|
-
width,
|
|
53
|
-
backgroundColor: Colors.green,
|
|
54
|
-
flexDirection: 'row',
|
|
55
|
-
justifyContent: 'space-between',
|
|
56
|
-
alignItems: 'center',
|
|
57
|
-
paddingVertical: 10,
|
|
58
|
-
paddingHorizontal: 30,
|
|
59
|
-
position: 'absolute',
|
|
60
|
-
bottom: 0,
|
|
61
|
-
left: 0,
|
|
62
|
-
},
|
|
63
|
-
cameraRetakePhotoText: {
|
|
64
|
-
color: Colors.white,
|
|
65
|
-
},
|
|
66
|
-
cameraTakingPictureOverlay: {
|
|
67
|
-
...StyleSheet.absoluteFillObject,
|
|
68
|
-
justifyContent: 'center',
|
|
69
|
-
alignItems: 'center',
|
|
70
|
-
zIndex: 999,
|
|
71
|
-
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
72
|
-
},
|
|
73
|
-
cameraTakenImageContainer: {
|
|
74
|
-
backgroundColor: 'rgba(0,0,0,0.9)',
|
|
75
|
-
flex: 1,
|
|
76
|
-
...StyleSheet.absoluteFillObject,
|
|
77
|
-
position: 'absolute',
|
|
78
|
-
justifyContent: 'center',
|
|
79
|
-
alignItems: 'center',
|
|
80
|
-
},
|
|
81
|
-
cameraTakenImage: {
|
|
82
|
-
width: width - 30,
|
|
83
|
-
height: width - 30,
|
|
84
|
-
alignSelf: 'center',
|
|
85
|
-
position: 'relative',
|
|
86
|
-
},
|
|
87
|
-
cameraPermissionsContainer: {
|
|
88
|
-
flex: 1,
|
|
89
|
-
...StyleSheet.absoluteFillObject,
|
|
90
|
-
position: 'absolute',
|
|
91
|
-
backgroundColor: Colors.white,
|
|
92
|
-
justifyContent: 'center',
|
|
93
|
-
alignItems: 'center',
|
|
94
|
-
},
|
|
95
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Text as RNText } from 'react-native';
|
|
2
|
-
|
|
3
|
-
import style from './style';
|
|
4
|
-
|
|
5
|
-
import type { TextProps } from '../../configs/types';
|
|
6
|
-
|
|
7
|
-
const Text = ({
|
|
8
|
-
variant = 'default',
|
|
9
|
-
size = 'medium',
|
|
10
|
-
color = 'dark',
|
|
11
|
-
weight = 'regular',
|
|
12
|
-
align = 'left',
|
|
13
|
-
style: customStyle = {},
|
|
14
|
-
children,
|
|
15
|
-
...props
|
|
16
|
-
}: TextProps) => (
|
|
17
|
-
<RNText
|
|
18
|
-
style={[
|
|
19
|
-
style[variant as keyof typeof style],
|
|
20
|
-
style[size as keyof typeof style],
|
|
21
|
-
style[color as keyof typeof style],
|
|
22
|
-
style[weight as keyof typeof style],
|
|
23
|
-
style[align as keyof typeof style],
|
|
24
|
-
{ ...customStyle },
|
|
25
|
-
]}
|
|
26
|
-
allowFontScaling={false}
|
|
27
|
-
{...props}
|
|
28
|
-
>
|
|
29
|
-
{children}
|
|
30
|
-
</RNText>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
export default Text;
|