type errors
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import {Image as RNImage, Share as RNShare} from 'react-native'
|
||||
import {Image} from 'react-native-image-crop-picker'
|
||||
import uuid from 'react-native-uuid'
|
||||
import {
|
||||
cacheDirectory,
|
||||
@@ -20,12 +19,13 @@ import RNFetchBlob from 'rn-fetch-blob'
|
||||
import {POST_IMG_MAX} from '#/lib/constants'
|
||||
import {logger} from '#/logger'
|
||||
import {isAndroid, isIOS} from '#/platform/detection'
|
||||
import {Dimensions} from './types'
|
||||
import {type PickerImage} from './picker.shared'
|
||||
import {type Dimensions} from './types'
|
||||
|
||||
export async function compressIfNeeded(
|
||||
img: Image,
|
||||
img: PickerImage,
|
||||
maxSize: number = 1000000,
|
||||
): Promise<Image> {
|
||||
): Promise<PickerImage> {
|
||||
const origUri = `file://${img.path}`
|
||||
if (img.size < maxSize) {
|
||||
return img
|
||||
@@ -166,7 +166,10 @@ interface DoResizeOpts {
|
||||
maxSize: number
|
||||
}
|
||||
|
||||
async function doResize(localUri: string, opts: DoResizeOpts): Promise<Image> {
|
||||
async function doResize(
|
||||
localUri: string,
|
||||
opts: DoResizeOpts,
|
||||
): Promise<PickerImage> {
|
||||
// We need to get the dimensions of the image before we resize it. Previously, the library we used allowed us to enter
|
||||
// a "max size", and it would do the "best possible size" calculation for us.
|
||||
// Now instead, we have to supply the final dimensions to the manipulation function instead.
|
||||
|
||||
@@ -3,11 +3,11 @@ import {
|
||||
getInfoAsync,
|
||||
readDirectoryAsync,
|
||||
} from 'expo-file-system'
|
||||
import ExpoImageCropTool from 'expo-image-crop-tool'
|
||||
|
||||
import {compressIfNeeded} from './manip'
|
||||
import {CropperOptions} from './types'
|
||||
import {RNImage} from './picker.shared'
|
||||
import ExpoImageCropTool from 'expo-image-crop-tool'
|
||||
import {type PickerImage} from './picker.shared'
|
||||
import {type CropperOptions} from './types'
|
||||
|
||||
async function getFile() {
|
||||
const imagesDir = documentDirectory!
|
||||
@@ -35,11 +35,11 @@ async function getFile() {
|
||||
})
|
||||
}
|
||||
|
||||
export async function openPicker(): Promise<RNImage[]> {
|
||||
export async function openPicker(): Promise<PickerImage[]> {
|
||||
return [await getFile()]
|
||||
}
|
||||
|
||||
export async function openCamera(): Promise<RNImage> {
|
||||
export async function openCamera(): Promise<PickerImage> {
|
||||
return await getFile()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
ImagePickerOptions,
|
||||
type ImagePickerOptions,
|
||||
launchImageLibraryAsync,
|
||||
MediaTypeOptions,
|
||||
} from 'expo-image-picker'
|
||||
@@ -9,7 +9,7 @@ import {t} from '@lingui/macro'
|
||||
import * as Toast from '#/view/com/util/Toast'
|
||||
import {getDataUriSize} from './util'
|
||||
|
||||
export type RNImage = {
|
||||
export type PickerImage = {
|
||||
mime: string
|
||||
height: number
|
||||
width: number
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import ExpoImageCropTool, {OpenCropperOptions} from 'expo-image-crop-tool'
|
||||
import {ImagePickerOptions, launchCameraAsync} from 'expo-image-picker'
|
||||
import ExpoImageCropTool, {type OpenCropperOptions} from 'expo-image-crop-tool'
|
||||
import {type ImagePickerOptions, launchCameraAsync} from 'expo-image-picker'
|
||||
|
||||
export {openPicker, type RNImage} from './picker.shared'
|
||||
export {openPicker, type PickerImage as RNImage} from './picker.shared'
|
||||
|
||||
export async function openCamera(customOpts: ImagePickerOptions) {
|
||||
const opts: ImagePickerOptions = {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/// <reference lib="dom" />
|
||||
|
||||
import {CameraOpts, CropperOptions} from './types'
|
||||
import {unstable__openModal} from '#/state/modals'
|
||||
import {RNImage} from './picker.shared'
|
||||
import {type PickerImage} from './picker.shared'
|
||||
import {type CameraOpts, type CropperOptions} from './types'
|
||||
|
||||
export {openPicker, type RNImage} from './picker.shared'
|
||||
export {openPicker, type PickerImage as RNImage} from './picker.shared'
|
||||
|
||||
export async function openCamera(_opts: CameraOpts): Promise<RNImage> {
|
||||
export async function openCamera(_opts: CameraOpts): Promise<PickerImage> {
|
||||
// const mediaType = opts.mediaType || 'photo' TODO
|
||||
throw new Error('TODO')
|
||||
}
|
||||
|
||||
export async function openCropper(opts: CropperOptions): Promise<RNImage> {
|
||||
export async function openCropper(opts: CropperOptions): Promise<PickerImage> {
|
||||
// TODO handle more opts
|
||||
return new Promise((resolve, reject) => {
|
||||
unstable__openModal({
|
||||
@@ -23,7 +23,7 @@ export async function openCropper(opts: CropperOptions): Promise<RNImage> {
|
||||
: undefined,
|
||||
aspect: opts.webAspectRatio,
|
||||
circular: opts.webCircularCrop,
|
||||
onSelect: (img?: RNImage) => {
|
||||
onSelect: (img?: PickerImage) => {
|
||||
if (img) {
|
||||
resolve(img)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user