UNPKG

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