@holper/react-native-holper-storybook 0.6.101 → 0.7.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.
Files changed (210) hide show
  1. package/.expo/README.md +8 -0
  2. package/.nvmrc +1 -0
  3. package/.prettierignore +5 -0
  4. package/.storybook/index.jsx +11 -0
  5. package/.storybook/main.js +8 -0
  6. package/.storybook/preview.jsx +51 -0
  7. package/.storybook/storybook.requires.js +43 -0
  8. package/.yarn/releases/yarn-4.5.0.cjs +925 -0
  9. package/.yarnrc.yml +3 -0
  10. package/App.jsx +29 -0
  11. package/LICENSE +21 -0
  12. package/{readme.md → README.md} +18 -19
  13. package/app.config.js +77 -0
  14. package/assets/adaptive-icon.png +0 -0
  15. package/assets/favicon.png +0 -0
  16. package/assets/fonts/Poppins-Bold.ttf +0 -0
  17. package/assets/fonts/Poppins-Regular.ttf +0 -0
  18. package/assets/fonts/Poppins-SemiBold.ttf +0 -0
  19. package/assets/icon.png +0 -0
  20. package/assets/splash.png +0 -0
  21. package/babel.config.js +7 -0
  22. package/build.sh +11 -0
  23. package/components/Button/index.tsx +66 -0
  24. package/{lib/components/Button/style.js → components/Button/style.ts} +8 -7
  25. package/components/Card/index.tsx +33 -0
  26. package/{lib/components/Card/style.js → components/Card/style.ts} +5 -4
  27. package/{lib/components/ConfirmationModal/index.js → components/ConfirmationModal/index.tsx} +25 -79
  28. package/{lib/components/ConfirmationModal/style.js → components/ConfirmationModal/style.tsx} +14 -13
  29. package/{lib/components/Container/index.js → components/Container/index.tsx} +7 -28
  30. package/{lib/components/Container/style.js → components/Container/style.ts} +6 -5
  31. package/{lib/components/CustomChatView/index.js → components/CustomChatView/index.tsx} +22 -30
  32. package/{lib/components/CustomChatView/style.js → components/CustomChatView/style.ts} +1 -1
  33. package/components/DeckSwiper/index.tsx +90 -0
  34. package/{lib/components/DeckSwiper/style.js → components/DeckSwiper/style.ts} +13 -12
  35. package/components/DonutCountdown/index.tsx +86 -0
  36. package/components/DonutCountdown/style.ts +8 -0
  37. package/components/FloatingContainer/index.tsx +35 -0
  38. package/{lib/components/FloatingContainer/style.js → components/FloatingContainer/style.ts} +7 -6
  39. package/components/Footer/index.tsx +35 -0
  40. package/{lib/components/Footer/style.js → components/Footer/style.ts} +4 -3
  41. package/components/Header/index.tsx +21 -0
  42. package/{lib/components/Header/style.js → components/Header/style.ts} +4 -3
  43. package/{lib/components/ImagePicker/index.js → components/ImagePicker/index.tsx} +3 -12
  44. package/components/ImageResponsive/index.tsx +24 -0
  45. package/components/ImageResponsive/style.ts +9 -0
  46. package/components/ImageViewer/index.tsx +36 -0
  47. package/{lib/components/ImageViewer/style.js → components/ImageViewer/style.ts} +11 -10
  48. package/{lib/components/Input/index.js → components/Input/index.tsx} +6 -33
  49. package/{lib/components/Input/style.js → components/Input/style.ts} +7 -18
  50. package/{lib/components/InputPin/index.js → components/InputPin/index.tsx} +6 -13
  51. package/{lib/components/InputPin/style.js → components/InputPin/style.ts} +7 -6
  52. package/components/MenuItem/index.tsx +25 -0
  53. package/{lib/components/MenuItem/style.js → components/MenuItem/style.ts} +9 -7
  54. package/{lib/components/NavigationTitle/index.js → components/NavigationTitle/index.tsx} +9 -30
  55. package/{lib/components/NavigationTitle/style.js → components/NavigationTitle/style.ts} +12 -11
  56. package/components/Notification/index.tsx +44 -0
  57. package/{lib/components/Notification/style.js → components/Notification/style.ts} +13 -11
  58. package/components/PreventDoubleClick/index.tsx +28 -0
  59. package/components/Select/index.tsx +51 -0
  60. package/components/Select/style.ts +64 -0
  61. package/{lib/components/SwipeablePanel/index.js → components/SwipeablePanel/index.tsx} +58 -85
  62. package/{lib/components/SwipeablePanel/style.js → components/SwipeablePanel/style.ts} +15 -14
  63. package/components/Switch/index.tsx +30 -0
  64. package/components/TakePicture/confirmPictureModal.tsx +37 -0
  65. package/components/TakePicture/index.tsx +148 -0
  66. package/{lib/components/TakePicture/style.js → components/TakePicture/style.ts} +4 -4
  67. package/components/Text/index.tsx +33 -0
  68. package/{lib/components/Text/style.js → components/Text/style.ts} +4 -2
  69. package/{lib/components/Textarea/index.js → components/Textarea/index.tsx} +5 -24
  70. package/{lib/components/Textarea/style.js → components/Textarea/style.ts} +5 -4
  71. package/components/TimeOutButton/index.tsx +67 -0
  72. package/{lib/components/TimeOutButton/style.js → components/TimeOutButton/style.ts} +4 -3
  73. package/components/Toast/index.tsx +34 -0
  74. package/components/Toast/style.ts +12 -0
  75. package/{lib/components/UploadDocument/index.js → components/UploadDocument/index.tsx} +49 -105
  76. package/{lib/components/UploadDocument/style.js → components/UploadDocument/style.ts} +16 -15
  77. package/components/VirtualKeyboard/index.tsx +75 -0
  78. package/{lib/components/VirtualKeyboard/style.js → components/VirtualKeyboard/style.ts} +9 -8
  79. package/components/index.ts +29 -0
  80. package/{lib/configs/constants.js → configs/constants.ts} +50 -48
  81. package/configs/types.ts +326 -0
  82. package/eas.json +27 -0
  83. package/eslint.config.mjs +205 -0
  84. package/hooks/index.ts +2 -0
  85. package/{lib/hooks/useDebounce.js → hooks/useDebounce.tsx} +6 -4
  86. package/hooks/useLoadFonts.tsx +13 -0
  87. package/index.js +3 -2
  88. package/lib/components/Button/index.tsx +66 -0
  89. package/lib/components/Button/style.ts +111 -0
  90. package/lib/components/Card/index.tsx +33 -0
  91. package/lib/components/Card/style.ts +34 -0
  92. package/lib/components/ConfirmationModal/index.tsx +104 -0
  93. package/lib/components/ConfirmationModal/style.tsx +53 -0
  94. package/lib/components/Container/index.tsx +33 -0
  95. package/lib/components/Container/style.ts +13 -0
  96. package/lib/components/CustomChatView/index.tsx +65 -0
  97. package/lib/components/CustomChatView/style.ts +10 -0
  98. package/lib/components/DeckSwiper/index.tsx +90 -0
  99. package/lib/components/DeckSwiper/style.ts +59 -0
  100. package/lib/components/DonutCountdown/index.tsx +86 -0
  101. package/lib/components/DonutCountdown/style.ts +8 -0
  102. package/lib/components/FloatingContainer/index.tsx +35 -0
  103. package/lib/components/FloatingContainer/style.ts +25 -0
  104. package/lib/components/Footer/index.tsx +35 -0
  105. package/lib/components/Footer/style.ts +40 -0
  106. package/lib/components/Header/index.tsx +21 -0
  107. package/lib/components/Header/style.ts +34 -0
  108. package/lib/components/ImagePicker/index.tsx +18 -0
  109. package/lib/components/ImageResponsive/index.tsx +24 -0
  110. package/lib/components/ImageResponsive/style.ts +9 -0
  111. package/lib/components/ImageViewer/index.tsx +36 -0
  112. package/lib/components/ImageViewer/style.ts +38 -0
  113. package/lib/components/Input/index.tsx +62 -0
  114. package/lib/components/Input/style.ts +91 -0
  115. package/lib/components/InputPin/index.tsx +21 -0
  116. package/lib/components/InputPin/style.ts +22 -0
  117. package/lib/components/MenuItem/index.tsx +25 -0
  118. package/lib/components/MenuItem/style.ts +44 -0
  119. package/lib/components/NavigationTitle/index.tsx +53 -0
  120. package/lib/components/NavigationTitle/style.ts +49 -0
  121. package/lib/components/Notification/index.tsx +44 -0
  122. package/lib/components/Notification/style.ts +50 -0
  123. package/lib/components/PreventDoubleClick/index.tsx +28 -0
  124. package/lib/components/Select/index.tsx +51 -0
  125. package/lib/components/Select/style.ts +64 -0
  126. package/lib/components/SwipeablePanel/index.tsx +208 -0
  127. package/lib/components/SwipeablePanel/style.ts +81 -0
  128. package/lib/components/Switch/index.tsx +30 -0
  129. package/lib/components/TakePicture/confirmPictureModal.tsx +37 -0
  130. package/lib/components/TakePicture/index.tsx +148 -0
  131. package/lib/components/TakePicture/style.ts +95 -0
  132. package/lib/components/Text/index.tsx +33 -0
  133. package/lib/components/Text/style.ts +101 -0
  134. package/lib/components/Textarea/index.tsx +26 -0
  135. package/lib/components/Textarea/style.ts +38 -0
  136. package/lib/components/TimeOutButton/index.tsx +67 -0
  137. package/lib/components/TimeOutButton/style.ts +42 -0
  138. package/lib/components/Toast/index.tsx +34 -0
  139. package/lib/components/Toast/style.ts +12 -0
  140. package/lib/components/UploadDocument/index.tsx +179 -0
  141. package/lib/components/UploadDocument/style.ts +57 -0
  142. package/lib/components/VirtualKeyboard/index.tsx +75 -0
  143. package/lib/components/VirtualKeyboard/style.ts +25 -0
  144. package/lib/components/index.ts +29 -0
  145. package/lib/configs/constants.ts +273 -0
  146. package/lib/configs/types.ts +326 -0
  147. package/lib/hooks/index.ts +2 -0
  148. package/lib/hooks/useDebounce.tsx +24 -0
  149. package/lib/hooks/useLoadFonts.tsx +13 -0
  150. package/lib/index.js +3 -2
  151. package/metro.config.js +11 -0
  152. package/package.json +72 -63
  153. package/prettier.config.mjs +23 -0
  154. package/stories/Button.stories.tsx +181 -0
  155. package/stories/Card.stories.tsx +22 -0
  156. package/stories/Colors.stories.tsx +57 -0
  157. package/stories/ConfirmationModal.stories.tsx +142 -0
  158. package/stories/Container.stories.tsx +105 -0
  159. package/stories/DeckSwiper.stories.tsx +43 -0
  160. package/stories/DonutCountdown.stories.tsx +134 -0
  161. package/stories/FloatingContainer.stories.tsx +139 -0
  162. package/stories/Footer.stories.tsx +65 -0
  163. package/stories/Header.stories.tsx +37 -0
  164. package/stories/ImagePicker.stories.tsx +14 -0
  165. package/stories/ImageResponsive.stories.tsx +18 -0
  166. package/stories/ImageViewer.stories.tsx +24 -0
  167. package/stories/Input.stories.tsx +119 -0
  168. package/stories/InputPin.stories.tsx +40 -0
  169. package/stories/Menu.stories.tsx +53 -0
  170. package/stories/MenuItem.stories.tsx +30 -0
  171. package/stories/NavigationTitle.stories.tsx +51 -0
  172. package/stories/Notification.stories.tsx +58 -0
  173. package/stories/Select.stories.tsx +270 -0
  174. package/stories/SwipeablePanel.stories.tsx +360 -0
  175. package/stories/Switch.stories.tsx +36 -0
  176. package/stories/TakePicture.stories.tsx +59 -0
  177. package/stories/Text.stories.tsx +61 -0
  178. package/stories/Textarea.stories.tsx +48 -0
  179. package/stories/TimeOutButton.stories.tsx +55 -0
  180. package/stories/Toast.stories.tsx +37 -0
  181. package/stories/UploadDocument.stories.tsx +179 -0
  182. package/stories/VirtualKeyboard.stories.tsx +14 -0
  183. package/tsconfig.json +21 -0
  184. package/utilities/ScrollView.tsx +19 -0
  185. package/utilities/index.ts +2 -0
  186. package/utilities/utils.ts +29 -0
  187. package/lib/components/Button/index.js +0 -104
  188. package/lib/components/Card/index.js +0 -49
  189. package/lib/components/DeckSwiper/index.js +0 -118
  190. package/lib/components/FlashMessage/index.js +0 -81
  191. package/lib/components/FloatingContainer/index.js +0 -69
  192. package/lib/components/Footer/index.js +0 -61
  193. package/lib/components/Header/index.js +0 -45
  194. package/lib/components/ImageResponsive/index.js +0 -39
  195. package/lib/components/ImageResponsive/style.js +0 -7
  196. package/lib/components/ImageViewer/index.js +0 -62
  197. package/lib/components/MenuItem/index.js +0 -44
  198. package/lib/components/Notification/index.js +0 -80
  199. package/lib/components/PreventDoubleClick/index.js +0 -21
  200. package/lib/components/Select/index.js +0 -89
  201. package/lib/components/Select/style.js +0 -81
  202. package/lib/components/Switch/index.js +0 -57
  203. package/lib/components/TakePicture/confirmPictureModal.js +0 -64
  204. package/lib/components/TakePicture/index.js +0 -198
  205. package/lib/components/Text/index.js +0 -75
  206. package/lib/components/TimeOutButton/index.js +0 -104
  207. package/lib/components/VirtualKeyboard/index.js +0 -86
  208. package/lib/components/index.js +0 -28
  209. package/lib/configs/loadFonts.js +0 -11
  210. package/lib/hooks/index.js +0 -1
