@codeleap/mobile 1.9.13 → 1.9.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/mobile",
3
- "version": "1.9.13",
3
+ "version": "1.9.14",
4
4
  "main": "src/index.ts",
5
5
  "author": "Paulo Henrique De Souza <paulosouza300272@gmail.com>",
6
6
  "license": "UNLICENSED",
@@ -37,8 +37,8 @@ export type FileInputProps = {
37
37
  alertProps?: Parameters<typeof OSAlert.ask>[0]
38
38
  pickerOptions?: Partial<Options>
39
39
  required?: boolean
40
- onOpenCamera?: () => Promise<void>
41
- onOpenGallery?: () => Promise<void>
40
+ onOpenCamera?: (resolve: (() => void)) => Promise<void>
41
+ onOpenGallery?: (resolve: (() => void)) => Promise<void>
42
42
  onError?: (error: any) => void
43
43
  }
44
44
 
@@ -140,7 +140,10 @@ export const FileInput = forwardRef<
140
140
  parsePickerData(data),
141
141
  ])
142
142
  }
143
-
143
+ const onPress = (open?: 'camera' | 'library') => {
144
+ const call = open === 'camera' ? 'openCamera' : 'openPicker'
145
+ ImageCropPicker[call](mergedOptions).then(handlePickerResolution)
146
+ }
144
147
  const openFilePicker = async () => {
145
148
  if (type === 'image') {
146
149
  OSAlert.ask({
@@ -151,18 +154,24 @@ export const FileInput = forwardRef<
151
154
  {
152
155
  text: alertProps?.options?.[0]?.text || 'Camera',
153
156
  onPress: () => {
154
- onOpenCamera().then(() => {
155
- ImageCropPicker.openCamera(mergedOptions).then(handlePickerResolution)
156
- }).catch(onError)
157
+ if (onOpenCamera) {
158
+ onOpenCamera(() => onPress('camera'))
159
+ } else {
160
+ onPress('camera')
161
+ }
162
+
157
163
  },
158
164
  ...alertProps?.options[1],
159
165
  },
160
166
  {
161
167
  text: 'Library',
162
168
  onPress: () => {
163
- onOpenGallery().then(() => {
164
- ImageCropPicker.openPicker(mergedOptions).then(handlePickerResolution)
165
- }).catch(onError)
169
+ if (onOpenGallery) {
170
+ onOpenGallery(() => onPress('library'))
171
+ } else {
172
+ onPress('library')
173
+ }
174
+
166
175
  },
167
176
  ...alertProps?.options[2],
168
177
  },