Bluesky app fork with some witchin' additions 馃挮
at main 50 lines 1.2 kB view raw
1import {type ImagePickerOptions, launchCameraAsync} from 'expo-image-picker' 2import ExpoImageCropTool, { 3 type OpenCropperOptions, 4} from '@bsky.app/expo-image-crop-tool' 5import {t} from '@lingui/core/macro' 6 7export { 8 openPicker, 9 openUnifiedPicker, 10 type PickerImage as RNImage, 11} from './picker.shared' 12 13export async function openCamera(customOpts: ImagePickerOptions) { 14 const opts: ImagePickerOptions = { 15 mediaTypes: 'images', 16 ...customOpts, 17 } 18 const res = await launchCameraAsync(opts) 19 20 if (!res || !res.assets) { 21 throw new Error('Camera was closed before taking a photo') 22 } 23 24 const asset = res?.assets[0] 25 26 return { 27 path: asset.uri, 28 mime: asset.mimeType ?? 'image/jpeg', 29 size: asset.fileSize ?? 0, 30 width: asset.width, 31 height: asset.height, 32 } 33} 34 35export async function openCropper(opts: OpenCropperOptions) { 36 const item = await ExpoImageCropTool.openCropperAsync({ 37 doneButtonText: t`Done`, 38 cancelButtonText: t`Cancel`, 39 ...opts, 40 format: 'jpeg', 41 }) 42 43 return { 44 path: item.path, 45 mime: item.mimeType, 46 size: item.size, 47 width: item.width, 48 height: item.height, 49 } 50}