@chem-po/react-native 0.0.29 → 0.0.31

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 (215) hide show
  1. package/lib/commonjs/components/button/DeleteButton.js +7 -8
  2. package/lib/commonjs/components/button/DeleteButton.js.map +1 -1
  3. package/lib/commonjs/components/button/LoadingButton.js +3 -3
  4. package/lib/commonjs/components/button/LoadingButton.js.map +1 -1
  5. package/lib/commonjs/components/button/Toggle.js +21 -17
  6. package/lib/commonjs/components/button/Toggle.js.map +1 -1
  7. package/lib/commonjs/components/form/Form.js +30 -4
  8. package/lib/commonjs/components/form/Form.js.map +1 -1
  9. package/lib/commonjs/components/form/FormFooter.js +3 -2
  10. package/lib/commonjs/components/form/FormFooter.js.map +1 -1
  11. package/lib/commonjs/components/form/input/Editable.js +50 -73
  12. package/lib/commonjs/components/form/input/Editable.js.map +1 -1
  13. package/lib/commonjs/components/form/input/StandaloneInput.js.map +1 -1
  14. package/lib/commonjs/components/form/input/common/InputClearButton.js +2 -1
  15. package/lib/commonjs/components/form/input/common/InputClearButton.js.map +1 -1
  16. package/lib/commonjs/components/form/input/date/index.js +23 -10
  17. package/lib/commonjs/components/form/input/date/index.js.map +1 -1
  18. package/lib/commonjs/components/form/input/datetime/index.js +32 -11
  19. package/lib/commonjs/components/form/input/datetime/index.js.map +1 -1
  20. package/lib/commonjs/components/form/input/file/index.js +27 -27
  21. package/lib/commonjs/components/form/input/file/index.js.map +1 -1
  22. package/lib/commonjs/components/form/input/hooks/useInputStyles.js +5 -6
  23. package/lib/commonjs/components/form/input/hooks/useInputStyles.js.map +1 -1
  24. package/lib/commonjs/components/form/input/input.js +3 -3
  25. package/lib/commonjs/components/form/input/input.js.map +1 -1
  26. package/lib/commonjs/components/form/input/multipleSelect/index.js +41 -24
  27. package/lib/commonjs/components/form/input/multipleSelect/index.js.map +1 -1
  28. package/lib/commonjs/components/form/input/select/index.js +1 -1
  29. package/lib/commonjs/components/form/input/select/index.js.map +1 -1
  30. package/lib/commonjs/components/form/input/socialMedia/index.js +3 -2
  31. package/lib/commonjs/components/form/input/socialMedia/index.js.map +1 -1
  32. package/lib/commonjs/components/form/input/text/AutoResizeTextarea.js +1 -6
  33. package/lib/commonjs/components/form/input/text/AutoResizeTextarea.js.map +1 -1
  34. package/lib/commonjs/components/form/input/text/index.js +5 -3
  35. package/lib/commonjs/components/form/input/text/index.js.map +1 -1
  36. package/lib/commonjs/components/form/input/text/textarea.js +3 -13
  37. package/lib/commonjs/components/form/input/text/textarea.js.map +1 -1
  38. package/lib/commonjs/components/form/input/text/useWebAutoResize.js +7 -8
  39. package/lib/commonjs/components/form/input/text/useWebAutoResize.js.map +1 -1
  40. package/lib/commonjs/components/form/input/time/index.js +2 -1
  41. package/lib/commonjs/components/form/input/time/index.js.map +1 -1
  42. package/lib/commonjs/components/form/view/file.js +21 -12
  43. package/lib/commonjs/components/form/view/file.js.map +1 -1
  44. package/lib/commonjs/components/form/view/index.js +29 -18
  45. package/lib/commonjs/components/form/view/index.js.map +1 -1
  46. package/lib/commonjs/components/form/view/multipleSelect.js +17 -13
  47. package/lib/commonjs/components/form/view/multipleSelect.js.map +1 -1
  48. package/lib/commonjs/components/form/view/select.js +20 -9
  49. package/lib/commonjs/components/form/view/select.js.map +1 -1
  50. package/lib/commonjs/components/form/view/styles.js +0 -3
  51. package/lib/commonjs/components/form/view/styles.js.map +1 -1
  52. package/lib/commonjs/components/image/ImageViewModal.js +18 -15
  53. package/lib/commonjs/components/image/ImageViewModal.js.map +1 -1
  54. package/lib/commonjs/components/layout/CollapseHorizontal.js +84 -0
  55. package/lib/commonjs/components/layout/CollapseHorizontal.js.map +1 -0
  56. package/lib/commonjs/components/loading/LoadingImage.js +20 -13
  57. package/lib/commonjs/components/loading/LoadingImage.js.map +1 -1
  58. package/lib/commonjs/components/theme/colorMode/DarkModeToggle.js +2 -1
  59. package/lib/commonjs/components/theme/colorMode/DarkModeToggle.js.map +1 -1
  60. package/lib/commonjs/contexts/root.js +6 -6
  61. package/lib/commonjs/contexts/root.js.map +1 -1
  62. package/lib/commonjs/index.js +11 -0
  63. package/lib/commonjs/index.js.map +1 -1
  64. package/lib/commonjs/types/forms.js +6 -0
  65. package/lib/commonjs/types/forms.js.map +1 -0
  66. package/lib/commonjs/types/index.js +17 -0
  67. package/lib/commonjs/types/index.js.map +1 -0
  68. package/lib/module/components/button/DeleteButton.js +8 -9
  69. package/lib/module/components/button/DeleteButton.js.map +1 -1
  70. package/lib/module/components/button/LoadingButton.js +4 -4
  71. package/lib/module/components/button/LoadingButton.js.map +1 -1
  72. package/lib/module/components/button/Toggle.js +24 -20
  73. package/lib/module/components/button/Toggle.js.map +1 -1
  74. package/lib/module/components/form/Form.js +31 -5
  75. package/lib/module/components/form/Form.js.map +1 -1
  76. package/lib/module/components/form/FormFooter.js +4 -3
  77. package/lib/module/components/form/FormFooter.js.map +1 -1
  78. package/lib/module/components/form/input/Editable.js +51 -74
  79. package/lib/module/components/form/input/Editable.js.map +1 -1
  80. package/lib/module/components/form/input/StandaloneInput.js.map +1 -1
  81. package/lib/module/components/form/input/common/InputClearButton.js +3 -2
  82. package/lib/module/components/form/input/common/InputClearButton.js.map +1 -1
  83. package/lib/module/components/form/input/date/index.js +24 -11
  84. package/lib/module/components/form/input/date/index.js.map +1 -1
  85. package/lib/module/components/form/input/datetime/index.js +33 -12
  86. package/lib/module/components/form/input/datetime/index.js.map +1 -1
  87. package/lib/module/components/form/input/file/index.js +29 -29
  88. package/lib/module/components/form/input/file/index.js.map +1 -1
  89. package/lib/module/components/form/input/hooks/useInputStyles.js +5 -6
  90. package/lib/module/components/form/input/hooks/useInputStyles.js.map +1 -1
  91. package/lib/module/components/form/input/input.js +3 -3
  92. package/lib/module/components/form/input/input.js.map +1 -1
  93. package/lib/module/components/form/input/multipleSelect/index.js +41 -24
  94. package/lib/module/components/form/input/multipleSelect/index.js.map +1 -1
  95. package/lib/module/components/form/input/select/index.js +1 -1
  96. package/lib/module/components/form/input/select/index.js.map +1 -1
  97. package/lib/module/components/form/input/socialMedia/index.js +4 -3
  98. package/lib/module/components/form/input/socialMedia/index.js.map +1 -1
  99. package/lib/module/components/form/input/text/AutoResizeTextarea.js +1 -6
  100. package/lib/module/components/form/input/text/AutoResizeTextarea.js.map +1 -1
  101. package/lib/module/components/form/input/text/index.js +6 -4
  102. package/lib/module/components/form/input/text/index.js.map +1 -1
  103. package/lib/module/components/form/input/text/textarea.js +4 -14
  104. package/lib/module/components/form/input/text/textarea.js.map +1 -1
  105. package/lib/module/components/form/input/text/useWebAutoResize.js +7 -8
  106. package/lib/module/components/form/input/text/useWebAutoResize.js.map +1 -1
  107. package/lib/module/components/form/input/time/index.js +3 -2
  108. package/lib/module/components/form/input/time/index.js.map +1 -1
  109. package/lib/module/components/form/view/file.js +15 -6
  110. package/lib/module/components/form/view/file.js.map +1 -1
  111. package/lib/module/components/form/view/index.js +19 -8
  112. package/lib/module/components/form/view/index.js.map +1 -1
  113. package/lib/module/components/form/view/multipleSelect.js +18 -14
  114. package/lib/module/components/form/view/multipleSelect.js.map +1 -1
  115. package/lib/module/components/form/view/select.js +20 -9
  116. package/lib/module/components/form/view/select.js.map +1 -1
  117. package/lib/module/components/form/view/styles.js +0 -3
  118. package/lib/module/components/form/view/styles.js.map +1 -1
  119. package/lib/module/components/image/ImageViewModal.js +20 -17
  120. package/lib/module/components/image/ImageViewModal.js.map +1 -1
  121. package/lib/module/components/layout/CollapseHorizontal.js +76 -0
  122. package/lib/module/components/layout/CollapseHorizontal.js.map +1 -0
  123. package/lib/module/components/loading/LoadingImage.js +21 -14
  124. package/lib/module/components/loading/LoadingImage.js.map +1 -1
  125. package/lib/module/components/theme/colorMode/DarkModeToggle.js +3 -2
  126. package/lib/module/components/theme/colorMode/DarkModeToggle.js.map +1 -1
  127. package/lib/module/contexts/root.js +6 -6
  128. package/lib/module/contexts/root.js.map +1 -1
  129. package/lib/module/index.js +1 -0
  130. package/lib/module/index.js.map +1 -1
  131. package/lib/module/types/forms.js +2 -0
  132. package/lib/module/types/forms.js.map +1 -0
  133. package/lib/module/types/index.js +2 -0
  134. package/lib/module/types/index.js.map +1 -0
  135. package/lib/typescript/components/button/DeleteButton.d.ts.map +1 -1
  136. package/lib/typescript/components/button/LoadingButton.d.ts.map +1 -1
  137. package/lib/typescript/components/button/Toggle.d.ts +5 -2
  138. package/lib/typescript/components/button/Toggle.d.ts.map +1 -1
  139. package/lib/typescript/components/form/Form.d.ts.map +1 -1
  140. package/lib/typescript/components/form/FormFooter.d.ts.map +1 -1
  141. package/lib/typescript/components/form/input/Editable.d.ts +2 -2
  142. package/lib/typescript/components/form/input/Editable.d.ts.map +1 -1
  143. package/lib/typescript/components/form/input/StandaloneInput.d.ts +5 -14
  144. package/lib/typescript/components/form/input/StandaloneInput.d.ts.map +1 -1
  145. package/lib/typescript/components/form/input/common/InputClearButton.d.ts.map +1 -1
  146. package/lib/typescript/components/form/input/date/index.d.ts.map +1 -1
  147. package/lib/typescript/components/form/input/datetime/index.d.ts.map +1 -1
  148. package/lib/typescript/components/form/input/file/index.d.ts +2 -1
  149. package/lib/typescript/components/form/input/file/index.d.ts.map +1 -1
  150. package/lib/typescript/components/form/input/hooks/useInputStyles.d.ts +3 -6
  151. package/lib/typescript/components/form/input/hooks/useInputStyles.d.ts.map +1 -1
  152. package/lib/typescript/components/form/input/multipleSelect/index.d.ts.map +1 -1
  153. package/lib/typescript/components/form/input/socialMedia/index.d.ts.map +1 -1
  154. package/lib/typescript/components/form/input/text/AutoResizeTextarea.d.ts.map +1 -1
  155. package/lib/typescript/components/form/input/text/index.d.ts.map +1 -1
  156. package/lib/typescript/components/form/input/text/textarea.d.ts +2 -2
  157. package/lib/typescript/components/form/input/text/textarea.d.ts.map +1 -1
  158. package/lib/typescript/components/form/input/text/useWebAutoResize.d.ts +2 -3
  159. package/lib/typescript/components/form/input/text/useWebAutoResize.d.ts.map +1 -1
  160. package/lib/typescript/components/form/input/time/index.d.ts.map +1 -1
  161. package/lib/typescript/components/form/view/file.d.ts.map +1 -1
  162. package/lib/typescript/components/form/view/index.d.ts +3 -2
  163. package/lib/typescript/components/form/view/index.d.ts.map +1 -1
  164. package/lib/typescript/components/form/view/multipleSelect.d.ts.map +1 -1
  165. package/lib/typescript/components/form/view/select.d.ts +2 -1
  166. package/lib/typescript/components/form/view/select.d.ts.map +1 -1
  167. package/lib/typescript/components/form/view/styles.d.ts +0 -3
  168. package/lib/typescript/components/form/view/styles.d.ts.map +1 -1
  169. package/lib/typescript/components/image/ImageViewModal.d.ts.map +1 -1
  170. package/lib/typescript/components/layout/CollapseHorizontal.d.ts +9 -0
  171. package/lib/typescript/components/layout/CollapseHorizontal.d.ts.map +1 -0
  172. package/lib/typescript/components/loading/LoadingImage.d.ts +4 -1
  173. package/lib/typescript/components/loading/LoadingImage.d.ts.map +1 -1
  174. package/lib/typescript/components/theme/colorMode/DarkModeToggle.d.ts.map +1 -1
  175. package/lib/typescript/index.d.ts +1 -0
  176. package/lib/typescript/index.d.ts.map +1 -1
  177. package/lib/typescript/types/forms.d.ts +5 -0
  178. package/lib/typescript/types/forms.d.ts.map +1 -0
  179. package/lib/typescript/types/index.d.ts +2 -0
  180. package/lib/typescript/types/index.d.ts.map +1 -0
  181. package/package.json +4 -4
  182. package/src/components/button/DeleteButton.tsx +12 -25
  183. package/src/components/button/LoadingButton.tsx +4 -5
  184. package/src/components/button/Toggle.tsx +24 -19
  185. package/src/components/form/Form.tsx +31 -11
  186. package/src/components/form/FormFooter.tsx +6 -5
  187. package/src/components/form/input/Editable.tsx +52 -92
  188. package/src/components/form/input/StandaloneInput.tsx +4 -13
  189. package/src/components/form/input/common/InputClearButton.tsx +4 -3
  190. package/src/components/form/input/date/index.tsx +24 -11
  191. package/src/components/form/input/datetime/index.tsx +37 -15
  192. package/src/components/form/input/file/index.tsx +34 -35
  193. package/src/components/form/input/hooks/useInputStyles.ts +10 -7
  194. package/src/components/form/input/input.tsx +2 -2
  195. package/src/components/form/input/multipleSelect/index.tsx +47 -36
  196. package/src/components/form/input/select/index.tsx +1 -1
  197. package/src/components/form/input/socialMedia/index.tsx +6 -5
  198. package/src/components/form/input/text/AutoResizeTextarea.tsx +1 -5
  199. package/src/components/form/input/text/index.tsx +7 -5
  200. package/src/components/form/input/text/textarea.tsx +4 -16
  201. package/src/components/form/input/text/useWebAutoResize.tsx +9 -8
  202. package/src/components/form/input/time/index.tsx +4 -3
  203. package/src/components/form/view/file.tsx +9 -5
  204. package/src/components/form/view/index.tsx +26 -7
  205. package/src/components/form/view/multipleSelect.tsx +11 -9
  206. package/src/components/form/view/select.tsx +12 -3
  207. package/src/components/form/view/styles.ts +0 -3
  208. package/src/components/image/ImageViewModal.tsx +56 -50
  209. package/src/components/layout/CollapseHorizontal.tsx +92 -0
  210. package/src/components/loading/LoadingImage.tsx +19 -19
  211. package/src/components/theme/colorMode/DarkModeToggle.tsx +4 -3
  212. package/src/contexts/root.tsx +6 -6
  213. package/src/index.ts +1 -0
  214. package/src/types/forms.ts +14 -0
  215. package/src/types/index.ts +1 -0
