@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 +1 -1
- package/src/components/FileInput.tsx +18 -9
package/package.json
CHANGED
|
@@ -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
|
|
155
|
-
|
|
156
|
-
}
|
|
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
|
|
164
|
-
|
|
165
|
-
}
|
|
169
|
+
if (onOpenGallery) {
|
|
170
|
+
onOpenGallery(() => onPress('library'))
|
|
171
|
+
} else {
|
|
172
|
+
onPress('library')
|
|
173
|
+
}
|
|
174
|
+
|
|
166
175
|
},
|
|
167
176
|
...alertProps?.options[2],
|
|
168
177
|
},
|