-
Notifications
You must be signed in to change notification settings - Fork 6
/
SystemImagePicker.js
37 lines (33 loc) · 1.11 KB
/
SystemImagePicker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* Created by lvbingru on 2/29/15.
*/
import {NativeModules, Platform, ImagePickerIOS} from 'react-native';
const ImagePicker = NativeModules.BBImagePicker;
const SystemImagePicker = {
canUserCamera : ImagePicker.canUseCamera,
// option
// sourceType : the picker source (library, album, camera)
// savePhoto : if true, do save photo when take picture
// allowsEditing : if true, can edit image after pick
// videoMode : if true, do video things or open videos
// videoMaximumDuration : in second
// -- videoQuality : ios(0-2,high to low) android(0.0-1.0 low to high)
openCameraDialog: (option) => {
return new Promise((resolve, reject)=>{
ImagePicker.openCamera(option||{}, (uri, width, height)=>{
if (width && height) {
resolve({uri, width, height})
}
else {
resolve({uri})
}
}, reject);
});
},
// option
// groupTypes : 'All', 'Album', 'SavedPhotos', 'Library'
getAssetsGroups : (option={groupTypes:'All'})=>{
return ImagePicker.getAssetsGroups && ImagePicker.getAssetsGroups(option)
},
};
export default SystemImagePicker;