Skip to content

Commit

Permalink
fix: 【i agepicker】增加onDelete
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenlingasMx committed Jul 11, 2023
1 parent 078c091 commit 43ec91f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const ImagePicker = ({
onCancel,
onFail,
onGrantFail,
onDelete,
cameraRationale = {
title: '获取摄像头权限',
message: '若不允许,您将无法使用摄像头功能',
Expand Down Expand Up @@ -72,6 +73,7 @@ const ImagePicker = ({
cameraRationale,
libraryRationale,
selectionLimit,
onDelete,
});
const savePhotos = (url = '') => {
Alert.alert('保存图片', '', [
Expand Down
3 changes: 3 additions & 0 deletions packages/react-native-image-picker/src/ImagePicker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export declare type ImagePickerProps = PropsWithChildren<{
onGrantFail?: () => void;
/** 预览时长按图片保存回调 */
onSave?: ((image: any) => void) | undefined;
/** 删除图片回调 */
onDelete?: (files: string[]) => void;
/** 打开相册授权的文本 */
libraryRationale?: Rationale;
/** 打开摄像头授权的文本 */
Expand Down Expand Up @@ -86,4 +88,5 @@ export type useImageProps = {
onGrantFail?: () => void;
/** 其他图片自定义配置,详细参考react-native-image-picker的option配置 */
options?: CameraOptions;
onDelete?: (files: string[]) => void;
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function useImagePicker({
onGrantFail,
cameraRationale,
libraryRationale,
onDelete,
}: ImagePickerProps) {
/** 打开相册或者摄像头的ActionSheet */
const [launchVisible, { setTrue: setLaunchVisibleTrue, setFalse: setLaunchVisibleFalse }] = useBoolean(false);
Expand Down Expand Up @@ -174,6 +175,7 @@ export default function useImagePicker({
// 刷新页面
setRefresh(!refresh);
uploadFinish?.(undefined);
onDelete?.(currentImgSource);
};

// 打开上传
Expand Down

0 comments on commit 43ec91f

Please sign in to comment.