@@ -1,8 +1,13 @@
1
1
  import { useScreen, useToast } from '@chem-po/react'
2
2
  import { Ionicons } from '@expo/vector-icons'
3
3
  import React, { useCallback, useEffect, useMemo, useState } from 'react'
4
- import { Image, Modal, StyleSheet, TouchableOpacity, View } from 'react-native'
5
- import { Gesture, GestureDetector, GestureHandlerRootView } from 'react-native-gesture-handler'
4
+ import { Image, Modal, SafeAreaView, StyleSheet, View } from 'react-native'
5
+ import {
6
+ Gesture,
7
+ GestureDetector,
8
+ GestureHandlerRootView,
9
+ Pressable,
10
+ } from 'react-native-gesture-handler'
6
11
  import Animated, { useAnimatedStyle, useSharedValue, withSpring } from 'react-native-reanimated'
7
12
  import { downloadFile } from '../../utils/downloadFile'
8
13
  import { LoadingLogo } from '../loading/Loading'
@@ -53,11 +58,13 @@ export const ImageViewModal: React.FC<ImageViewModalProps> = ({
53
58
  }, [screenHeight, screenWidth, imageSize, loading])
54
59
 
55
60
  const onLoadStart = useCallback(() => setLoading(true), [])
56
- const onLoad = useCallback((e: any) => {
57
- const { width: naturalWidth, height: naturalHeight } = e.nativeEvent.source
58
- setImageSize({ width: naturalWidth, height: naturalHeight })
59
- setLoading(false)
60
- }, [])
61
+ const onLoad = useCallback(() => {
62
+ if (!src) return
63
+ Image.getSize(src, (width, height) => {
64
+ setImageSize({ width, height })
65
+ setLoading(false)
66
+ })
67
+ }, [src])
61
68
 
