103 lines
3.1 KiB
Dart
103 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class CustomAlertDialog extends StatelessWidget {
|
|
final String title;
|
|
final String content;
|
|
final String cancelText;
|
|
final String confirmText;
|
|
final VoidCallback? onCancel;
|
|
final VoidCallback? onConfirm;
|
|
|
|
const CustomAlertDialog({
|
|
Key? key,
|
|
required this.title,
|
|
required this.content,
|
|
this.cancelText = "取消",
|
|
this.confirmText = "确定",
|
|
this.onCancel,
|
|
this.onConfirm,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Dialog(
|
|
backgroundColor: Colors.transparent,
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(5),
|
|
),
|
|
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
SizedBox(height: 20),
|
|
Text(
|
|
title,
|
|
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(height: 20),
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 30),
|
|
child: Text(
|
|
content,
|
|
style: const TextStyle(fontSize: 16, color: Colors.black45),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
|
|
const SizedBox(height: 20),
|
|
const Divider(height: 1),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: InkWell(
|
|
onTap: () {
|
|
Navigator.of(context).pop();
|
|
onCancel?.call();
|
|
},
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
alignment: Alignment.center,
|
|
child: Text(
|
|
cancelText,
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.w500,
|
|
color: Colors.black,
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Container(width: 1, height: 48, color: Colors.grey[300]),
|
|
Expanded(
|
|
child: InkWell(
|
|
onTap: () {
|
|
Navigator.of(context).pop();
|
|
onConfirm?.call();
|
|
},
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
alignment: Alignment.center,
|
|
child: Text(
|
|
confirmText,
|
|
style: const TextStyle(
|
|
color: Color(0xFF3874F6),
|
|
fontWeight: FontWeight.w500,
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|