@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
package/.yarnrc.yml ADDED
@@ -0,0 +1,3 @@
1
+ yarnPath: .yarn/releases/yarn-4.5.0.cjs
2
+
3
+ nodeLinker: node-modules
package/App.jsx ADDED
@@ -0,0 +1,29 @@
1
+ import { LogBox, StyleSheet, View } from 'react-native';
2
+ import Constants from 'expo-constants';
3
+ import { Text } from './components';
4
+ LogBox.ignoreAllLogs();
5
+
6
+ function App() {
7
+ return (
8
+ <View style={styles.container}>
9
+ <Text>Open up App.tsx to start working on your app!</Text>
10
+ </View>
11
+ );
12
+ }
13
+
14
+ let AppEntryPoint = App;
15
+
16
+ if (Constants.expoConfig.extra.storybookEnabled === 'true') {
17
+ AppEntryPoint = require('./.storybook').default;
18
+ }
19
+
20
+ const styles = StyleSheet.create({
21
+ container: {
22
+ flex: 1,
23
+ backgroundColor: '#fff',
24
+ alignItems: 'center',
25
+ justifyContent: 'center',
26
+ },
27
+ });
28
+
29
+ export default AppEntryPoint;
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.
@@ -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
16
+
18
17
  `import { asyncLoadFont } from from 'react-native-holper-storybook';` and call the `asyncLoadFont` function in your app entry point.
19
18
 
20
19
  ```
21
- import React, { useEffect, useState } from 'react';
22
- import { asyncLoadFont } from 'react-native-holper-storybook';
20
+ import { useEffect, useState } from 'react';
21
+ import { useLoadFonts } from 'react-native-holper-storybook';
23
22
 
24
23
  export default function App() {
25
- const [fontsLoaded, setFontsLoaded] = useState(false);
24
+ const { loaded, error } = useLoadFonts();
26
25
 
27
26
  useEffect(() => {
28
- (async function() {
29
- await asyncLoadFont;
30
- setFontsLoaded(true);
31
- })();
32
- }, []);
33
-
34
- if (!fontsLoaded) {
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 FlashMessage
45
- This library uses https://www.npmjs.com/package/react-native-flash-message, in order to use it, include `<FlashMessage/>` in you root component.
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 { FlashMessage } from 'react-native-holper-storybook';
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
- <FlashMessage />
55
+ <Toaster />
57
56
  </View>
58
57
  );
59
58
  }
60
59
  ```
61
60
 
62
- ###### Sending a messages
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/app.config.js ADDED
@@ -0,0 +1,77 @@
1
+ export default ({ config }) => ({
2
+ ...config,
3
+ android: {
4
+ adaptiveIcon: {
5
+ backgroundColor: '#FFFFFF',
6
+ foregroundImage: './assets/adaptive-icon.png',
7
+ },
8
+ package: 'com.psksx1.holperstorybook',
9
+ },
10
+ assetBundlePatterns: ['**/*'],
11
+ extra: {
12
+ eas: {
13
+ projectId: 'e8ab23b4-2f23-4e60-86da-4be317b4600e',
14
+ },
15
+ storybookEnabled: process.env.STORYBOOK_ENABLED,
16
+ },
17
+ icon: './assets/icon.png',
18
+ ios: {
19
+ bundleIdentifier: 'holper.storybook.app',
20
+ config: {
21
+ googleMapsApiKey: 'AIzaSyC7J4gQm2F8i2EakaQluAY19uYhkQLWCDk',
22
+ },
23
+ infoPlist: {
24
+ ITSAppUsesNonExemptEncryption: false,
25
+ },
26
+ privacyManifests: {
27
+ NSPrivacyAccessedAPITypes: [
28
+ {
29
+ NSPrivacyAccessedAPIType: 'NSPrivacyAccessedAPICategoryUserDefaults',
30
+ NSPrivacyAccessedAPITypeReasons: ['CA92.1'],
31
+ },
32
+ ],
33
+ },
34
+ },
35
+ name: 'Holper Storybook',
36
+ orientation: 'portrait',
37
+ owner: 'holper',
38
+ platforms: ['ios', 'android'],
39
+ plugins: [
40
+ 'expo-font',
41
+ [
42
+ 'expo-image-picker',
43
+ {
44
+ photosPermission: 'The app need access to your photos.',
45
+ },
46
+ ],
47
+ [
48
+ 'expo-camera',
49
+ {
50
+ cameraPermission: 'Allow $(PRODUCT_NAME) to access your camera',
51
+ microphonePermission: 'Allow $(PRODUCT_NAME) to access your microphone',
52
+ recordAudioAndroid: true,
53
+ },
54
+ ],
55
+ [
56
+ 'expo-media-library',
57
+ {
58
+ isAccessMediaLocationEnabled: true,
59
+ photosPermission: 'Allow $(PRODUCT_NAME) to access your photos.',
60
+ savePhotosPermission: 'Allow $(PRODUCT_NAME) to save photos.',
61
+ },
62
+ ],
63
+ ],
64
+ slug: 'holper-storybook',
65
+ splash: {
66
+ backgroundColor: '#ffffff',
67
+ image: './assets/splash.png',
68
+ resizeMode: 'contain',
69
+ },
70
+ updates: {
71
+ fallbackToCacheTimeout: 0,
72
+ },
73
+ version: '1.0.0',
74
+ web: {
75
+ favicon: './assets/favicon.png',
76
+ },
77
+ });
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,7 @@
1
+ module.exports = (api) => {
2
+ api.cache(true);
3
+ return {
4
+ plugins: ['@babel/plugin-transform-class-static-block'],
5
+ presets: ['babel-preset-expo'],
6
+ };
7
+ };
package/build.sh ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+
3
+ rm -rf ./lib
4
+ mkdir lib
5
+ mkdir lib/assets
6
+ cp -r ./components/. ./lib/components
7
+ cp -r ./configs/. ./lib/configs/
8
+ cp -r ./hooks/. ./lib/hooks/
9
+ cp -r ./assets/fonts/. ./lib/assets/fonts
10
+ cp ./index.js ./lib
11
+ npm publish
@@ -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
- import { Colors, borderRadius } from '../../configs/constants';
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.lightblue,
41
- backgroundColor: Colors.lightblue,
42
- shadowColor: Colors.lightblue,
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
- import { Colors, borderRadius } from '../../configs/constants';
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 React from 'react';
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
- Platform,
9
- KeyboardAvoidingView,
9
+ View,
10
10
  } from 'react-native';
11
- import PropTypes from 'prop-types';
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
- animationType='slide'
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='large'
42
+ size="large"
49
43
  align={alertMode && !closeButton ? 'center' : 'left'}
50
- weight='semiBold'
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='fit'
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='small'
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: 0.4,
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
+ });