@holper/react-native-holper-storybook 0.6.102 → 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/LICENSE +21 -0
- package/{readme.md → README.md} +19 -20
- package/index.js +3 -2
- package/lib/components/Button/index.tsx +66 -0
- package/lib/components/Button/{style.js → style.ts} +8 -7
- package/lib/components/Card/index.tsx +33 -0
- package/lib/components/Card/{style.js → style.ts} +5 -4
- package/lib/components/ConfirmationModal/{index.js → index.tsx} +25 -79
- package/lib/components/ConfirmationModal/{style.js → style.tsx} +14 -13
- package/lib/components/Container/{index.js → index.tsx} +7 -28
- package/lib/components/Container/{style.js → style.ts} +6 -5
- package/lib/components/CustomChatView/{index.js → index.tsx} +22 -30
- package/lib/components/CustomChatView/{style.js → style.ts} +1 -1
- package/lib/components/DeckSwiper/index.tsx +90 -0
- package/lib/components/DeckSwiper/{style.js → style.ts} +13 -12
- package/lib/components/DonutCountdown/index.tsx +86 -0
- package/lib/components/DonutCountdown/style.ts +8 -0
- package/lib/components/FloatingContainer/index.tsx +35 -0
- package/lib/components/FloatingContainer/{style.js → style.ts} +7 -6
- package/lib/components/Footer/index.tsx +35 -0
- package/lib/components/Footer/{style.js → style.ts} +4 -3
- package/lib/components/Header/index.tsx +21 -0
- package/lib/components/Header/{style.js → style.ts} +4 -3
- package/lib/components/ImagePicker/{index.js → index.tsx} +3 -12
- package/lib/components/ImageResponsive/index.tsx +24 -0
- package/lib/components/ImageResponsive/style.ts +9 -0
- package/lib/components/ImageViewer/index.tsx +36 -0
- package/lib/components/ImageViewer/{style.js → style.ts} +4 -3
- package/lib/components/Input/{index.js → index.tsx} +6 -33
- package/lib/components/Input/{style.js → style.ts} +7 -18
- package/lib/components/InputPin/{index.js → index.tsx} +6 -13
- package/lib/components/InputPin/{style.js → style.ts} +7 -6
- package/lib/components/MenuItem/index.tsx +25 -0
- package/lib/components/MenuItem/{style.js → style.ts} +9 -7
- package/lib/components/NavigationTitle/{index.js → index.tsx} +9 -30
- package/lib/components/NavigationTitle/{style.js → style.ts} +12 -11
- package/lib/components/Notification/index.tsx +44 -0
- package/lib/components/Notification/{style.js → style.ts} +13 -11
- package/lib/components/PreventDoubleClick/index.tsx +28 -0
- package/lib/components/Select/index.tsx +51 -0
- package/lib/components/Select/style.ts +64 -0
- package/lib/components/SwipeablePanel/{index.js → index.tsx} +58 -85
- package/lib/components/SwipeablePanel/{style.js → style.ts} +15 -14
- package/lib/components/Switch/index.tsx +30 -0
- package/lib/components/TakePicture/{confirmPictureModal.js → confirmPictureModal.tsx} +9 -33
- package/lib/components/TakePicture/index.tsx +148 -0
- package/lib/components/TakePicture/{style.js → style.ts} +4 -4
- package/lib/components/Text/index.tsx +33 -0
- package/lib/components/Text/{style.js → style.ts} +4 -2
- package/lib/components/Textarea/{index.js → index.tsx} +5 -24
- package/lib/components/Textarea/{style.js → style.ts} +5 -4
- package/lib/components/TimeOutButton/index.tsx +67 -0
- package/lib/components/TimeOutButton/{style.js → style.ts} +4 -3
- package/lib/components/Toast/index.tsx +34 -0
- package/lib/components/Toast/style.ts +12 -0
- package/lib/components/UploadDocument/{index.js → index.tsx} +49 -105
- package/lib/components/UploadDocument/{style.js → style.ts} +16 -15
- package/lib/components/VirtualKeyboard/index.tsx +75 -0
- package/lib/components/VirtualKeyboard/{style.js → style.ts} +9 -8
- package/lib/components/index.ts +29 -0
- package/lib/configs/{constants.js → constants.ts} +50 -48
- package/lib/configs/types.ts +326 -0
- package/lib/hooks/index.ts +2 -0
- package/lib/hooks/{useDebounce.js → useDebounce.tsx} +6 -4
- package/lib/hooks/useLoadFonts.tsx +13 -0
- package/lib/index.js +3 -2
- package/package.json +72 -59
- package/lib/components/Button/index.js +0 -104
- package/lib/components/Card/index.js +0 -49
- package/lib/components/DeckSwiper/index.js +0 -118
- package/lib/components/FlashMessage/index.js +0 -81
- package/lib/components/FloatingContainer/index.js +0 -69
- package/lib/components/Footer/index.js +0 -61
- package/lib/components/Header/index.js +0 -45
- package/lib/components/ImageResponsive/index.js +0 -39
- package/lib/components/ImageResponsive/style.js +0 -7
- package/lib/components/ImageViewer/index.js +0 -62
- package/lib/components/MenuItem/index.js +0 -44
- package/lib/components/Notification/index.js +0 -80
- package/lib/components/PreventDoubleClick/index.js +0 -21
- package/lib/components/Select/index.js +0 -89
- package/lib/components/Select/style.js +0 -81
- package/lib/components/Switch/index.js +0 -57
- package/lib/components/TakePicture/index.js +0 -198
- package/lib/components/Text/index.js +0 -75
- package/lib/components/TimeOutButton/index.js +0 -104
- package/lib/components/VirtualKeyboard/index.js +0 -86
- package/lib/components/index.js +0 -28
- package/lib/configs/loadFonts.js +0 -11
- package/lib/hooks/index.js +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Chromatic
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/{readme.md → README.md}
RENAMED
|
@@ -8,31 +8,29 @@ To: `"main": "lib/index.js",`
|
|
|
8
8
|
|
|
9
9
|
And revert the change after publish.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
11
|
#### Publish the library for npm
|
|
14
12
|
|
|
15
13
|
Run the command: `npm publish` this will build the lib before publishing.
|
|
16
14
|
|
|
17
15
|
#### How to set up
|
|
18
|
-
|
|
16
|
+
|
|
17
|
+
`import { useLoadFonts } from from 'react-native-holper-storybook';` and call the `useLoadFonts` function in your app entry point.
|
|
19
18
|
|
|
20
19
|
```
|
|
21
|
-
import
|
|
22
|
-
import {
|
|
20
|
+
import { useEffect, useState } from 'react';
|
|
21
|
+
import { useLoadFonts } from 'react-native-holper-storybook';
|
|
23
22
|
|
|
24
23
|
export default function App() {
|
|
25
|
-
const
|
|
24
|
+
const { loaded, error } = useLoadFonts();
|
|
26
25
|
|
|
27
26
|
useEffect(() => {
|
|
28
|
-
(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return <View/>;
|
|
27
|
+
if (loaded || error) {
|
|
28
|
+
SplashScreen.hideAsync();
|
|
29
|
+
}
|
|
30
|
+
}, [loaded, error]);
|
|
31
|
+
|
|
32
|
+
if (!loaded && !error) {
|
|
33
|
+
return null;
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
return (
|
|
@@ -41,25 +39,26 @@ export default function App() {
|
|
|
41
39
|
}
|
|
42
40
|
```
|
|
43
41
|
|
|
44
|
-
#### Using
|
|
45
|
-
|
|
42
|
+
#### Using Toast
|
|
43
|
+
|
|
44
|
+
This library uses https://github.com/gunnartorfis/sonner-native, in order to use it, include `<Toaster />` in you root component.
|
|
46
45
|
|
|
47
46
|
```
|
|
48
47
|
import React from 'react';
|
|
49
48
|
import { View } from 'react-native';
|
|
50
|
-
import {
|
|
49
|
+
import { Toaster } from 'react-native-holper-storybook';
|
|
51
50
|
|
|
52
51
|
export default function App() {
|
|
53
52
|
return (
|
|
54
53
|
<View>
|
|
55
54
|
...
|
|
56
|
-
<
|
|
55
|
+
<Toaster />
|
|
57
56
|
</View>
|
|
58
57
|
);
|
|
59
58
|
}
|
|
60
59
|
```
|
|
61
60
|
|
|
62
|
-
|
|
61
|
+
#### Sending a messages
|
|
63
62
|
|
|
64
63
|
```
|
|
65
64
|
import React from 'react';
|
|
@@ -79,4 +78,4 @@ export default MyComponent = () => {
|
|
|
79
78
|
</View>
|
|
80
79
|
);
|
|
81
80
|
}
|
|
82
|
-
```
|
|
81
|
+
```
|
package/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export {asyncLoadFont} from './configs/loadFonts';
|
|
2
|
-
export {Colors, MapStyle, ConstantsWS, HiringStatus, CouponStatus, NotificationsTypes} from './configs/constants';
|
|
3
1
|
export * from './components';
|
|
2
|
+
export { Colors, ConstantsWS, CouponStatus, HiringStatus, MapStyle, NotificationsTypes } from './configs/constants';
|
|
3
|
+
export * from './configs/types';
|
|
4
|
+
export { useDebounce, useLoadFonts } from './hooks';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { ActivityIndicator, TouchableOpacity } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { Colors } from '../../configs/constants';
|
|
5
|
+
import withPreventDoubleClick from './../PreventDoubleClick';
|
|
6
|
+
import style from './style';
|
|
7
|
+
|
|
8
|
+
import type { ButtonProps } from '../../configs/types';
|
|
9
|
+
|
|
10
|
+
const Button = ({
|
|
11
|
+
onPress,
|
|
12
|
+
disabled,
|
|
13
|
+
isLoading,
|
|
14
|
+
bordered,
|
|
15
|
+
variant = 'primary',
|
|
16
|
+
size = 'medium',
|
|
17
|
+
noShadow,
|
|
18
|
+
style: customStyle,
|
|
19
|
+
debounceDelay = 0,
|
|
20
|
+
children,
|
|
21
|
+
}: ButtonProps) => {
|
|
22
|
+
const [isDisabled, setIsDisabled] = useState<boolean>(disabled || false);
|
|
23
|
+
|
|
24
|
+
useEffect(() => setIsDisabled(disabled || false), [disabled]);
|
|
25
|
+
|
|
26
|
+
const getSpinnerColor = () => {
|
|
27
|
+
switch (variant) {
|
|
28
|
+
case 'primary':
|
|
29
|
+
case 'inverted':
|
|
30
|
+
case 'error':
|
|
31
|
+
return Colors.white;
|
|
32
|
+
default:
|
|
33
|
+
return Colors.darkblue;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const handleTap = () => {
|
|
38
|
+
if (onPress) {
|
|
39
|
+
onPress();
|
|
40
|
+
}
|
|
41
|
+
setIsDisabled(true);
|
|
42
|
+
setTimeout(() => {
|
|
43
|
+
setIsDisabled(false);
|
|
44
|
+
}, debounceDelay);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<TouchableOpacity
|
|
49
|
+
style={[
|
|
50
|
+
style.button,
|
|
51
|
+
style[variant],
|
|
52
|
+
style[size],
|
|
53
|
+
bordered ? style.bordered : {},
|
|
54
|
+
isDisabled ? style.disabled : {},
|
|
55
|
+
noShadow ? style.noShadow : {},
|
|
56
|
+
customStyle,
|
|
57
|
+
]}
|
|
58
|
+
disabled={isLoading || isDisabled}
|
|
59
|
+
onPress={handleTap}
|
|
60
|
+
>
|
|
61
|
+
{isLoading ? <ActivityIndicator color={getSpinnerColor()} size={28} /> : children}
|
|
62
|
+
</TouchableOpacity>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default withPreventDoubleClick(Button);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Dimensions } from 'react-native';
|
|
2
|
-
|
|
1
|
+
import { Dimensions, StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { borderRadius, Colors } from '../../configs/constants';
|
|
3
4
|
|
|
4
5
|
const { width } = Dimensions.get('window');
|
|
5
6
|
|
|
6
|
-
export default {
|
|
7
|
+
export default StyleSheet.create({
|
|
7
8
|
// Default button shape
|
|
8
9
|
button: {
|
|
9
10
|
height: 50,
|
|
@@ -37,9 +38,9 @@ export default {
|
|
|
37
38
|
shadowColor: Colors.dimgray,
|
|
38
39
|
},
|
|
39
40
|
light: {
|
|
40
|
-
borderColor: Colors.
|
|
41
|
-
backgroundColor: Colors.
|
|
42
|
-
shadowColor: Colors.
|
|
41
|
+
borderColor: Colors.gray,
|
|
42
|
+
backgroundColor: Colors.gray,
|
|
43
|
+
shadowColor: Colors.gray,
|
|
43
44
|
},
|
|
44
45
|
brightblue: {
|
|
45
46
|
borderColor: Colors.brightblue,
|
|
@@ -107,4 +108,4 @@ export default {
|
|
|
107
108
|
shadowColor: Colors.transparent,
|
|
108
109
|
elevation: 0,
|
|
109
110
|
},
|
|
110
|
-
};
|
|
111
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { TouchableOpacityProps, ViewProps } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import withPreventDoubleClick from '../PreventDoubleClick';
|
|
6
|
+
import style from './style';
|
|
7
|
+
|
|
8
|
+
import type { CardProps } from '../../configs/types';
|
|
9
|
+
|
|
10
|
+
const TappedTouchableOpacity = withPreventDoubleClick(TouchableOpacity);
|
|
11
|
+
|
|
12
|
+
const Card = (
|
|
13
|
+
{ children, isButton, onPress, noShadow, style: customStyle }: CardProps,
|
|
14
|
+
...props: (TouchableOpacityProps & ViewProps)[]
|
|
15
|
+
) => (
|
|
16
|
+
<>
|
|
17
|
+
{isButton ? (
|
|
18
|
+
<TappedTouchableOpacity
|
|
19
|
+
onPress={onPress}
|
|
20
|
+
style={[style.card, customStyle, noShadow ? style.noShadow : {}]}
|
|
21
|
+
{...props}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
</TappedTouchableOpacity>
|
|
25
|
+
) : (
|
|
26
|
+
<View style={[style.card, customStyle, noShadow ? style.noShadow : {}]} {...props}>
|
|
27
|
+
{children}
|
|
28
|
+
</View>
|
|
29
|
+
)}
|
|
30
|
+
</>
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
export default Card;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Dimensions, Platform } from 'react-native';
|
|
2
|
-
|
|
1
|
+
import { Dimensions, Platform, StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { borderRadius, Colors } from '../../configs/constants';
|
|
3
4
|
|
|
4
5
|
const { width } = Dimensions.get('window');
|
|
5
6
|
const isAndroid = Platform.OS === 'android';
|
|
6
7
|
|
|
7
|
-
export default {
|
|
8
|
+
export default StyleSheet.create({
|
|
8
9
|
card: {
|
|
9
10
|
margin: 8,
|
|
10
11
|
minHeight: 50,
|
|
@@ -30,4 +31,4 @@ export default {
|
|
|
30
31
|
elevation: 0,
|
|
31
32
|
borderColor: Colors.lightblue,
|
|
32
33
|
},
|
|
33
|
-
};
|
|
34
|
+
});
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Ionicons } from '@expo/vector-icons';
|
|
2
2
|
import {
|
|
3
|
+
Keyboard,
|
|
4
|
+
KeyboardAvoidingView,
|
|
3
5
|
Modal,
|
|
6
|
+
Platform,
|
|
4
7
|
TouchableOpacity,
|
|
5
|
-
View,
|
|
6
|
-
Keyboard,
|
|
7
8
|
TouchableWithoutFeedback,
|
|
8
|
-
|
|
9
|
-
KeyboardAvoidingView,
|
|
9
|
+
View,
|
|
10
10
|
} from 'react-native';
|
|
11
|
-
|
|
12
|
-
import Ionicons from 'react-native-vector-icons/Ionicons';
|
|
13
|
-
import Text from '../Text';
|
|
14
|
-
import Button from '../Button';
|
|
11
|
+
|
|
15
12
|
import { Colors } from '../../configs/constants';
|
|
13
|
+
import Button from '../Button';
|
|
14
|
+
import Text from '../Text';
|
|
16
15
|
import style from './style';
|
|
17
16
|
|
|
17
|
+
import type { ConfirmationModalProps } from '../../configs/types';
|
|
18
|
+
|
|
18
19
|
const ConfirmationModal = ({
|
|
19
20
|
visible,
|
|
20
21
|
title,
|
|
@@ -29,25 +30,18 @@ const ConfirmationModal = ({
|
|
|
29
30
|
inverted,
|
|
30
31
|
isPrime,
|
|
31
32
|
children,
|
|
32
|
-
}) => (
|
|
33
|
-
<Modal
|
|
34
|
-
|
|
35
|
-
transparent={true}
|
|
36
|
-
visible={visible}
|
|
37
|
-
onRequestClose={() => {}}
|
|
38
|
-
>
|
|
39
|
-
<KeyboardAvoidingView
|
|
40
|
-
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
41
|
-
>
|
|
33
|
+
}: ConfirmationModalProps) => (
|
|
34
|
+
<Modal animationType="slide" transparent visible={visible} onRequestClose={() => {}}>
|
|
35
|
+
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'}>
|
|
42
36
|
<TouchableWithoutFeedback onPress={() => Keyboard.dismiss()}>
|
|
43
37
|
<View style={style.container}>
|
|
44
38
|
<View style={style.content}>
|
|
45
39
|
<View style={alertMode && !closeButton ? {} : style.title}>
|
|
46
40
|
<Text
|
|
47
41
|
style={alertMode && !closeButton ? {} : style.titleText}
|
|
48
|
-
size=
|
|
42
|
+
size="large"
|
|
49
43
|
align={alertMode && !closeButton ? 'center' : 'left'}
|
|
50
|
-
weight=
|
|
44
|
+
weight="semiBold"
|
|
51
45
|
numberOfLines={1}
|
|
52
46
|
>
|
|
53
47
|
{title}
|
|
@@ -58,46 +52,33 @@ const ConfirmationModal = ({
|
|
|
58
52
|
if (onClose) {
|
|
59
53
|
onClose();
|
|
60
54
|
} else {
|
|
61
|
-
onCancel
|
|
55
|
+
if (onCancel) {
|
|
56
|
+
onCancel();
|
|
57
|
+
}
|
|
62
58
|
}
|
|
63
59
|
}}
|
|
64
60
|
style={style.button}
|
|
65
61
|
>
|
|
66
|
-
<Ionicons
|
|
67
|
-
name='close-outline'
|
|
68
|
-
size={24}
|
|
69
|
-
color={Colors.darkblue}
|
|
70
|
-
/>
|
|
62
|
+
<Ionicons name="close-outline" size={24} color={Colors.darkblue} />
|
|
71
63
|
</TouchableOpacity>
|
|
72
64
|
)}
|
|
73
65
|
</View>
|
|
74
66
|
|
|
75
|
-
<View style={infoMode ? style.bodyInfo : style.body}>
|
|
76
|
-
{children}
|
|
77
|
-
</View>
|
|
67
|
+
<View style={infoMode ? style.bodyInfo : style.body}>{children}</View>
|
|
78
68
|
|
|
79
69
|
{!infoMode && (
|
|
80
70
|
<>
|
|
81
71
|
{alertMode ? (
|
|
82
|
-
<Button
|
|
83
|
-
size='
|
|
84
|
-
variant={inverted ? 'inverted' : 'primary'}
|
|
85
|
-
onPress={onConfirm}
|
|
86
|
-
>
|
|
87
|
-
<Text size='large' color={isPrime ? 'lightgold' : 'white'}>
|
|
72
|
+
<Button size="fit" variant={inverted ? 'inverted' : 'primary'} onPress={onConfirm}>
|
|
73
|
+
<Text size="large" color={isPrime ? 'lightgold' : 'white'}>
|
|
88
74
|
{confirmText}
|
|
89
75
|
</Text>
|
|
90
76
|
</Button>
|
|
91
77
|
) : (
|
|
92
78
|
<View style={style.buttons}>
|
|
93
79
|
{onCancel && (
|
|
94
|
-
<Button
|
|
95
|
-
size=
|
|
96
|
-
bordered
|
|
97
|
-
variant={inverted ? 'inverted' : 'primary'}
|
|
98
|
-
onPress={onCancel}
|
|
99
|
-
>
|
|
100
|
-
<Text size='large'>{cancelText}</Text>
|
|
80
|
+
<Button size="small" bordered variant={inverted ? 'inverted' : 'primary'} onPress={onCancel}>
|
|
81
|
+
<Text size="large">{cancelText}</Text>
|
|
101
82
|
</Button>
|
|
102
83
|
)}
|
|
103
84
|
<Button
|
|
@@ -105,10 +86,7 @@ const ConfirmationModal = ({
|
|
|
105
86
|
size={onCancel ? 'small' : 'fit'}
|
|
106
87
|
onPress={onConfirm}
|
|
107
88
|
>
|
|
108
|
-
<Text
|
|
109
|
-
size='large'
|
|
110
|
-
color={isPrime ? 'lightgold' : 'white'}
|
|
111
|
-
>
|
|
89
|
+
<Text size="large" color={isPrime ? 'lightgold' : 'white'}>
|
|
112
90
|
{confirmText}
|
|
113
91
|
</Text>
|
|
114
92
|
</Button>
|
|
@@ -123,36 +101,4 @@ const ConfirmationModal = ({
|
|
|
123
101
|
</Modal>
|
|
124
102
|
);
|
|
125
103
|
|
|
126
|
-
ConfirmationModal.defaultProps = {
|
|
127
|
-
visible: false,
|
|
128
|
-
title: ' ',
|
|
129
|
-
confirmText: ' ',
|
|
130
|
-
cancelText: ' ',
|
|
131
|
-
onCancel: () => {},
|
|
132
|
-
onConfirm: () => {},
|
|
133
|
-
onClose: null,
|
|
134
|
-
alertMode: false,
|
|
135
|
-
closeButton: false,
|
|
136
|
-
infoMode: false,
|
|
137
|
-
inverted: false,
|
|
138
|
-
isPrime: false,
|
|
139
|
-
children: null,
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
ConfirmationModal.propTypes = {
|
|
143
|
-
visible: PropTypes.bool,
|
|
144
|
-
title: PropTypes.string,
|
|
145
|
-
confirmText: PropTypes.string,
|
|
146
|
-
cancelText: PropTypes.string,
|
|
147
|
-
onCancel: PropTypes.func,
|
|
148
|
-
onConfirm: PropTypes.func,
|
|
149
|
-
onClose: PropTypes.func,
|
|
150
|
-
alertMode: PropTypes.bool,
|
|
151
|
-
closeButton: PropTypes.bool,
|
|
152
|
-
infoMode: PropTypes.bool,
|
|
153
|
-
inverted: PropTypes.bool,
|
|
154
|
-
isPrime: PropTypes.bool,
|
|
155
|
-
children: PropTypes.node,
|
|
156
|
-
};
|
|
157
|
-
|
|
158
104
|
export default ConfirmationModal;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { Dimensions } from 'react-native';
|
|
1
|
+
import { Dimensions, StyleSheet } from 'react-native';
|
|
2
|
+
|
|
2
3
|
import { Colors } from '../../configs/constants';
|
|
3
4
|
|
|
4
5
|
const { width, height } = Dimensions.get('window');
|
|
5
6
|
|
|
6
|
-
export default {
|
|
7
|
+
export default StyleSheet.create({
|
|
7
8
|
container: {
|
|
8
9
|
backgroundColor: 'rgba(0,0,0,0.3)',
|
|
9
10
|
height,
|
|
10
11
|
justifyContent: 'center',
|
|
11
|
-
alignItems: 'center'
|
|
12
|
+
alignItems: 'center',
|
|
12
13
|
},
|
|
13
14
|
content: {
|
|
14
15
|
width: width - 60,
|
|
@@ -16,30 +17,30 @@ export default {
|
|
|
16
17
|
padding: 20,
|
|
17
18
|
borderRadius: 20,
|
|
18
19
|
shadowOffset: { width: 0, height: 4 },
|
|
19
|
-
shadowOpacity:
|
|
20
|
+
shadowOpacity: 0.4,
|
|
20
21
|
shadowRadius: 3,
|
|
21
22
|
elevation: 5,
|
|
22
|
-
shadowColor: Colors.gray
|
|
23
|
+
shadowColor: Colors.gray,
|
|
23
24
|
},
|
|
24
25
|
title: {
|
|
25
26
|
flexDirection: 'row',
|
|
26
27
|
justifyContent: 'space-between',
|
|
27
|
-
alignItems: 'center'
|
|
28
|
+
alignItems: 'center',
|
|
28
29
|
},
|
|
29
30
|
titleText: {
|
|
30
|
-
width: '90%'
|
|
31
|
+
width: '90%',
|
|
31
32
|
},
|
|
32
33
|
body: {
|
|
33
34
|
marginTop: 20,
|
|
34
|
-
marginBottom: 35
|
|
35
|
+
marginBottom: 35,
|
|
35
36
|
},
|
|
36
37
|
bodyInfo: {
|
|
37
|
-
marginTop: 20
|
|
38
|
+
marginTop: 20,
|
|
38
39
|
},
|
|
39
40
|
buttons: {
|
|
40
41
|
flexDirection: 'row',
|
|
41
42
|
justifyContent: 'space-between',
|
|
42
|
-
alignItems: 'center'
|
|
43
|
+
alignItems: 'center',
|
|
43
44
|
},
|
|
44
45
|
button: {
|
|
45
46
|
height: 30,
|
|
@@ -47,6 +48,6 @@ export default {
|
|
|
47
48
|
borderRadius: 15,
|
|
48
49
|
backgroundColor: Colors.lightblue,
|
|
49
50
|
alignItems: 'center',
|
|
50
|
-
justifyContent: 'center'
|
|
51
|
-
}
|
|
52
|
-
};
|
|
51
|
+
justifyContent: 'center',
|
|
52
|
+
},
|
|
53
|
+
});
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
1
|
+
import { Keyboard, ScrollView, TouchableWithoutFeedback, View } from 'react-native';
|
|
3
2
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
4
|
-
|
|
5
|
-
TouchableWithoutFeedback,
|
|
6
|
-
Keyboard,
|
|
7
|
-
ScrollView,
|
|
8
|
-
View,
|
|
9
|
-
} from 'react-native';
|
|
3
|
+
|
|
10
4
|
import style from './style';
|
|
11
5
|
|
|
6
|
+
import type { ContainerProps } from '../../configs/types';
|
|
7
|
+
|
|
12
8
|
const Container = ({
|
|
13
9
|
fullScreen = true,
|
|
14
10
|
enableScroll,
|
|
@@ -16,16 +12,13 @@ const Container = ({
|
|
|
16
12
|
scrollStyle,
|
|
17
13
|
children,
|
|
18
14
|
...props
|
|
19
|
-
}) => (
|
|
20
|
-
<SafeAreaView
|
|
21
|
-
{...props}
|
|
22
|
-
style={[fullScreen ? style.fullScreen : {}, customStyle]}
|
|
23
|
-
>
|
|
15
|
+
}: ContainerProps) => (
|
|
16
|
+
<SafeAreaView {...props} style={[fullScreen ? style.fullScreen : {}, customStyle]}>
|
|
24
17
|
{enableScroll ? (
|
|
25
18
|
<ScrollView
|
|
26
19
|
contentContainerStyle={scrollStyle}
|
|
27
20
|
showsVerticalScrollIndicator={false}
|
|
28
|
-
keyboardDismissMode=
|
|
21
|
+
keyboardDismissMode="on-drag"
|
|
29
22
|
>
|
|
30
23
|
{children}
|
|
31
24
|
</ScrollView>
|
|
@@ -37,18 +30,4 @@ const Container = ({
|
|
|
37
30
|
</SafeAreaView>
|
|
38
31
|
);
|
|
39
32
|
|
|
40
|
-
Container.defaultProps = {
|
|
41
|
-
fullScreen: true,
|
|
42
|
-
enableScroll: false,
|
|
43
|
-
style: {},
|
|
44
|
-
scrollStyle: {},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
Container.propTypes = {
|
|
48
|
-
fullScreen: PropTypes.bool,
|
|
49
|
-
enableScroll: PropTypes.bool,
|
|
50
|
-
style: PropTypes.any,
|
|
51
|
-
scrollStyle: PropTypes.any,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
33
|
export default Container;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Dimensions } from 'react-native';
|
|
1
|
+
import { Dimensions, StyleSheet } from 'react-native';
|
|
2
|
+
|
|
2
3
|
import { Colors } from '../../configs/constants';
|
|
3
4
|
|
|
4
5
|
const { width } = Dimensions.get('window');
|
|
5
6
|
|
|
6
|
-
export default {
|
|
7
|
+
export default StyleSheet.create({
|
|
7
8
|
fullScreen: {
|
|
8
9
|
flex: 1,
|
|
9
10
|
width,
|
|
10
|
-
backgroundColor: Colors.white
|
|
11
|
-
}
|
|
12
|
-
};
|
|
11
|
+
backgroundColor: Colors.white,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -1,43 +1,47 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { Platform, TouchableOpacity, Alert, Linking } from "react-native";
|
|
5
|
-
import { MapStyle } from "../../configs/constants";
|
|
6
|
-
import styles from "./style";
|
|
1
|
+
import { Alert, Linking, Platform, TouchableOpacity } from 'react-native';
|
|
2
|
+
import MapView, { PROVIDER_GOOGLE } from 'react-native-maps';
|
|
7
3
|
|
|
8
|
-
|
|
4
|
+
import { MapStyle } from '../../configs/constants';
|
|
5
|
+
import styles from './style';
|
|
6
|
+
|
|
7
|
+
import type { CustomChatViewProps } from '../../configs/types';
|
|
8
|
+
|
|
9
|
+
const CustomChatView = ({ currentMessage, containerStyle, mapViewStyle }: CustomChatViewProps) => {
|
|
9
10
|
const openMapAsync = async () => {
|
|
10
|
-
const { location
|
|
11
|
+
const { location } = currentMessage || {};
|
|
12
|
+
|
|
13
|
+
if (!location) {
|
|
14
|
+
Alert.alert('Location data is missing.');
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
11
17
|
|
|
12
18
|
const mapScheme = Platform.select({
|
|
13
|
-
ios:
|
|
14
|
-
android:
|
|
19
|
+
ios: 'maps:0,0?q=',
|
|
20
|
+
android: 'geo:0,0?q=',
|
|
15
21
|
});
|
|
16
22
|
const latLng = `${location.latitude},${location.longitude}`;
|
|
17
|
-
const label = `${currentMessage
|
|
23
|
+
const label = `${currentMessage?.user?.name ?? ''}`;
|
|
18
24
|
|
|
19
25
|
const url = Platform.select({
|
|
20
26
|
ios: `${mapScheme}${label}@${latLng}`,
|
|
21
27
|
android: `${mapScheme}${latLng}(${label})`,
|
|
22
|
-
});
|
|
28
|
+
}) as string;
|
|
23
29
|
|
|
24
30
|
try {
|
|
25
31
|
const supported = await Linking.canOpenURL(url);
|
|
26
32
|
if (supported) {
|
|
27
33
|
return Linking.openURL(url);
|
|
28
34
|
}
|
|
29
|
-
Alert.alert(
|
|
35
|
+
Alert.alert('Opening the map is not supported.');
|
|
30
36
|
} catch ({ message }) {
|
|
31
37
|
Alert.alert(message);
|
|
32
38
|
}
|
|
39
|
+
return null;
|
|
33
40
|
};
|
|
34
41
|
|
|
35
|
-
if (currentMessage
|
|
42
|
+
if (currentMessage?.location) {
|
|
36
43
|
return (
|
|
37
|
-
<TouchableOpacity
|
|
38
|
-
style={[styles.container, containerStyle]}
|
|
39
|
-
onPress={openMapAsync}
|
|
40
|
-
>
|
|
44
|
+
<TouchableOpacity style={[styles.container, containerStyle]} onPress={openMapAsync}>
|
|
41
45
|
<MapView
|
|
42
46
|
style={[styles.mapView, mapViewStyle]}
|
|
43
47
|
region={{
|
|
@@ -58,16 +62,4 @@ const CustomChatView = ({ currentMessage, containerStyle, mapViewStyle }) => {
|
|
|
58
62
|
return null;
|
|
59
63
|
};
|
|
60
64
|
|
|
61
|
-
CustomChatView.propTypes = {
|
|
62
|
-
currentMessage: PropTypes.object,
|
|
63
|
-
containerStyle: PropTypes.object,
|
|
64
|
-
mapViewStyle: PropTypes.object,
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
CustomChatView.defaultProps = {
|
|
68
|
-
currentMessage: {},
|
|
69
|
-
containerStyle: {},
|
|
70
|
-
mapViewStyle: {},
|
|
71
|
-
};
|
|
72
|
-
|
|
73
65
|
export default CustomChatView;
|