Merge branch 'fix-banner-cropper' of https://github.com/piotrpalek/social-app into piotrpalek-fix-banner-cropper

This commit is contained in:
Paul Frazee 2024-05-06 15:30:54 -07:00
commit e1940983a3
6 changed files with 93 additions and 51 deletions

View file

@ -1,8 +1,9 @@
import {
Image as RNImage,
openCamera as openCameraFn,
openCropper as openCropperFn,
Image as RNImage,
} from 'react-native-image-crop-picker'
import {CameraOpts, CropperOptions} from './types'
export {openPicker} from './picker.shared'

View file

@ -1,7 +1,8 @@
/// <reference lib="dom" />
import {CameraOpts, CropperOptions} from './types'
import {Image as RNImage} from 'react-native-image-crop-picker'
import {CameraOpts, CropperOptions} from './types'
export {openPicker} from './picker.shared'
import {unstable__openModal} from '#/state/modals'
@ -12,15 +13,17 @@ export async function openCamera(_opts: CameraOpts): Promise<RNImage> {
export async function openCropper(opts: CropperOptions): Promise<RNImage> {
// TODO handle more opts
return new Promise((resolve, reject) => {
return new Promise(resolve => {
unstable__openModal({
name: 'crop-image',
uri: opts.path,
dimensions:
opts.height && opts.width
? {width: opts.width, height: opts.height}
: undefined,
onSelect: (img?: RNImage) => {
if (img) {
resolve(img)
} else {
reject(new Error('Canceled'))
}
},
})