@holper/react-native-holper-storybook 0.6.89 → 0.6.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,22 +1,44 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import Ionicons from 'react-native-vector-icons/Ionicons';
|
|
4
|
-
import RNFlashMessage, {
|
|
5
|
+
import RNFlashMessage, {
|
|
6
|
+
showMessage,
|
|
7
|
+
renderFlashMessageIcon,
|
|
8
|
+
} from 'react-native-flash-message';
|
|
5
9
|
import { Colors } from '../../configs/constants';
|
|
6
10
|
|
|
7
|
-
export const customRenderFlashMessageIcon = (
|
|
8
|
-
|
|
11
|
+
export const customRenderFlashMessageIcon = (
|
|
12
|
+
icon = 'success',
|
|
13
|
+
style = {},
|
|
14
|
+
customProps = {}
|
|
15
|
+
) => {
|
|
16
|
+
switch (icon) {
|
|
9
17
|
case 'success':
|
|
10
|
-
return
|
|
18
|
+
return (
|
|
19
|
+
<Ionicons
|
|
20
|
+
name='checkmark-circle-outline'
|
|
21
|
+
color={Colors.darkblue}
|
|
22
|
+
size={30}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
11
25
|
case 'error':
|
|
12
|
-
return
|
|
26
|
+
return (
|
|
27
|
+
<Ionicons
|
|
28
|
+
name='alert-circle-outline'
|
|
29
|
+
color={Colors.darkblue}
|
|
30
|
+
size={30}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
13
33
|
}
|
|
14
34
|
|
|
15
35
|
// it's good to inherit the original method...
|
|
16
36
|
return renderFlashMessageIcon(icon, style, customProps);
|
|
17
37
|
};
|
|
18
38
|
|
|
19
|
-
|
|
39
|
+
const statusBarHeight = Platform.OS === 'android' ? { statusBarHeight: 5 } : {};
|
|
40
|
+
|
|
41
|
+
export const sendMessage = ({ variant, message, description }) => {
|
|
20
42
|
return showMessage({
|
|
21
43
|
position: 'top',
|
|
22
44
|
message,
|
|
@@ -25,8 +47,8 @@ export const sendMessage = ({variant, message, description}) => {
|
|
|
25
47
|
type: variant,
|
|
26
48
|
backgroundColor: variant === 'success' ? Colors.green : Colors.lightred,
|
|
27
49
|
color: Colors.darkblue,
|
|
28
|
-
|
|
29
|
-
|
|
50
|
+
hideOnPress: true,
|
|
51
|
+
...statusBarHeight,
|
|
30
52
|
});
|
|
31
53
|
};
|
|
32
54
|
|
|
@@ -34,17 +56,17 @@ sendMessage.defaultProps = {
|
|
|
34
56
|
options: {
|
|
35
57
|
variant: 'success',
|
|
36
58
|
message: ' ',
|
|
37
|
-
description: ' '
|
|
38
|
-
}
|
|
59
|
+
description: ' ',
|
|
60
|
+
},
|
|
39
61
|
};
|
|
40
62
|
|
|
41
63
|
sendMessage.propTypes = {
|
|
42
64
|
options: PropTypes.shape({
|
|
43
65
|
variant: PropTypes.oneOf(['success', 'error']),
|
|
44
66
|
message: PropTypes.string,
|
|
45
|
-
description: PropTypes.string
|
|
46
|
-
})
|
|
47
|
-
}
|
|
67
|
+
description: PropTypes.string,
|
|
68
|
+
}),
|
|
69
|
+
};
|
|
48
70
|
|
|
49
71
|
const FlashMessage = () => {
|
|
50
72
|
return (
|
|
@@ -54,6 +76,6 @@ const FlashMessage = () => {
|
|
|
54
76
|
textStyle={{ fontFamily: 'poppins_regular' }}
|
|
55
77
|
/>
|
|
56
78
|
);
|
|
57
|
-
}
|
|
79
|
+
};
|
|
58
80
|
|
|
59
81
|
export default FlashMessage;
|