|
|
@@ -29,6 +29,7 @@ class ToastUtil {
|
|
|
|
|
|
static Future<void> errorAlert(
|
|
|
String message, {
|
|
|
+ String? title,
|
|
|
String confirmText = '确定',
|
|
|
BuildContext? context,
|
|
|
}) async {
|
|
|
@@ -42,15 +43,24 @@ class ToastUtil {
|
|
|
context: dialogContext,
|
|
|
builder: (BuildContext context) {
|
|
|
return AlertDialog(
|
|
|
- title: const Text(
|
|
|
- '错误',
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 20,
|
|
|
- fontWeight: FontWeight.bold,
|
|
|
- color: Colors.red,
|
|
|
- ),
|
|
|
+ title: Row(
|
|
|
+ children: [
|
|
|
+ Icon(Icons.error_outline, color: Colors.red, size: 24),
|
|
|
+ SizedBox(width: 10),
|
|
|
+ Text(
|
|
|
+ title ?? '错误',
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 20,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ color: Colors.red,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ content: ConstrainedBox(
|
|
|
+ constraints: BoxConstraints(minWidth: 350),
|
|
|
+ child: Text(message, style: const TextStyle(fontSize: 16)),
|
|
|
),
|
|
|
- content: Text(message, style: const TextStyle(fontSize: 16)),
|
|
|
backgroundColor: Colors.white,
|
|
|
shape: RoundedRectangleBorder(
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
@@ -58,28 +68,32 @@ class ToastUtil {
|
|
|
elevation: 24,
|
|
|
actions: <Widget>[
|
|
|
Container(
|
|
|
+ width: double.infinity,
|
|
|
padding: const EdgeInsets.only(right: 0, bottom: 0),
|
|
|
alignment: Alignment.centerRight,
|
|
|
- child: ElevatedButton(
|
|
|
- style: ElevatedButton.styleFrom(
|
|
|
- backgroundColor: Colors.red,
|
|
|
- shape: RoundedRectangleBorder(
|
|
|
- borderRadius: BorderRadius.circular(8),
|
|
|
- ),
|
|
|
- padding: const EdgeInsets.symmetric(
|
|
|
- horizontal: 24,
|
|
|
- vertical: 12,
|
|
|
+ child: SizedBox(
|
|
|
+ width: 120,
|
|
|
+ child: ElevatedButton(
|
|
|
+ style: ElevatedButton.styleFrom(
|
|
|
+ backgroundColor: Colors.red,
|
|
|
+ shape: RoundedRectangleBorder(
|
|
|
+ borderRadius: BorderRadius.circular(8),
|
|
|
+ ),
|
|
|
+ padding: const EdgeInsets.symmetric(
|
|
|
+ horizontal: 16,
|
|
|
+ vertical: 10,
|
|
|
+ ),
|
|
|
),
|
|
|
- ),
|
|
|
- onPressed: () {
|
|
|
- Navigator.of(context).pop(true); // 返回true表示确认
|
|
|
- },
|
|
|
- child: Text(
|
|
|
- confirmText,
|
|
|
- style: const TextStyle(
|
|
|
- fontSize: 16,
|
|
|
- fontWeight: FontWeight.w500,
|
|
|
- color: Colors.white,
|
|
|
+ onPressed: () {
|
|
|
+ Navigator.of(context).pop(true); // 返回true表示确认
|
|
|
+ },
|
|
|
+ child: Text(
|
|
|
+ confirmText,
|
|
|
+ style: const TextStyle(
|
|
|
+ fontSize: 16,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ color: Colors.white,
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
),
|
|
|
@@ -93,6 +107,7 @@ class ToastUtil {
|
|
|
static Future<void> confirm(
|
|
|
String message,
|
|
|
VoidCallback onConfirm, {
|
|
|
+ String? title,
|
|
|
String confirmText = '确定',
|
|
|
String cancelText = '取消',
|
|
|
BuildContext? context,
|
|
|
@@ -106,15 +121,24 @@ class ToastUtil {
|
|
|
context: dialogContext,
|
|
|
builder: (BuildContext context) {
|
|
|
return AlertDialog(
|
|
|
- title: const Text(
|
|
|
- '确认',
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 20,
|
|
|
- fontWeight: FontWeight.bold,
|
|
|
- color: Colors.blue,
|
|
|
- ),
|
|
|
+ title: Row(
|
|
|
+ children: [
|
|
|
+ const Icon(Icons.help_outline, color: Colors.blue, size: 24),
|
|
|
+ const SizedBox(width: 10),
|
|
|
+ Text(
|
|
|
+ title ?? '提示',
|
|
|
+ style: const TextStyle(
|
|
|
+ fontSize: 20,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ color: Colors.blue,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ content: ConstrainedBox(
|
|
|
+ constraints: BoxConstraints(minWidth: 350),
|
|
|
+ child: Text(message, style: const TextStyle(fontSize: 16)),
|
|
|
),
|
|
|
- content: Text(message, style: const TextStyle(fontSize: 16)),
|
|
|
backgroundColor: Colors.white,
|
|
|
shape: RoundedRectangleBorder(
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
@@ -122,59 +146,68 @@ class ToastUtil {
|
|
|
elevation: 24,
|
|
|
actions: <Widget>[
|
|
|
Container(
|
|
|
+ width: double.infinity,
|
|
|
padding: const EdgeInsets.only(right: 0, bottom: 0),
|
|
|
alignment: Alignment.centerRight,
|
|
|
- child: Row(
|
|
|
- mainAxisSize: MainAxisSize.min,
|
|
|
- children: [
|
|
|
- OutlinedButton(
|
|
|
- style: OutlinedButton.styleFrom(
|
|
|
- side: const BorderSide(color: Colors.grey),
|
|
|
- shape: RoundedRectangleBorder(
|
|
|
- borderRadius: BorderRadius.circular(8),
|
|
|
- ),
|
|
|
- padding: const EdgeInsets.symmetric(
|
|
|
- horizontal: 20,
|
|
|
- vertical: 12,
|
|
|
+ child: SizedBox(
|
|
|
+ width: 200,
|
|
|
+ child: Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
+ children: [
|
|
|
+ SizedBox(
|
|
|
+ width: 80,
|
|
|
+ child: OutlinedButton(
|
|
|
+ style: OutlinedButton.styleFrom(
|
|
|
+ side: const BorderSide(color: Colors.grey),
|
|
|
+ shape: RoundedRectangleBorder(
|
|
|
+ borderRadius: BorderRadius.circular(8),
|
|
|
+ ),
|
|
|
+ padding: const EdgeInsets.symmetric(
|
|
|
+ horizontal: 12,
|
|
|
+ vertical: 8,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ onPressed: () {
|
|
|
+ Navigator.of(context).pop(false); // 取消,关闭确认框
|
|
|
+ },
|
|
|
+ child: Text(
|
|
|
+ cancelText,
|
|
|
+ style: const TextStyle(
|
|
|
+ fontSize: 16,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ color: Colors.grey,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
- onPressed: () {
|
|
|
- Navigator.of(context).pop(false); // 取消,关闭确认框
|
|
|
- },
|
|
|
- child: Text(
|
|
|
- cancelText,
|
|
|
- style: const TextStyle(
|
|
|
- fontSize: 16,
|
|
|
- fontWeight: FontWeight.w500,
|
|
|
- color: Colors.grey,
|
|
|
+ SizedBox(
|
|
|
+ width: 80,
|
|
|
+ child: ElevatedButton(
|
|
|
+ style: ElevatedButton.styleFrom(
|
|
|
+ backgroundColor: Colors.blue,
|
|
|
+ shape: RoundedRectangleBorder(
|
|
|
+ borderRadius: BorderRadius.circular(8),
|
|
|
+ ),
|
|
|
+ padding: const EdgeInsets.symmetric(
|
|
|
+ horizontal: 12,
|
|
|
+ vertical: 8,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ onPressed: () {
|
|
|
+ Navigator.of(context).pop(true); // 确定,关闭确认框
|
|
|
+ },
|
|
|
+ child: Text(
|
|
|
+ confirmText,
|
|
|
+ style: const TextStyle(
|
|
|
+ fontSize: 16,
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ color: Colors.white,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
- ),
|
|
|
- const SizedBox(width: 12),
|
|
|
- ElevatedButton(
|
|
|
- style: ElevatedButton.styleFrom(
|
|
|
- backgroundColor: Colors.blue,
|
|
|
- shape: RoundedRectangleBorder(
|
|
|
- borderRadius: BorderRadius.circular(8),
|
|
|
- ),
|
|
|
- padding: const EdgeInsets.symmetric(
|
|
|
- horizontal: 20,
|
|
|
- vertical: 12,
|
|
|
- ),
|
|
|
- ),
|
|
|
- onPressed: () {
|
|
|
- Navigator.of(context).pop(true); // 确定,关闭确认框
|
|
|
- },
|
|
|
- child: Text(
|
|
|
- confirmText,
|
|
|
- style: const TextStyle(
|
|
|
- fontSize: 16,
|
|
|
- fontWeight: FontWeight.w500,
|
|
|
- color: Colors.white,
|
|
|
- ),
|
|
|
- ),
|
|
|
- ),
|
|
|
- ],
|
|
|
+ ],
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
],
|