UNPKG

948 BJavaScriptView Raw
1// @flow
2
3import {
4 NativeModules,
5} from 'react-native';
6
7const { ExponentImagePicker } = NativeModules;
8
9type ImageInfo = {|
10 uri: string,
11 width: number,
12 height: number,
13|};
14
15type ImageResult =
16 {| cancelled: true |} |
17 {| cancelled: false |} & ImageInfo;
18
19
20type ImageLibraryOptions = {
21 allowsEditing?: boolean,
22 aspect?: [number, number],
23 quality?: number,
24};
25
26export async function launchImageLibraryAsync(
27 options?: ImageLibraryOptions,
28): Promise<ImageResult> {
29 if (!options || typeof options !== 'object') {
30 options = {};
31 }
32 return ExponentImagePicker.launchImageLibraryAsync(options);
33}
34
35
36type CameraOptions = {
37 allowsEditing?: boolean,
38 aspect?: [number, number],
39 quality?: number,
40};
41
42export async function launchCameraAsync(
43 options?: CameraOptions,
44): Promise<ImageResult> {
45 if (!options || typeof options !== 'object') {
46 options = {};
47 }
48 return ExponentImagePicker.launchCameraAsync(options);
49}