92 lines
2.6 KiB
Dart
92 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class ConfigDialog extends StatelessWidget {
|
|
final String title;
|
|
final String content;
|
|
final TextStyle? contentStyle;
|
|
final String confirmText;
|
|
final String cancelText;
|
|
final bool showCancel;
|
|
final void Function()? onConfirm;
|
|
final void Function()? onCancel;
|
|
|
|
const ConfigDialog({
|
|
super.key,
|
|
this.title = "",
|
|
required this.content,
|
|
this.contentStyle,
|
|
this.confirmText = '确定',
|
|
this.cancelText = '取消',
|
|
this.showCancel = true,
|
|
this.onConfirm,
|
|
this.onCancel,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Color borderColor = Theme.of(context).colorScheme.surfaceContainer;
|
|
return AlertDialog(
|
|
actionsPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 5),
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0),
|
|
elevation: 0,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
title: Visibility(
|
|
visible: title.isNotEmpty,
|
|
child: Container(
|
|
margin: const EdgeInsets.only(bottom: 15),
|
|
child: Text(
|
|
title,
|
|
textAlign: TextAlign.center,
|
|
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w700),
|
|
),
|
|
),
|
|
),
|
|
content: Container(
|
|
padding: const EdgeInsets.only(bottom: 20, left: 20, right: 20),
|
|
decoration: BoxDecoration(
|
|
border: Border(
|
|
bottom: BorderSide(width: 1, color: borderColor),
|
|
),
|
|
),
|
|
child: Text(content, textAlign: TextAlign.center, style: contentStyle),
|
|
),
|
|
actions: [
|
|
SizedBox(
|
|
height: 40,
|
|
child: Row(
|
|
children: [
|
|
if (showCancel) ...[
|
|
Expanded(
|
|
child: TextButton(
|
|
onPressed: onCancel,
|
|
child: Text(
|
|
cancelText,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
width: 1,
|
|
margin: EdgeInsets.symmetric(horizontal: 10),
|
|
color: borderColor,
|
|
),
|
|
],
|
|
Expanded(
|
|
child: TextButton(
|
|
onPressed: onConfirm,
|
|
child: Text(
|
|
confirmText,
|
|
style: TextStyle(
|
|
color: Theme.of(context).primaryColor,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|