62
69
  // Reset zoom and pan when modal opens/closes
63
70
  const resetTransform = useCallback(() => {
@@ -203,53 +210,51 @@ export const ImageViewModal: React.FC<ImageViewModalProps> = ({
203
210
 
204
211
  return (
205
212
  <Modal visible={isOpen} transparent animationType="fade" onRequestClose={onClose}>
206
- <GestureHandlerRootView style={styles.gestureRoot}>
207
- <View style={styles.modalOverlay}>
208
- <TouchableOpacity
209
- style={styles.backgroundTouchable}
210
- activeOpacity={1}
211
- onPress={onClose}
212
- />
213
- <View style={styles.contentContainer}>
214
- <GestureDetector gesture={combinedGestures}>
215
- <Animated.View
216
- style={[
217
- styles.imageContainer,
218
- {
219
- width,
220
- height,
221
- opacity: loading ? 0 : 1,
222
- },
223
- animatedStyle,
224
- ]}>
225
- <Image
226
- source={src ? { uri: src } : undefined}
227
- style={styles.image}
228
- onLoadStart={onLoadStart}
229
- onLoad={onLoad}
230
- resizeMode="contain"
231
- />
232
- </Animated.View>
233
- </GestureDetector>
213
+ <SafeAreaView style={{ flex: 1 }}>
214
+ <GestureHandlerRootView style={styles.gestureRoot}>
215
+ <View style={styles.modalOverlay}>
216
+ <Pressable style={styles.backgroundTouchable} onPress={onClose} />
217
+ <View style={styles.contentContainer}>
218
+ <GestureDetector gesture={combinedGestures}>
219
+ <Animated.View
220
+ style={[
221
+ styles.imageContainer,
222
+ {
223
+ width,
224
+ height,
225
+ opacity: loading ? 0 : 1,
226
+ },
227
+ animatedStyle,
228
+ ]}>
229
+ <Image
230
+ source={src ? { uri: src } : undefined}
231
+ style={styles.image}
232
+ onLoadStart={onLoadStart}
233
+ onLoad={onLoad}
234
+ resizeMode="contain"
235
+ />
236
+ </Animated.View>
237
+ </GestureDetector>
234
238
 
235
- {withDownload && (
236
- <TouchableOpacity style={styles.downloadButton} onPress={() => void handleDownload()}>
237
- <Ionicons name="download" size={24} color="white" />
238
- </TouchableOpacity>
239
- )}
239
+ {withDownload && (
240
+ <Pressable style={styles.downloadButton} onPress={() => void handleDownload()}>
241
+ <Ionicons name="download" size={24} color="white" />
242
+ </Pressable>
243
+ )}
240
244
 
241
- <TouchableOpacity style={styles.closeButton} onPress={onClose}>
242
- <Ionicons name="close" size={24} color="white" />
243
- </TouchableOpacity>
245
+ <Pressable style={styles.closeButton} onPress={onClose}>
246
+ <Ionicons name="close" size={24} color="white" />
247
+ </Pressable>
244
248
 
245
- {loading || !src ? (
246
- <View style={styles.loadingContainer}>
247
- <LoadingLogo isLoading={loading} size={70} />
248
- </View>
249
- ) : null}
249
+ {loading || !src ? (
250
+ <View style={styles.loadingContainer}>
251
+ <LoadingLogo isLoading={loading} size={70} />
252
+ </View>
253
+ ) : null}
254
+ </View>
250
255
  </View>
251
- </View>
252
- </GestureHandlerRootView>
256
+ </GestureHandlerRootView>
257
+ </SafeAreaView>
253
258
  </Modal>
254
259
  )
255
260
  }
@@ -303,6 +308,7 @@ const styles = StyleSheet.create({
303
308
  },
304
309
  loadingContainer: {
305
310
  ...StyleSheet.absoluteFillObject,
311
+ pointerEvents: 'none',
306
312
  justifyContent: 'center',
307
313
  alignItems: 'center',
308
314
  },
@@ -0,0 +1,92 @@
1
+ import React, { useCallback, useLayoutEffect, useRef, useState } from 'react'
2
+ import { LayoutChangeEvent, StyleProp, View, ViewStyle } from 'react-native'
3
+ import Animated, {
4
+ useAnimatedStyle,
5
+ useSharedValue,
6
+ withSequence,
7
+ withTiming,
8
+ } from 'react-native-reanimated'
9
+
10
+ export const CollapseHorizontal = ({
11
+ children,
12
+ in: isIn,
13
+ duration = 200,
14
+ style,
15
+ }: {
16
+ children: React.ReactNode
17
+ in: boolean
18
+ duration?: number
19
+ style?: StyleProp<ViewStyle>
20
+ }) => {
21
+ const contentRef = useRef<View>(null)
22
+ const [contentWidth, setContentWidth] = useState(0)
23
+ const width = useSharedValue(0)
24
+ const opacity = useSharedValue(0)
25
+ const handleLayout = useCallback(
26
+ (event: LayoutChangeEvent) => {
27
+ setContentWidth(event.nativeEvent.layout.width)
28
+ // Initialize width if component is initially visible
29
+ if (isIn && width.value === 0) {
30
+ width.value = event.nativeEvent.layout.width
31
+ opacity.value = 1
32
+ }
33
+ },
34
+ [isIn, width, opacity],
35
+ )
36
+
37
+ useLayoutEffect(() => {
38
+ if (contentRef.current) {
39
+ contentRef.current.measure((_x, _y, width) => {
40
+ setContentWidth(width)
41
+ })
42
+ }
43
+ }, [])
44
+
45
+ React.useEffect(() => {
46
+ if (isIn) {
47
+ // Fade in: width first, then opacity
48
+ width.value = withTiming(contentWidth, {
49
+ duration,
50
+ })
51
+ opacity.value = withSequence(
52
+ withTiming(0, { duration: 0 }), // Reset opacity
53
+ withTiming(1, {
54
+ duration,
55
+ }),
56
+ )
57
+ } else {
58
+ // Fade out: opacity first, then width
59
+ opacity.value = withTiming(0, {
60
+ duration,
61
+ })
62
+ width.value = withSequence(
63
+ withTiming(width.value, { duration: 0 }), // Ensure we start from current width
64
+ withTiming(0, {
65
+ duration,
66
+ }),
67
+ )
68
+ }
69
+ }, [isIn, contentWidth, duration, width, opacity])
70
+
71
+ const animatedStyle = useAnimatedStyle(() => ({
72
+ width: width.value,
73
+ opacity: opacity.value,
74
+ }))
75
+
76
+ return (
77
+ <Animated.View
78
+ style={[
79
+ {
80
+ overflow: 'hidden',
81
+ pointerEvents: isIn ? 'auto' : 'none',
82
+ },
83
+ animatedStyle,
84
+ ]}>
85
+ <View style={{ position: 'absolute', width: 'auto' }}>
86
+ <View style={style} onLayout={handleLayout} ref={contentRef}>
87
+ {children}
88
+ </View>
89
+ </View>
90
+ </Animated.View>
91
+ )
92
+ }
@@ -1,14 +1,15 @@
1
1
  import { useMounted } from '@chem-po/react'
2
2
  import { Ionicons } from '@expo/vector-icons'
3
3
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
4
- import { DimensionValue, Image, StyleSheet, TouchableOpacity, View, ViewStyle } from 'react-native'
4
+ import { DimensionValue, Image, StyleSheet, View, ViewStyle } from 'react-native'
5
+ import { Pressable } from 'react-native-gesture-handler'
5
6
  import { ImageViewModal } from '../image/ImageViewModal'
6
7
  import { LoadingLogo } from './Loading'
7
8
 
8
9
  export interface LoadingImageProps {
9
10
  src?: string | null
10
11
  loadingOverride?: boolean
11
- onLoad?: (e: any) => void
12
+ onLoad?: (dims: { width: number; height: number }) => void
12
13
  filename?: string
13
14
  fileType?: string
14
15
  withFullView?: boolean
@@ -41,12 +42,13 @@ export const LoadingImage = ({
41
42
  const [viewing, setViewing] = useState(false)
42
43
  const mounted = useMounted(100)
43
44
 
44
- const handleImageLoad = useCallback(
45
- (e: any) => {
46
- if (onLoad) onLoad(e)
47
- },
48
- [onLoad],
49
- )
45
+ const handleImageLoad = useCallback(() => {
46
+ if (onLoad && src) {
47
+ Image.getSize(src, (width, height) => {
48
+ onLoad({ width, height })
49
+ })
50
+ }
51
+ }, [onLoad, src])
50
52
 
51
53
  const [prevSrc, setPrevSrc] = useState(src)
52
54
  useEffect(() => {
@@ -65,7 +67,6 @@ export const LoadingImage = ({
65
67
  opacity: src && !loading ? 1 : 0,
66
68
  },
67
69
  ]}
68
- // onLoadStart={() => setImageLoading(true)}
69
70
  onLoadEnd={() => setImageLoading(false)}
70
71
  onLoad={handleImageLoad}
71
72
  resizeMode={src ? 'cover' : 'contain'}
@@ -86,23 +87,22 @@ export const LoadingImage = ({
86
87
  {!withFullView || buttonFullView ? (
87
88
  ImageComponent
88
89
  ) : (
89
- <TouchableOpacity
90
- activeOpacity={0.9}
90
+ <Pressable
91
91
  onPress={() => setViewing(true)}
92
92
  style={{
93
- width: width ? undefined : '100%',
94
- height: height ? undefined : '100%',
93
+ position: 'absolute',
94
+ top: 0,
95
+ left: 0,
96
+ right: 0,
97
+ bottom: 0,
95
98
  }}>
96
99
  {ImageComponent}
97
- </TouchableOpacity>
100
+ </Pressable>
98
101
  )}
99
102
  {buttonFullView && (
100
- <TouchableOpacity
101
- style={styles.fullViewButton}
102
- onPress={() => setViewing(true)}
103
- activeOpacity={0.7}>
103
+ <Pressable style={styles.fullViewButton} onPress={() => setViewing(true)}>
104
104
  <Ionicons name="expand" size={20} color="white" style={styles.fullViewIcon} />
105
- </TouchableOpacity>
105
+ </Pressable>
106
106
  )}
107
107
  <View
108
108
  style={[
@@ -1,7 +1,8 @@
1
1
  import { useBackgroundColor, useIconColor, useTheme } from '@chem-po/react'
2
2
  import { Ionicons } from '@expo/vector-icons'
3
3
  import React from 'react'
4
- import { StyleSheet, TouchableOpacity, View } from 'react-native'
4
+ import { StyleSheet, View } from 'react-native'
5
+ import { Pressable } from 'react-native-gesture-handler'
5
6
 
6
7
  export const DarkModeToggle = () => {
7
8
  const { colorMode, toggleColorMode } = useTheme()
@@ -11,7 +12,7 @@ export const DarkModeToggle = () => {
11
12
  const iconName = isDark ? 'moon' : 'sunny'
12
13
  const bg = useBackgroundColor(100)
13
14
  return (
14
- <TouchableOpacity
15
+ <Pressable
15
16
  onPress={toggleColorMode}
16
17
  style={[
17
18
  styles.button,
@@ -20,7 +21,7 @@ export const DarkModeToggle = () => {
20
21
  },
21
22
  ]}>
22
23
  <Ionicons name={iconName} size={16} color={iconColor} />
23
- </TouchableOpacity>
24
+ </Pressable>
24
25
  )
25
26
  }
26
27
 
@@ -28,14 +28,14 @@ const createPaperTheme = (
28
28
  return {
29
29
  dark: colorMode === 'dark',
30
30
  colors: {
31
- primary: colors.accent[200],
31
+ primary: colors.accent[300],
32
32
  onPrimary: colors.text[900],
33
- primaryContainer: colors.accent[500],
34
- onPrimaryContainer: colors.text[300],
33
+ primaryContainer: colors.accent[800],
34
+ onPrimaryContainer: colors.text[150],
35
35
 
36
36
  secondary: colors.background[150],
37
37
  onSecondary: colors.text[100],
38
- secondaryContainer: colors.background[50],
38
+ secondaryContainer: colors.accent[950],
39
39
  onSecondaryContainer: colors.text[150],
40
40
 
41
41
  tertiary: colors.accent[600],
@@ -53,7 +53,7 @@ const createPaperTheme = (
53
53
  surface: colors.background[100],
54
54
  onSurface: colors.text[100],
55
55
  surfaceVariant: colors.background[200],
56
- onSurfaceVariant: colors.text[250],
56
+ onSurfaceVariant: colors.text[300],
57
57
  outline: colors.text[500],
58
58
  outlineVariant: colors.accent[300],
59
59
 
@@ -92,7 +92,7 @@ const createPaperTheme = (
92
92
  ...fonts?.bodyMedium,
93
93
  },
94
94
  bodySmall: {
95
- fontSize: 15,
95
+ fontSize: 16,
96
96
  ...fonts?.bodySmall,
97
97
  },
98
98
  },
package/src/index.ts CHANGED
@@ -3,3 +3,4 @@ export * from './constants'
3
3
  export * from './contexts'
4
4
  export * from './hooks'
5
5
  export * from './store'
6
+ export * from './types'
@@ -0,0 +1,14 @@
1
+ import { BaseCustomInput, BaseCustomInputProps } from '@chem-po/react'
2
+ import { TextStyle, ViewStyle } from 'react-native'
3
+
4
+ export type CustomInput<Value, InputStyle = TextStyle> = BaseCustomInput<
5
+ Value,
6
+ ViewStyle,
7
+ InputStyle
8
+ >
9
+
10
+ export type CustomInputProps<Value, InputStyle = TextStyle> = BaseCustomInputProps<
11
+ Value,
12
+ ViewStyle,
13
+ InputStyle
14
+ >
@@ -0,0 +1 @@
1
+ export * from './forms'