File tree Expand file tree Collapse file tree 3 files changed +7
-0
lines changed
packages/react-native-image-picker/src/ImagePicker Expand file tree Collapse file tree 3 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ const ImagePicker = ({
2222 onCancel,
2323 onFail,
2424 onGrantFail,
25+ onDelete,
2526 cameraRationale = {
2627 title : '获取摄像头权限' ,
2728 message : '若不允许,您将无法使用摄像头功能' ,
@@ -72,6 +73,7 @@ const ImagePicker = ({
7273 cameraRationale,
7374 libraryRationale,
7475 selectionLimit,
76+ onDelete,
7577 } ) ;
7678 const savePhotos = ( url = '' ) => {
7779 Alert . alert ( '保存图片' , '' , [
Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ export declare type ImagePickerProps = PropsWithChildren<{
3333 onGrantFail ?: ( ) => void ;
3434 /** 预览时长按图片保存回调 */
3535 onSave ?: ( ( image : any ) => void ) | undefined ;
36+ /** 删除图片回调 */
37+ onDelete ?: ( files : string [ ] ) => void ;
3638 /** 打开相册授权的文本 */
3739 libraryRationale ?: Rationale ;
3840 /** 打开摄像头授权的文本 */
@@ -86,4 +88,5 @@ export type useImageProps = {
8688 onGrantFail ?: ( ) => void ;
8789 /** 其他图片自定义配置,详细参考react-native-image-picker的option配置 */
8890 options ?: CameraOptions ;
91+ onDelete ?: ( files : string [ ] ) => void ;
8992} ;
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ export default function useImagePicker({
3636 onGrantFail,
3737 cameraRationale,
3838 libraryRationale,
39+ onDelete,
3940} : ImagePickerProps ) {
4041 /** 打开相册或者摄像头的ActionSheet */
4142 const [ launchVisible , { setTrue : setLaunchVisibleTrue , setFalse : setLaunchVisibleFalse } ] = useBoolean ( false ) ;
@@ -174,6 +175,7 @@ export default function useImagePicker({
174175 // 刷新页面
175176 setRefresh ( ! refresh ) ;
176177 uploadFinish ?.( undefined ) ;
178+ onDelete ?.( currentImgSource ) ;
177179 } ;
178180
179181 // 打开上传
You can’t perform that action at this time.
0 commit comments