@@ -0,0 +1,179 @@
1
+ import { Ionicons } from '@expo/vector-icons';
2
+ import { useState } from 'react';
3
+ import { Alert } from 'react-native';
4
+
5
+ import { UploadDocument } from '../components';
6
+ import { Colors } from '../configs/constants';
7
+
8
+ export default {
9
+ title: 'UploadDocument',
10
+ component: UploadDocument,
11
+ };
12
+
13
+ export const Default = {
14
+ render: () => (
15
+ <UploadDocument
16
+ title="Foto frontal"
17
+ description="Foto frontal de su cedula de identidad"
18
+ uploadButtonText="Subir"
19
+ reUploadButtonText="Volver a subir documento"
20
+ icon={<Ionicons name="image-outline" color={Colors.darkblue} size={50} />}
21
+ mediaModal={{
22
+ title: 'Seleccionar origen',
23
+ description: 'Selecione desde donde desea cargar el archivo',
24
+ confirmText: 'Cámara',
25
+ cancelText: 'Galería',
26
+ }}
27
+ takePicture={{
28
+ cameraErrorMessage: 'No access to the camera',
29
+ requestPermissionsMessage: 'Grant access to the camera',
30
+ processingPictureMessage: 'Processing',
31
+ repeatPictureText: 'Repeat',
32
+ usePictureText: 'Use',
33
+ }}
34
+ onSelectImage={() => {}}
35
+ />
36
+ ),
37
+ };
38
+
39
+ export const AvatarType = {
40
+ render: () => (
41
+ <UploadDocument
42
+ title="Avatar"
43
+ uploadButtonText="Subir"
44
+ reUploadButtonText="Volver a subir avatar"
45
+ icon={<Ionicons name="happy-outline" color={Colors.darkblue} size={50} />}
46
+ mediaModal={{
47
+ title: 'Seleccionar origen',
48
+ description: 'Selecione desde donde desea cargar el archivo',
49
+ confirmText: 'Cámara',
50
+ cancelText: 'Galería',
51
+ }}
52
+ takePicture={{
53
+ cameraErrorMessage: 'No access to the camera',
54
+ requestPermissionsMessage: 'Grant access to the camera',
55
+ processingPictureMessage: 'Processing',
56
+ repeatPictureText: 'Repeat',
57
+ usePictureText: 'Use',
58
+ }}
59
+ onSelectImage={() => {}}
60
+ isAvatarPicker
61
+ />
62
+ ),
63
+ };
64
+
65
+ export const PreloadedFile = {
66
+ render: () => (
67
+ <UploadDocument
68
+ title="Foto frontal"
69
+ description="Foto frontal de su cedula de identidad"
70
+ uploadButtonText="Subir"
71
+ reUploadButtonText="Volver a subir documento"
72
+ icon={<Ionicons name="image-outline" color={Colors.darkblue} size={50} />}
73
+ mediaModal={{
74
+ title: 'Seleccionar origen',
75
+ description: 'Selecione desde donde desea cargar el archivo',
76
+ confirmText: 'Cámara',
77
+ cancelText: 'Galería',
78
+ }}
79
+ takePicture={{
80
+ cameraErrorMessage: 'No access to the camera',
81
+ requestPermissionsMessage: 'Grant access to the camera',
82
+ processingPictureMessage: 'Processing',
83
+ repeatPictureText: 'Repeat',
84
+ usePictureText: 'Use',
85
+ }}
86
+ onSelectImage={() => {}}
87
+ file="https://picsum.photos/200?random=1"
88
+ />
89
+ ),
90
+ };
91
+
92
+ const CompletedComponent = () => {
93
+ const [value, setValue] = useState<string>();
94
+
95
+ return (
96
+ <UploadDocument
97
+ title="Foto frontal"
98
+ description="Foto frontal de su cedula de identidad"
99
+ uploadButtonText="Subir"
100
+ reUploadButtonText="Volver a subir documento"
101
+ icon={<Ionicons name="image-outline" color={Colors.darkblue} size={50} />}
102
+ mediaModal={{
103
+ title: 'Seleccionar origen',
104
+ description: 'Selecione desde donde desea cargar el archivo',
105
+ confirmText: 'Cámara',
106
+ cancelText: 'Galería',
107
+ }}
108
+ takePicture={{
109
+ cameraErrorMessage: 'No access to the camera',
110
+ requestPermissionsMessage: 'Grant access to the camera',
111
+ processingPictureMessage: 'Processing',
112
+ repeatPictureText: 'Repeat',
113
+ usePictureText: 'Use',
114
+ }}
115
+ onSelectImage={setValue}
116
+ completed={value !== null}
117
+ />
118
+ );
119
+ };
120
+
121
+ export const Completed = {
122
+ render: CompletedComponent,
123
+ };
124
+
125
+ export const Inverted = {
126
+ render: () => (
127
+ <UploadDocument
128
+ inverted
129
+ title="Foto frontal"
130
+ description="Foto frontal de su cedula de identidad"
131
+ uploadButtonText="Subir"
132
+ reUploadButtonText="Volver a subir documento"
133
+ icon={<Ionicons name="image-outline" color={Colors.darkblue} size={50} />}
134
+ mediaModal={{
135
+ title: 'Seleccionar origen',
136
+ description: 'Selecione desde donde desea cargar el archivo',
137
+ confirmText: 'Cámara',
138
+ cancelText: 'Galería',
139
+ }}
140
+ takePicture={{
141
+ cameraErrorMessage: 'No access to the camera',
142
+ requestPermissionsMessage: 'Grant access to the camera',
143
+ processingPictureMessage: 'Processing',
144
+ repeatPictureText: 'Repeat',
145
+ usePictureText: 'Use',
146
+ }}
147
+ onSelectImage={() => {}}
148
+ />
149
+ ),
150
+ };
151
+
152
+ export const PermissionDenied = {
153
+ render: () => (
154
+ <UploadDocument
155
+ title="Foto frontal"
156
+ description="Foto frontal de su cedula de identidad"
157
+ uploadButtonText="Subir"
158
+ reUploadButtonText="Volver a subir documento"
159
+ icon={<Ionicons name="image-outline" color={Colors.darkblue} size={50} />}
160
+ onPermissionDenied={() => {
161
+ Alert.alert('Permission denied', 'Permission denied');
162
+ }}
163
+ mediaModal={{
164
+ title: 'Seleccionar origen',
165
+ description: 'Selecione desde donde desea cargar el archivo',
166
+ confirmText: 'Cámara',
167
+ cancelText: 'Galería',
168
+ }}
169
+ takePicture={{
170
+ cameraErrorMessage: 'No access to the camera',
171
+ requestPermissionsMessage: 'Grant access to the camera',
172
+ processingPictureMessage: 'Processing',
173
+ repeatPictureText: 'Repeat',
174
+ usePictureText: 'Use',
175
+ }}
176
+ onSelectImage={() => {}}
177
+ />
178
+ ),
179
+ };
@@ -0,0 +1,14 @@
1
+ import { VirtualKeyboard } from '../components';
2
+
3
+ export default {
4
+ title: 'Virtual Keyboard',
5
+ component: VirtualKeyboard,
6
+ };
7
+
8
+ export const Default = {
9
+ render: () => <VirtualKeyboard onPress={() => {}} />,
10
+ };
11
+
12
+ export const HideBiometrics = {
13
+ render: () => <VirtualKeyboard onPress={() => {}} hideBiometrics />,
14
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Bundler */
4
+ "jsx": "preserve",
5
+ "allowJs": true,
6
+ "resolveJsonModule": true,
7
+
8
+ /* Linting */
9
+ "allowSyntheticDefaultImports": true,
10
+ "experimentalDecorators": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "noEmit": true,
13
+ "noFallthroughCasesInSwitch": true,
14
+ "noImplicitAny": true,
15
+ "noImplicitThis": true,
16
+ "strict": true,
17
+ "strictNullChecks": true,
18
+ "useUnknownInCatchVariables": false
19
+ },
20
+ "extends": "expo/tsconfig.base"
21
+ }
@@ -0,0 +1,19 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { StyleProp, ViewStyle } from 'react-native';
3
+
4
+ import { ScrollView } from 'react-native';
5
+
6
+ interface ScrollViewProps {
7
+ children: ReactNode;
8
+ styles?: StyleProp<ViewStyle>;
9
+ contentContainerStyle?: StyleProp<ViewStyle>;
10
+ }
11
+
12
+ export default ({ children, styles, contentContainerStyle }: ScrollViewProps) => (
13
+ <ScrollView
14
+ style={[{ paddingVertical: 42, paddingHorizontal: 20, flex: 1 }, styles]}
15
+ contentContainerStyle={contentContainerStyle}
16
+ >
17
+ {children}
18
+ </ScrollView>
19
+ );
@@ -0,0 +1,2 @@
1
+ export { default as ScrollView } from './ScrollView';
2
+ export { lightOrDark } from './utils';
@@ -0,0 +1,29 @@
1
+ export const lightOrDark = (color: any) => {
2
+ let r: number, g: number, b: number;
3
+ // Check the format of the color, HEX or RGB?
4
+ if (color.match(/^rgb/)) {
5
+ // If HEX --> store the red, green, blue values in separate variables
6
+ color = color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);
7
+
8
+ r = color[1];
9
+ g = color[2];
10
+ b = color[3];
11
+ } else {
12
+ // If RGB --> Convert it to HEX: http://gist.github.com/983661
13
+ color = +('0x' + color.slice(1).replace(color.length < 5 && /./g, '$&$&'));
14
+
15
+ r = Math.floor(color / (256 * 256));
16
+ g = Math.floor(color / 256) % 256;
17
+ b = color % 256;
18
+ }
19
+
20
+ // HSP equation from http://alienryderflex.com/hsp.html
21
+ const hsp = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b));
22
+
23
+ // Using the HSP value, determine whether the color is light or dark
24
+ if (hsp > 127.5) {
25
+ return 'light';
26
+ } else {
27
+ return 'dark';
28
+ }
29
+ };
@@ -1,104 +0,0 @@
1
- import React, { useState, useEffect } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { TouchableOpacity, ActivityIndicator } from 'react-native';
4
- import withPreventDoubleClick from './../PreventDoubleClick';
5
- import { Colors } from '../../configs/constants';
6
- import style from './style';
7
-
8
- const Button = ({
9
- onPress,
10
- disabled,
11
- isLoading,
12
- bordered,
13
- variant = 'primary',
14
- size = 'medium',
15
- noShadow,
16
- style: customStyle,
17
- debounceDelay = 0,
18
- children,
19
- }) => {
20
- const [isDisabled, setIsDisabled] = useState(disabled);
21
-
22
- useEffect(() => setIsDisabled(disabled), [disabled]);
23
-
24
- const getSpinnerColor = () => {
25
- switch (variant) {
26
- case 'primary':
27
- case 'inverted':
28
- case 'error':
29
- return Colors.white;
30
- default:
31
- return Colors.darkblue;
32
- }
33
- };
34
-
35
- const handleTap = () => {
36
- onPress();
37
- setIsDisabled(true);
38
- setTimeout(() => {
39
- setIsDisabled(false);
40
- }, debounceDelay);
41
- };
42
-
43
- return (
44
- <TouchableOpacity
45
- style={[
46
- style.button,
47
- style[variant],
48
- style[size],
49
- bordered ? style.bordered : {},
50
- isDisabled ? style.disabled : {},
51
- noShadow ? style.noShadow : {},
52
- customStyle,
53
- ]}
54
- disabled={isLoading || isDisabled}
55
- onPress={handleTap}
56
- >
57
- {isLoading ? (
58
- <ActivityIndicator color={getSpinnerColor()} size={28} />
59
- ) : (
60
- children
61
- )}
62
- </TouchableOpacity>
63
- );
64
- };
65
-
66
- Button.defaultProps = {
67
- children: null,
68
- disabled: false,
69
- isLoading: false,
70
- bordered: false,
71
- noShadow: false,
72
- variant: 'primary',
73
- size: 'medium',
74
- style: {},
75
- onPress: () => {},
76
- debounceDelay: 0,
77
- };
78
-
79
- Button.propTypes = {
80
- children: PropTypes.node,
81
- disabled: PropTypes.bool,
82
- isLoading: PropTypes.bool,
83
- bordered: PropTypes.bool,
84
- noShadow: PropTypes.bool,
85
- variant: PropTypes.oneOf([
86
- 'brightblue',
87
- 'brightviolet',
88
- 'darkyellow',
89
- 'dim',
90
- 'electricblue',
91
- 'error',
92
- 'inverted',
93
- 'light',
94
- 'lightgreen',
95
- 'primary',
96
- 'secondary',
97
- ]),
98
- size: PropTypes.oneOf(['tiny', 'small', 'medium', 'fit', 'icon']),
99
- style: PropTypes.any,
100
- onPress: PropTypes.func,
101
- debounceDelay: PropTypes.number,
102
- };
103
-
104
- export default withPreventDoubleClick(Button);
@@ -1,49 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { View, TouchableOpacity } from 'react-native';
4
- import withPreventDoubleClick from '../PreventDoubleClick';
5
- import style from './style';
6
-
7
- const TappedTouchableOpacity = withPreventDoubleClick(TouchableOpacity);
8
-
9
- const Card = (
10
- { children, isButton, onPress, noShadow, style: customStyle },
11
- ...props
12
- ) => (
13
- <>
14
- {isButton ? (
15
- <TappedTouchableOpacity
16
- onPress={onPress}
17
- style={[style.card, customStyle, noShadow ? style.noShadow : {}]}
18
- {...props}
19
- >
20
- {children}
21
- </TappedTouchableOpacity>
22
- ) : (
23
- <View
24
- style={[style.card, customStyle, noShadow ? style.noShadow : {}]}
25
- {...props}
26
- >
27
- {children}
28
- </View>
29
- )}
30
- </>
31
- );
32
-
33
- Card.defaultProps = {
34
- style: {},
35
- children: null,
36
- isButton: false,
37
- noShadow: false,
38
- onPress: () => {},
39
- };
40
-
41
- Card.propTypes = {
42
- style: PropTypes.any,
43
- children: PropTypes.node,
44
- isButton: PropTypes.bool,
45
- noShadow: PropTypes.bool,
46
- onPress: PropTypes.func,
47
- };
48
-
49
- export default Card;
@@ -1,118 +0,0 @@
1
- import React, { useRef, useState } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { View, Image } from 'react-native';
4
- import Swiper from 'react-native-deck-swiper';
5
- import Entypo from 'react-native-vector-icons/Entypo';
6
- import Text from '../Text';
7
- import Button from '../Button';
8
- import { Colors } from '../../configs/constants';
9
- import style from './style';
10
-
11
- const DeckSwiper = ({ data, inverted, nextText, onChange, onFinish }) => {
12
- const swiper = useRef(null);
13
- const [finished, setFinished] = useState(false);
14
- const [index, setIndex] = useState(0);
15
-
16
- const renderDots = () =>
17
- data.map((d, i) => (
18
- <Entypo
19
- name='dot-single'
20
- size={36}
21
- key={`dot-${i}`}
22
- style={style[index === i ? 'dotSelected' : 'dot']}
23
- />
24
- ));
25
-
26
- return (
27
- <>
28
- <Swiper
29
- ref={swiper}
30
- cards={data}
31
- renderCard={(card) => {
32
- if (!card) {
33
- return null;
34
- }
35
- return (
36
- <View style={style.card}>
37
- <View style={style.imageContainer}>
38
- <Image
39
- style={style.imageResponsive}
40
- source={card.image}
41
- progressiveRenderingEnabled
42
- resizeMode='contain'
43
- />
44
- </View>
45
- <View style={style.textContainer}>
46
- <Text size='extra-large' style={style.title}>
47
- {card.title}
48
- </Text>
49
- <Text size='large' align='center'>
50
- {card.description}
51
- </Text>
52
- </View>
53
- </View>
54
- );
55
- }}
56
- onSwipedAll={() => {
57
- setFinished(true);
58
- onFinish();
59
- }}
60
- onSwipedRight={(index) => {
61
- setIndex(index - 1);
62
- onChange(index - 1);
63
- }}
64
- onSwipedLeft={(index) => {
65
- setIndex(index + 1);
66
- onChange(index + 1);
67
- }}
68
- cardIndex={index}
69
- backgroundColor={Colors.white}
70
- stackSize={2}
71
- verticalSwipe={false}
72
- showSecondCard={true}
73
- disableRightSwipe={index === 0}
74
- goBackToPreviousCardOnSwipeRight={true}
75
- childrenOnTop
76
- >
77
- {!finished && (
78
- <>
79
- <View style={style.dotsContainer}>{renderDots()}</View>
80
- <View style={style.container}>
81
- <Button
82
- variant={inverted ? 'inverted' : 'primary'}
83
- onPress={() => swiper.current.swipeLeft()}
84
- >
85
- <Text color='white'>{nextText}</Text>
86
- </Button>
87
- </View>
88
- </>
89
- )}
90
- </Swiper>
91
- </>
92
- );
93
- };
94
-
95
- DeckSwiper.defaultProps = {
96
- data: [],
97
- inverted: false,
98
- nextText: ' ',
99
- useUri: false,
100
- onChange: () => {},
101
- onfinish: () => {},
102
- };
103
-
104
- DeckSwiper.propTypes = {
105
- data: PropTypes.arrayOf(
106
- PropTypes.shape({
107
- image: PropTypes.string,
108
- title: PropTypes.string,
109
- description: PropTypes.string,
110
- })
111
- ),
112
- inverted: PropTypes.bool,
113
- nextText: PropTypes.string,
114
- onChange: PropTypes.func,
115
- onFinish: PropTypes.func,
116
- };
117
-
118
- export default DeckSwiper;
@@ -1,81 +0,0 @@
1
- import React from 'react';
2
- import { Platform } from 'react-native';
3
- import PropTypes from 'prop-types';
4
- import Ionicons from 'react-native-vector-icons/Ionicons';
5
- import RNFlashMessage, {
6
- showMessage,
7
- renderFlashMessageIcon,
8
- } from 'react-native-flash-message';
9
- import { Colors } from '../../configs/constants';
10
-
11
- export const customRenderFlashMessageIcon = (
12
- icon = 'success',
13
- style = {},
14
- customProps = {}
15
- ) => {
16
- switch (icon) {
17
- case 'success':
18
- return (
19
- <Ionicons
20
- name='checkmark-circle-outline'
21
- color={Colors.darkblue}
22
- size={30}
23
- />
24
- );
25
- case 'error':
26
- return (
27
- <Ionicons
28
- name='alert-circle-outline'
29
- color={Colors.darkblue}
30
- size={30}
31
- />
32
- );
33
- }
34
-
35
- // it's good to inherit the original method...
36
- return renderFlashMessageIcon(icon, style, customProps);
37
- };
38
-
39
- const statusBarHeight = Platform.OS === 'android' ? { statusBarHeight: 5 } : {};
40
-
41
- export const sendMessage = ({ variant, message, description }) => {
42
- return showMessage({
43
- position: 'top',
44
- message,
45
- description,
46
- icon: variant,
47
- type: variant,
48
- backgroundColor: variant === 'success' ? Colors.green : Colors.lightred,
49
- color: Colors.darkblue,
50
- hideOnPress: true,
51
- ...statusBarHeight,
52
- });
53
- };
54
-
55
- sendMessage.defaultProps = {
56
- options: {
57
- variant: 'success',
58
- message: ' ',
59
- description: ' ',
60
- },
61
- };
62
-
63
- sendMessage.propTypes = {
64
- options: PropTypes.shape({
65
- variant: PropTypes.oneOf(['success', 'error']),
66
- message: PropTypes.string,
67
- description: PropTypes.string,
68
- }),
69
- };
70
-
71
- const FlashMessage = () => {
72
- return (
73
- <RNFlashMessage
74
- renderFlashMessageIcon={customRenderFlashMessageIcon}
75
- titleStyle={{ fontFamily: 'poppins_bold' }}
76
- textStyle={{ fontFamily: 'poppins_regular' }}
77
- />
78
- );
79
- };
80
-
81
- export default FlashMessage;
@@ -1,69 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import {
4
- View,
5
- ScrollView,
6
- RefreshControl,
7
- KeyboardAvoidingView,
8
- Platform,
9
- } from 'react-native';
10
- import style from './style';
11
-
12
- const FloatingContainer = ({
13
- useRefreshControl,
14
- onRefresh,
15
- isRefreshing,
16
- children,
17
- floatingComponent,
18
- centered,
19
- floatingContainerStyle,
20
- disableScroll,
21
- }) => (
22
- <KeyboardAvoidingView
23
- style={style.floatingContainer}
24
- behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
25
- >
26
- <ScrollView
27
- contentContainerStyle={centered ? style.centered : {}}
28
- fadingEdgeLength={150}
29
- keyboardShouldPersistTaps='handled'
30
- showsVerticalScrollIndicator={false}
31
- scrollEnabled={!disableScroll}
32
- keyboardDismissMode='on-drag'
33
- refreshControl={
34
- useRefreshControl ? (
35
- <RefreshControl refreshing={isRefreshing} onRefresh={onRefresh} />
36
- ) : null
37
- }
38
- >
39
- {children}
40
- </ScrollView>
41
- <View style={[style.container, floatingContainerStyle]}>
42
- {floatingComponent}
43
- </View>
44
- </KeyboardAvoidingView>
45
- );
46
-
47
- FloatingContainer.defaultProps = {
48
- useRefreshControl: false,
49
- isRefreshing: false,
50
- centered: false,
51
- onRefresh: () => {},
52
- children: null,
53
- floatingComponent: null,
54
- disableScroll: false,
55
- floatingContainerStyle: {},
56
- };
57
-
58
- FloatingContainer.propTypes = {
59
- useRefreshControl: PropTypes.bool,
60
- isRefreshing: PropTypes.bool,
61
- centered: PropTypes.bool,
62
- onRefresh: PropTypes.func,
63
- children: PropTypes.node,
64
- floatingComponent: PropTypes.node,
65
- disableScroll: PropTypes.bool,
66
- floatingContainerStyle: PropTypes.any,
67
- };
68
-
69
- export default FloatingContainer;