82 lines
2.5 KiB
Dart
82 lines
2.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class DeleteConfirmationDialog extends StatelessWidget {
|
|
final VoidCallback onConfirm; // 确认删除的回调
|
|
final VoidCallback onCancel; // 取消的回调
|
|
|
|
const DeleteConfirmationDialog({
|
|
super.key,
|
|
required this.onConfirm,
|
|
required this.onCancel,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AlertDialog(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
contentPadding: const EdgeInsets.all(10),
|
|
title: const Column(
|
|
children: [
|
|
Text(
|
|
'确定删除此草稿?',
|
|
style: TextStyle(color: Colors.white, fontSize: 20),
|
|
),
|
|
SizedBox(height: 10),
|
|
],
|
|
),
|
|
content: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Divider(color: Colors.grey),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Container(
|
|
width: 100,
|
|
child: TextButton(
|
|
style: TextButton.styleFrom(padding: EdgeInsets.zero),
|
|
onPressed: onCancel, // 调用取消回调
|
|
child: const Text('取消',
|
|
style: TextStyle(color: Colors.white, fontSize: 18)),
|
|
),
|
|
),
|
|
Container(
|
|
height: 30,
|
|
child: const VerticalDivider(
|
|
thickness: 1,
|
|
color: Colors.grey,
|
|
),
|
|
),
|
|
Container(
|
|
width: 100,
|
|
child: TextButton(
|
|
style: TextButton.styleFrom(padding: EdgeInsets.zero),
|
|
onPressed: () {
|
|
onConfirm(); // 调用确认回调
|
|
Navigator.of(context).pop(); // 关闭弹窗
|
|
},
|
|
child: ShaderMask(
|
|
shaderCallback: (Rect bounds) {
|
|
return const LinearGradient(
|
|
colors: [
|
|
Color(0xFF80DAA4),
|
|
Color(0xFF79DDED),
|
|
],
|
|
).createShader(bounds);
|
|
},
|
|
child: const Text('确定',
|
|
style: TextStyle(color: Colors.white, fontSize: 18)),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
backgroundColor: const Color(0xFF1F212E),
|
|
);
|
|
}
|
|
}
|