mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1/// <reference lib="dom" />
2
3import {CameraOpts, CropperOptions} from './types'
4import {RootStoreModel} from 'state/index'
5import {Image as RNImage} from 'react-native-image-crop-picker'
6export {openPicker} from './picker.shared'
7
8export async function openCamera(
9 _store: RootStoreModel,
10 _opts: CameraOpts,
11): Promise<RNImage> {
12 // const mediaType = opts.mediaType || 'photo' TODO
13 throw new Error('TODO')
14}
15
16export async function openCropper(
17 store: RootStoreModel,
18 opts: CropperOptions,
19): Promise<RNImage> {
20 // TODO handle more opts
21 return new Promise((resolve, reject) => {
22 store.shell.openModal({
23 name: 'crop-image',
24 uri: opts.path,
25 onSelect: (img?: RNImage) => {
26 if (img) {
27 resolve(img)
28 } else {
29 reject(new Error('Canceled'))
30 }
31 },
32 })
33 })
34}