- core/localization: 新增约 60 个翻译键(含参数化方法),中英双语覆盖 - shared/widgets: CommonDialog 默认参数国际化 - features/home: 完成页操作步骤指引、状态栏串口连接状态、程序列表状态标签 - features/programs: 表头状态列、表单验证提示、导入/模板操作反馈、删除确认(参数化) - features/program_detail: 步骤列表/表单标题、删除确认、速度档位显示(参数化) - features/device: run_state_provider 错误消息改为错误码 - features/settings: 升级页、密码面板、语言面板、U盘导入面板、串口配置面板全部替换 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
93 lines
2.4 KiB
Dart
93 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// 确认对话框组件
|
|
class CommonDialog {
|
|
/// 显示确认对话框
|
|
static Future<bool?> showConfirm({
|
|
required BuildContext context,
|
|
required String title,
|
|
required String content,
|
|
String confirmText = 'Confirm',
|
|
String cancelText = 'Cancel',
|
|
bool isDestructive = false,
|
|
}) {
|
|
return showDialog<bool>(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: Text(title),
|
|
content: Text(content),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context, false),
|
|
child: Text(cancelText),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () => Navigator.pop(context, true),
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: isDestructive ? Colors.red : null,
|
|
),
|
|
child: Text(confirmText),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 显示信息对话框
|
|
static Future<void> showInfo({
|
|
required BuildContext context,
|
|
required String title,
|
|
required String content,
|
|
String confirmText = 'Confirm',
|
|
}) {
|
|
return showDialog(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: Text(title),
|
|
content: Text(content),
|
|
actions: [
|
|
ElevatedButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
child: Text(confirmText),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 显示输入对话框
|
|
static Future<String?> showInput({
|
|
required BuildContext context,
|
|
required String title,
|
|
String? hintText,
|
|
String? initialValue,
|
|
String confirmText = 'Confirm',
|
|
String cancelText = 'Cancel',
|
|
}) {
|
|
final controller = TextEditingController(text: initialValue);
|
|
|
|
return showDialog<String>(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
title: Text(title),
|
|
content: TextField(
|
|
decoration: InputDecoration(
|
|
hintText: hintText,
|
|
border: const OutlineInputBorder(),
|
|
),
|
|
controller: controller,
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
child: Text(cancelText),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () => Navigator.pop(context, controller.text),
|
|
child: Text(confirmText),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |