@holper/react-native-holper-storybook 0.7.1 → 0.8.0
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/index.js +2 -3
- package/lib/components/Button/index.js +104 -0
- package/lib/components/Button/{style.ts → style.js} +7 -8
- package/lib/components/Card/index.js +49 -0
- package/lib/components/Card/{style.ts → style.js} +4 -5
- package/lib/components/ConfirmationModal/{index.tsx → index.js} +79 -25
- package/lib/components/ConfirmationModal/{style.tsx → style.js} +13 -14
- package/lib/components/Container/{index.tsx → index.js} +28 -7
- package/lib/components/Container/{style.ts → style.js} +5 -6
- package/lib/components/CustomChatView/{index.tsx → index.js} +30 -22
- package/lib/components/CustomChatView/{style.ts → style.js} +1 -1
- package/lib/components/DeckSwiper/index.js +118 -0
- package/lib/components/DeckSwiper/{style.ts → style.js} +12 -13
- package/lib/components/FlashMessage/index.js +83 -0
- package/lib/components/FloatingContainer/index.js +69 -0
- package/lib/components/FloatingContainer/{style.ts → style.js} +6 -7
- package/lib/components/Footer/index.js +61 -0
- package/lib/components/Footer/{style.ts → style.js} +3 -4
- package/lib/components/Header/index.js +45 -0
- package/lib/components/Header/{style.ts → style.js} +3 -4
- package/lib/components/ImagePicker/{index.tsx → index.js} +12 -3
- package/lib/components/ImageResponsive/index.js +39 -0
- package/lib/components/ImageResponsive/style.js +7 -0
- package/lib/components/ImageViewer/index.js +62 -0
- package/lib/components/ImageViewer/{style.ts → style.js} +3 -4
- package/lib/components/Input/{index.tsx → index.js} +33 -6
- package/lib/components/Input/{style.ts → style.js} +18 -7
- package/lib/components/InputPin/{index.tsx → index.js} +13 -6
- package/lib/components/InputPin/{style.ts → style.js} +6 -7
- package/lib/components/MenuItem/index.js +44 -0
- package/lib/components/MenuItem/{style.ts → style.js} +7 -9
- package/lib/components/NavigationTitle/{index.tsx → index.js} +30 -9
- package/lib/components/NavigationTitle/{style.ts → style.js} +11 -12
- package/lib/components/Notification/index.js +80 -0
- package/lib/components/Notification/{style.ts → style.js} +11 -13
- package/lib/components/PreventDoubleClick/index.js +21 -0
- package/lib/components/Select/index.js +89 -0
- package/lib/components/Select/style.js +81 -0
- package/lib/components/SwipeablePanel/{index.tsx → index.js} +85 -58
- package/lib/components/SwipeablePanel/{style.ts → style.js} +14 -15
- package/lib/components/Switch/index.js +57 -0
- package/lib/components/TakePicture/{confirmPictureModal.tsx → confirmPictureModal.js} +33 -9
- package/lib/components/TakePicture/index.js +198 -0
- package/lib/components/TakePicture/{style.ts → style.js} +4 -4
- package/lib/components/Text/index.js +75 -0
- package/lib/components/Text/{style.ts → style.js} +2 -4
- package/lib/components/Textarea/{index.tsx → index.js} +24 -5
- package/lib/components/Textarea/{style.ts → style.js} +4 -5
- package/lib/components/TimeOutButton/index.js +104 -0
- package/lib/components/TimeOutButton/{style.ts → style.js} +3 -4
- package/lib/components/UploadDocument/index.js +222 -0
- package/lib/components/UploadDocument/{style.ts → style.js} +15 -16
- package/lib/components/VirtualKeyboard/index.js +86 -0
- package/lib/components/VirtualKeyboard/{style.ts → style.js} +8 -9
- package/lib/components/index.js +28 -0
- package/lib/configs/constants.js +276 -0
- package/lib/configs/loadFonts.js +11 -0
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/{useDebounce.tsx → useDebounce.js} +4 -6
- package/lib/index.js +2 -3
- package/package.json +58 -72
- package/{README.md → readme.md} +20 -19
- package/LICENSE +0 -21
- package/lib/components/Button/index.tsx +0 -66
- package/lib/components/Card/index.tsx +0 -33
- package/lib/components/DeckSwiper/index.tsx +0 -90
- package/lib/components/DonutCountdown/index.tsx +0 -86
- package/lib/components/DonutCountdown/style.ts +0 -8
- package/lib/components/FloatingContainer/index.tsx +0 -35
- package/lib/components/Footer/index.tsx +0 -35
- package/lib/components/Header/index.tsx +0 -21
- package/lib/components/ImageResponsive/index.tsx +0 -24
- package/lib/components/ImageResponsive/style.ts +0 -9
- package/lib/components/ImageViewer/index.tsx +0 -36
- package/lib/components/MenuItem/index.tsx +0 -25
- package/lib/components/Notification/index.tsx +0 -44
- package/lib/components/PreventDoubleClick/index.tsx +0 -28
- package/lib/components/Select/index.tsx +0 -51
- package/lib/components/Select/style.ts +0 -64
- package/lib/components/Switch/index.tsx +0 -30
- package/lib/components/TakePicture/index.tsx +0 -148
- package/lib/components/Text/index.tsx +0 -33
- package/lib/components/TimeOutButton/index.tsx +0 -67
- package/lib/components/Toast/index.tsx +0 -34
- package/lib/components/Toast/style.ts +0 -12
- package/lib/components/UploadDocument/index.tsx +0 -179
- package/lib/components/VirtualKeyboard/index.tsx +0 -75
- package/lib/components/index.ts +0 -29
- package/lib/configs/constants.ts +0 -273
- package/lib/configs/types.ts +0 -326
- package/lib/hooks/index.ts +0 -2
- package/lib/hooks/useLoadFonts.tsx +0 -13
|
@@ -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,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,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;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
|
|
2
|
-
import { Dimensions, TouchableOpacity, View } from 'react-native';
|
|
3
|
-
|
|
4
|
-
import style from './style';
|
|
5
|
-
|
|
6
|
-
import type { TimeOutButtonProps } from '../../configs/types';
|
|
7
|
-
|
|
8
|
-
const { width } = Dimensions.get('window');
|
|
9
|
-
const BUTTON_WIDTH = width * 0.6;
|
|
10
|
-
|
|
11
|
-
const TimeOutButton = forwardRef(({ onPress, time = 3000, warning, children }: TimeOutButtonProps, ref) => {
|
|
12
|
-
const [elapsedTime, setElapsedTime] = useState<number>(0);
|
|
13
|
-
const [interval, setLocalInterval] = useState<NodeJS.Timeout | undefined>(undefined);
|
|
14
|
-
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
let isCancelled = false;
|
|
17
|
-
const timer = setInterval(() => {
|
|
18
|
-
if (!isCancelled) {
|
|
19
|
-
setElapsedTime((prevElapsedTime) => prevElapsedTime + 1);
|
|
20
|
-
}
|
|
21
|
-
}, 1);
|
|
22
|
-
setLocalInterval(timer);
|
|
23
|
-
|
|
24
|
-
return () => {
|
|
25
|
-
clearInterval(timer);
|
|
26
|
-
isCancelled = true;
|
|
27
|
-
};
|
|
28
|
-
}, []);
|
|
29
|
-
|
|
30
|
-
useImperativeHandle(ref, () => ({
|
|
31
|
-
onStop() {
|
|
32
|
-
clearInterval(interval);
|
|
33
|
-
},
|
|
34
|
-
}));
|
|
35
|
-
|
|
36
|
-
const watchInterval = () => {
|
|
37
|
-
if (elapsedTime >= time) {
|
|
38
|
-
clearInterval(interval);
|
|
39
|
-
if (onPress) onPress();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return elapsedTime <= time ? (BUTTON_WIDTH * (time - elapsedTime)) / time : BUTTON_WIDTH;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const checkWarningPercent = () => (elapsedTime <= time ? time * 0.3 > time - elapsedTime : false);
|
|
46
|
-
|
|
47
|
-
const onLocalPress = () => {
|
|
48
|
-
setElapsedTime(time);
|
|
49
|
-
clearInterval(interval);
|
|
50
|
-
if (onPress) onPress();
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<TouchableOpacity style={[style.button, style.buttonBg]} onPress={onLocalPress}>
|
|
55
|
-
<View
|
|
56
|
-
style={[
|
|
57
|
-
style.button,
|
|
58
|
-
warning ? (checkWarningPercent() ? style.buttonOverlayWarning : style.buttonOverlay) : style.buttonOverlay,
|
|
59
|
-
{ width: watchInterval() },
|
|
60
|
-
]}
|
|
61
|
-
/>
|
|
62
|
-
{children}
|
|
63
|
-
</TouchableOpacity>
|
|
64
|
-
);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
export default TimeOutButton;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Ionicons } from '@expo/vector-icons';
|
|
2
|
-
import { toast, Toaster } from 'sonner-native';
|
|
3
|
-
|
|
4
|
-
import { Colors } from '../../configs/constants';
|
|
5
|
-
import style from './style';
|
|
6
|
-
|
|
7
|
-
import type { ToastMessageProps } from '../../configs/types';
|
|
8
|
-
|
|
9
|
-
const Toast = () => (
|
|
10
|
-
<Toaster
|
|
11
|
-
autoWiggleOnUpdate="toast-change"
|
|
12
|
-
closeButton
|
|
13
|
-
duration={3000}
|
|
14
|
-
icons={{
|
|
15
|
-
error: <Ionicons name="alert-circle-outline" color={Colors.darkred} size={30} />,
|
|
16
|
-
success: <Ionicons name="checkmark-circle-outline" color={Colors.darkgreen} size={30} />,
|
|
17
|
-
}}
|
|
18
|
-
pauseWhenPageIsHidden
|
|
19
|
-
position="top-center"
|
|
20
|
-
richColors
|
|
21
|
-
swipeToDismissDirection="up"
|
|
22
|
-
visibleToasts={4}
|
|
23
|
-
toastOptions={{
|
|
24
|
-
titleStyle: style.titleStyle,
|
|
25
|
-
descriptionStyle: style.descriptionStyle,
|
|
26
|
-
}}
|
|
27
|
-
/>
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
export const sendMessage = ({ variant, message, description }: ToastMessageProps) => {
|
|
31
|
-
toast[variant](message, { description });
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export default Toast;
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import * as ExpoImagePicker from 'expo-image-picker';
|
|
2
|
-
import * as MediaLibrary from 'expo-media-library';
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
4
|
-
import { ActivityIndicator, Platform, TouchableOpacity, View } from 'react-native';
|
|
5
|
-
|
|
6
|
-
import { Colors } from '../../configs/constants';
|
|
7
|
-
import Button from '../Button';
|
|
8
|
-
import ConfirmationModal from '../ConfirmationModal';
|
|
9
|
-
import ImagePicker from '../ImagePicker';
|
|
10
|
-
import ImageViewer from '../ImageViewer';
|
|
11
|
-
import TakePicture from '../TakePicture';
|
|
12
|
-
import Text from '../Text';
|
|
13
|
-
import style from './style';
|
|
14
|
-
|
|
15
|
-
import type { UploadDocumentProps } from '../../configs/types';
|
|
16
|
-
|
|
17
|
-
const iOS = Platform.OS === 'ios';
|
|
18
|
-
|
|
19
|
-
const UploadDocument = ({
|
|
20
|
-
title,
|
|
21
|
-
description,
|
|
22
|
-
icon,
|
|
23
|
-
completed,
|
|
24
|
-
isAvatarPicker,
|
|
25
|
-
uploadButtonText,
|
|
26
|
-
reUploadButtonText,
|
|
27
|
-
mediaModal,
|
|
28
|
-
takePicture,
|
|
29
|
-
inverted,
|
|
30
|
-
onSelectImage,
|
|
31
|
-
file,
|
|
32
|
-
onPermissionDenied,
|
|
33
|
-
}: UploadDocumentProps) => {
|
|
34
|
-
const [showMediaModal, setShowMediaModal] = useState<boolean>(false);
|
|
35
|
-
const [showCamera, setShowCamera] = useState<boolean>(false);
|
|
36
|
-
const [image, setImage] = useState<string | { uri: string }>();
|
|
37
|
-
const [loading, setLoading] = useState<boolean>(true);
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
(async () => {
|
|
41
|
-
if (iOS) {
|
|
42
|
-
await MediaLibrary.requestPermissionsAsync();
|
|
43
|
-
} else {
|
|
44
|
-
await ExpoImagePicker.getMediaLibraryPermissionsAsync();
|
|
45
|
-
}
|
|
46
|
-
})();
|
|
47
|
-
}, []);
|
|
48
|
-
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
if (!image) {
|
|
51
|
-
setImage(file);
|
|
52
|
-
}
|
|
53
|
-
}, [file, image]);
|
|
54
|
-
|
|
55
|
-
interface PickUploadMethodParams {
|
|
56
|
-
method: 'camera' | 'gallery' | string;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
interface GalleryPermissionResult {
|
|
60
|
-
status: string;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const pickUploadMethod = async (method: PickUploadMethodParams['method']): Promise<void> => {
|
|
64
|
-
setShowMediaModal(false);
|
|
65
|
-
|
|
66
|
-
switch (method) {
|
|
67
|
-
case 'camera':
|
|
68
|
-
setTimeout(async () => {
|
|
69
|
-
setShowCamera(true);
|
|
70
|
-
}, 500);
|
|
71
|
-
break;
|
|
72
|
-
case 'gallery':
|
|
73
|
-
setTimeout(async () => {
|
|
74
|
-
const { status: galleryStatus }: GalleryPermissionResult = iOS
|
|
75
|
-
? await MediaLibrary.requestPermissionsAsync()
|
|
76
|
-
: await ExpoImagePicker.getMediaLibraryPermissionsAsync();
|
|
77
|
-
|
|
78
|
-
if (galleryStatus !== 'granted' && iOS) {
|
|
79
|
-
if (onPermissionDenied) {
|
|
80
|
-
onPermissionDenied();
|
|
81
|
-
}
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const pickedImage = await ImagePicker(isAvatarPicker);
|
|
86
|
-
if (pickedImage !== undefined) {
|
|
87
|
-
selectImage(pickedImage);
|
|
88
|
-
}
|
|
89
|
-
}, 500);
|
|
90
|
-
break;
|
|
91
|
-
default:
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const selectImage = (selectedImage: any) => {
|
|
97
|
-
setImage(selectedImage);
|
|
98
|
-
if (onSelectImage) {
|
|
99
|
-
onSelectImage(selectedImage);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<View style={[style.container, completed ? style.containerCompleted : {}]}>
|
|
105
|
-
{image ? (
|
|
106
|
-
<View style={style.uploadedContainer}>
|
|
107
|
-
<View>
|
|
108
|
-
<ImageViewer
|
|
109
|
-
source={{
|
|
110
|
-
uri: typeof image === 'object' ? image.uri : image,
|
|
111
|
-
}}
|
|
112
|
-
style={style.image}
|
|
113
|
-
resizeMode="cover"
|
|
114
|
-
avatar
|
|
115
|
-
onLoadEnd={() => setLoading(false)}
|
|
116
|
-
/>
|
|
117
|
-
{loading && <ActivityIndicator style={style.imageSpinner} animating={loading} color={Colors.darkblue} />}
|
|
118
|
-
</View>
|
|
119
|
-
<View style={style.reUploadButtons}>
|
|
120
|
-
<Text style={style.titleUploaded} numberOfLines={1} ellipsizeMode="tail">
|
|
121
|
-
{title}
|
|
122
|
-
</Text>
|
|
123
|
-
<TouchableOpacity onPress={() => setShowMediaModal(true)}>
|
|
124
|
-
<Text size="tiny" style={style.reUpload}>
|
|
125
|
-
{reUploadButtonText}
|
|
126
|
-
</Text>
|
|
127
|
-
</TouchableOpacity>
|
|
128
|
-
</View>
|
|
129
|
-
</View>
|
|
130
|
-
) : (
|
|
131
|
-
<View style={style.noUploaded}>
|
|
132
|
-
{icon}
|
|
133
|
-
<Text size="large" style={style.title} numberOfLines={1} ellipsizeMode="tail">
|
|
134
|
-
{title}
|
|
135
|
-
</Text>
|
|
136
|
-
<Text size="small" style={style.description}>
|
|
137
|
-
{description}
|
|
138
|
-
</Text>
|
|
139
|
-
<Button variant={inverted ? 'inverted' : 'primary'} onPress={() => setShowMediaModal(true)}>
|
|
140
|
-
<Text color="white">{uploadButtonText}</Text>
|
|
141
|
-
</Button>
|
|
142
|
-
</View>
|
|
143
|
-
)}
|
|
144
|
-
|
|
145
|
-
<ConfirmationModal
|
|
146
|
-
visible={showMediaModal}
|
|
147
|
-
inverted={inverted}
|
|
148
|
-
title={mediaModal.title}
|
|
149
|
-
onConfirm={() => pickUploadMethod('camera')}
|
|
150
|
-
confirmText={mediaModal.confirmText}
|
|
151
|
-
onCancel={() => pickUploadMethod('gallery')}
|
|
152
|
-
cancelText={mediaModal.cancelText}
|
|
153
|
-
onClose={() => setShowMediaModal(false)}
|
|
154
|
-
>
|
|
155
|
-
<Text>{mediaModal.description}</Text>
|
|
156
|
-
</ConfirmationModal>
|
|
157
|
-
|
|
158
|
-
<TakePicture
|
|
159
|
-
visible={showCamera}
|
|
160
|
-
cameraErrorMessage={takePicture.cameraErrorMessage}
|
|
161
|
-
requestPermissionsMessage={takePicture.requestPermissionsMessage}
|
|
162
|
-
processingPictureMessage={takePicture.processingPictureMessage}
|
|
163
|
-
repeatPictureText={takePicture.repeatPictureText}
|
|
164
|
-
usePictureText={takePicture.usePictureText}
|
|
165
|
-
avatar={isAvatarPicker}
|
|
166
|
-
onClose={(selectedImage) => {
|
|
167
|
-
if (selectedImage) {
|
|
168
|
-
selectImage(selectedImage);
|
|
169
|
-
}
|
|
170
|
-
setTimeout(() => {
|
|
171
|
-
setShowCamera(false);
|
|
172
|
-
}, 0);
|
|
173
|
-
}}
|
|
174
|
-
/>
|
|
175
|
-
</View>
|
|
176
|
-
);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
export default UploadDocument;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Ionicons } from '@expo/vector-icons';
|
|
2
|
-
import { TouchableOpacity, View } from 'react-native';
|
|
3
|
-
|
|
4
|
-
import Text from '../Text';
|
|
5
|
-
import style from './style';
|
|
6
|
-
|
|
7
|
-
import type { VirtualKeyboardProps } from '../../configs/types';
|
|
8
|
-
|
|
9
|
-
const keys = [
|
|
10
|
-
{
|
|
11
|
-
key: <Text size="extra-large">1</Text>,
|
|
12
|
-
value: 1,
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
key: <Text size="extra-large">2</Text>,
|
|
16
|
-
value: 2,
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
key: <Text size="extra-large">3</Text>,
|
|
20
|
-
value: 3,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
key: <Text size="extra-large">4</Text>,
|
|
24
|
-
value: 4,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
key: <Text size="extra-large">5</Text>,
|
|
28
|
-
value: 5,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
key: <Text size="extra-large">6</Text>,
|
|
32
|
-
value: 6,
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
key: <Text size="extra-large">7</Text>,
|
|
36
|
-
value: 7,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
key: <Text size="extra-large">8</Text>,
|
|
40
|
-
value: 8,
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
key: <Text size="extra-large">9</Text>,
|
|
44
|
-
value: 9,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
key: <Ionicons name="finger-print-outline" style={style.icon} />,
|
|
48
|
-
value: 'biometrics',
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
key: <Text size="extra-large">0</Text>,
|
|
52
|
-
value: 0,
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
key: <Ionicons name="backspace-outline" style={style.icon} />,
|
|
56
|
-
value: 'back',
|
|
57
|
-
},
|
|
58
|
-
];
|
|
59
|
-
|
|
60
|
-
const VirtualKeyboard = ({ onPress, hideBiometrics }: VirtualKeyboardProps) => (
|
|
61
|
-
<View style={style.container}>
|
|
62
|
-
{keys.map(({ key, value }) => (
|
|
63
|
-
<TouchableOpacity
|
|
64
|
-
key={`key-${value}`}
|
|
65
|
-
style={style.button}
|
|
66
|
-
onPress={() => onPress(value === 'biometrics' && hideBiometrics ? null : value)}
|
|
67
|
-
disabled={value === 'biometrics' && hideBiometrics}
|
|
68
|
-
>
|
|
69
|
-
{value === 'biometrics' && hideBiometrics ? <Text> </Text> : key}
|
|
70
|
-
</TouchableOpacity>
|
|
71
|
-
))}
|
|
72
|
-
</View>
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
export default VirtualKeyboard;
|
package/lib/components/index.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export { default as Button } from './Button';
|
|
2
|
-
export { default as Card } from './Card';
|
|
3
|
-
export { default as ConfirmationModal } from './ConfirmationModal';
|
|
4
|
-
export { default as Container } from './Container';
|
|
5
|
-
export { default as CustomChatView } from './CustomChatView';
|
|
6
|
-
export { default as DeckSwiper } from './DeckSwiper';
|
|
7
|
-
export { default as DonutCountdown } from './DonutCountdown';
|
|
8
|
-
export { default as FloatingContainer } from './FloatingContainer';
|
|
9
|
-
export { default as Footer } from './Footer';
|
|
10
|
-
export { default as Header } from './Header';
|
|
11
|
-
export { default as ImagePicker } from './ImagePicker';
|
|
12
|
-
export { default as ImageResponsive } from './ImageResponsive';
|
|
13
|
-
export { default as ImageViewer } from './ImageViewer';
|
|
14
|
-
export { default as Input } from './Input';
|
|
15
|
-
export { default as InputPin } from './InputPin';
|
|
16
|
-
export { default as MenuItem } from './MenuItem';
|
|
17
|
-
export { default as NavigationTitle } from './NavigationTitle';
|
|
18
|
-
export { default as Notification } from './Notification';
|
|
19
|
-
export { default as withPreventDoubleClick } from './PreventDoubleClick';
|
|
20
|
-
export { default as Select } from './Select';
|
|
21
|
-
export { default as SwipeablePanel } from './SwipeablePanel';
|
|
22
|
-
export { default as Switch } from './Switch';
|
|
23
|
-
export { default as TakePicture } from './TakePicture';
|
|
24
|
-
export { default as Text } from './Text';
|
|
25
|
-
export { default as Textarea } from './Textarea';
|
|
26
|
-
export { default as TimeOutButton } from './TimeOutButton';
|
|
27
|
-
export { sendMessage, default as Toast } from './Toast';
|
|
28
|
-
export { default as UploadDocument } from './UploadDocument';
|
|
29
|
-
export { default as VirtualKeyboard } from './VirtualKeyboard';
|