From 871f6637acee753386a276092c714c26d4690f92 Mon Sep 17 00:00:00 2001 From: Developer Date: Sat, 18 Apr 2026 12:14:06 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B8=E5=86=8C=E9=A2=84=E8=A7=88=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E5=A2=9E=E5=8A=A0=E5=88=A0=E9=99=A4=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E5=92=8C=E4=BA=8C=E6=AC=A1=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../camera/ui/gallery/GalleryScreen.kt | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/inspection/camera/ui/gallery/GalleryScreen.kt b/app/src/main/java/com/inspection/camera/ui/gallery/GalleryScreen.kt index a7b8d95..3058b93 100644 --- a/app/src/main/java/com/inspection/camera/ui/gallery/GalleryScreen.kt +++ b/app/src/main/java/com/inspection/camera/ui/gallery/GalleryScreen.kt @@ -201,6 +201,8 @@ fun GalleryScreen( // 大图查看对话框(支持双指缩放) if (selectedImageUri != null) { + var showDeleteConfirm by remember { mutableStateOf(false) } + AlertDialog( onDismissRequest = { selectedImageUri = null }, title = { @@ -210,8 +212,17 @@ fun GalleryScreen( verticalAlignment = Alignment.CenterVertically ) { Text("图片预览") - IconButton(onClick = { selectedImageUri = null }) { - Icon(Icons.Default.Close, contentDescription = "关闭") + Row { + IconButton(onClick = { showDeleteConfirm = true }) { + Icon( + Icons.Default.Delete, + contentDescription = "删除", + tint = Color.Red + ) + } + IconButton(onClick = { selectedImageUri = null }) { + Icon(Icons.Default.Close, contentDescription = "关闭") + } } } }, @@ -229,6 +240,32 @@ fun GalleryScreen( } } ) + + // 删除二次确认对话框 + if (showDeleteConfirm) { + AlertDialog( + onDismissRequest = { showDeleteConfirm = false }, + title = { Text("确认删除") }, + text = { Text("确定要删除这张图片吗?删除后无法恢复。") }, + confirmButton = { + TextButton(onClick = { + scope.launch { + deleteImage(context, selectedImageUri!!) + images = loadImagesFromGallery(context) + selectedImageUri = null + showDeleteConfirm = false + } + }) { + Text("确定删除", color = Color.Red) + } + }, + dismissButton = { + TextButton(onClick = { showDeleteConfirm = false }) { + Text("取消") + } + } + ) + } } }