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("取消") + } + } + ) + } } }