f18b15241a
* Add modal state provider, replace usage except methods * Replace easy spots * Fix sticky spots * Replace final usages * Memorize context objects * Add more warnings
36 lines
889 B
TypeScript
36 lines
889 B
TypeScript
/// <reference lib="dom" />
|
|
|
|
import {CameraOpts, CropperOptions} from './types'
|
|
import {RootStoreModel} from 'state/index'
|
|
import {Image as RNImage} from 'react-native-image-crop-picker'
|
|
export {openPicker} from './picker.shared'
|
|
import {unstable__openModal} from '#/state/modals'
|
|
|
|
export async function openCamera(
|
|
_store: RootStoreModel,
|
|
_opts: CameraOpts,
|
|
): Promise<RNImage> {
|
|
// const mediaType = opts.mediaType || 'photo' TODO
|
|
throw new Error('TODO')
|
|
}
|
|
|
|
export async function openCropper(
|
|
_store: RootStoreModel,
|
|
opts: CropperOptions,
|
|
): Promise<RNImage> {
|
|
// TODO handle more opts
|
|
return new Promise((resolve, reject) => {
|
|
unstable__openModal({
|
|
name: 'crop-image',
|
|
uri: opts.path,
|
|
onSelect: (img?: RNImage) => {
|
|
if (img) {
|
|
resolve(img)
|
|
} else {
|
|
reject(new Error('Canceled'))
|
|
}
|
|
},
|
|
})
|
|
})
|
|
}
|