相册预览界面增加删除按钮和二次确认
This commit is contained in:
@@ -201,6 +201,8 @@ fun GalleryScreen(
|
||||
|
||||
// 大图查看对话框(支持双指缩放)
|
||||
if (selectedImageUri != null) {
|
||||
var showDeleteConfirm by remember { mutableStateOf(false) }
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = { selectedImageUri = null },
|
||||
title = {
|
||||
@@ -210,10 +212,19 @@ fun GalleryScreen(
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text("图片预览")
|
||||
Row {
|
||||
IconButton(onClick = { showDeleteConfirm = true }) {
|
||||
Icon(
|
||||
Icons.Default.Delete,
|
||||
contentDescription = "删除",
|
||||
tint = Color.Red
|
||||
)
|
||||
}
|
||||
IconButton(onClick = { selectedImageUri = null }) {
|
||||
Icon(Icons.Default.Close, contentDescription = "关闭")
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
text = {
|
||||
ZoomableImage(
|
||||
@@ -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("取消")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user