- 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>
196 lines
6.3 KiB
Dart
196 lines
6.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../../../core/localization/app_localizations.dart';
|
|
import '../../../core/theme/app_theme.dart';
|
|
import '../../../shared/widgets/common_button.dart';
|
|
import '../widgets/language_panel.dart';
|
|
import '../widgets/password_panel.dart';
|
|
|
|
/// 设置页菜单
|
|
enum _SettingsMenu { upgrade, language, password }
|
|
|
|
/// 系统设置页面
|
|
class SettingsPage extends ConsumerStatefulWidget {
|
|
const SettingsPage({super.key});
|
|
|
|
@override
|
|
ConsumerState<SettingsPage> createState() => _SettingsPageState();
|
|
}
|
|
|
|
class _SettingsPageState extends ConsumerState<SettingsPage> {
|
|
String _currentVersion = 'V1.0.0';
|
|
_SettingsMenu _currentMenu = _SettingsMenu.upgrade;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final l10n = AppLocalizations.of(context);
|
|
|
|
return Scaffold(
|
|
body: Container(
|
|
color: AppTheme.backgroundColor,
|
|
child: Row(
|
|
children: [
|
|
// 左侧导航菜单
|
|
SizedBox(
|
|
width: 280,
|
|
child: Container(
|
|
color: Colors.white,
|
|
child: Column(
|
|
children: [
|
|
// 设置标题
|
|
Container(
|
|
height: 60,
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: AppTheme.primaryColor.withValues(alpha: 0.1),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Icon(Icons.settings,
|
|
color: AppTheme.primaryColor, size: 24),
|
|
const SizedBox(width: 12),
|
|
Text(
|
|
l10n?.settings ?? '系统设置',
|
|
style: TextStyle(
|
|
color: AppTheme.primaryColor,
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
// 软件升级
|
|
_buildMenuItem(
|
|
icon: Icons.system_update,
|
|
title: l10n?.upgrade ?? '软件升级',
|
|
selected: _currentMenu == _SettingsMenu.upgrade,
|
|
onTap: () => setState(
|
|
() => _currentMenu = _SettingsMenu.upgrade),
|
|
),
|
|
// 语言设置
|
|
_buildMenuItem(
|
|
icon: Icons.language,
|
|
title: l10n?.language ?? '语言设置',
|
|
selected: _currentMenu == _SettingsMenu.language,
|
|
onTap: () => setState(
|
|
() => _currentMenu = _SettingsMenu.language),
|
|
),
|
|
// 密码修改
|
|
_buildMenuItem(
|
|
icon: Icons.lock,
|
|
title: l10n?.password ?? '密码修改',
|
|
selected: _currentMenu == _SettingsMenu.password,
|
|
onTap: () => setState(
|
|
() => _currentMenu = _SettingsMenu.password),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
// 右侧内容区域
|
|
Expanded(
|
|
child: Container(
|
|
margin: const EdgeInsets.all(16),
|
|
padding: const EdgeInsets.all(24),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: _buildContent(),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildContent() {
|
|
return switch (_currentMenu) {
|
|
_SettingsMenu.language => const LanguagePanel(),
|
|
_SettingsMenu.password => const PasswordPanel(),
|
|
_SettingsMenu.upgrade => _buildUpgradeContent(),
|
|
};
|
|
}
|
|
|
|
Widget _buildUpgradeContent() {
|
|
final l10n = AppLocalizations.of(context);
|
|
return ListView(
|
|
padding: EdgeInsets.zero,
|
|
children: [
|
|
Text(
|
|
l10n?.upgrade ?? '软件升级',
|
|
style: TextStyle(
|
|
color: AppTheme.textPrimary,
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: AppTheme.backgroundColor,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Icon(Icons.info_outline, color: AppTheme.primaryColor),
|
|
const SizedBox(width: 12),
|
|
Text(
|
|
'${l10n?.currentVersion ?? '当前版本'}: $_currentVersion',
|
|
style: TextStyle(color: AppTheme.textPrimary),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
CommonButton(
|
|
text: l10n?.checkUpdate ?? '检查更新',
|
|
icon: Icons.refresh,
|
|
type: ButtonType.primary,
|
|
onPressed: () {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(l10n?.latestVersion ?? '已是最新版本'),
|
|
backgroundColor: AppTheme.successColor,
|
|
),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
/// 导航菜单项
|
|
Widget _buildMenuItem({
|
|
required IconData icon,
|
|
required String title,
|
|
required VoidCallback onTap,
|
|
bool selected = false,
|
|
}) {
|
|
return Container(
|
|
color: selected
|
|
? AppTheme.primaryColor.withValues(alpha: 0.08)
|
|
: Colors.transparent,
|
|
child: ListTile(
|
|
leading: Icon(
|
|
icon,
|
|
color: selected ? AppTheme.primaryColor : AppTheme.textSecondary,
|
|
),
|
|
title: Text(
|
|
title,
|
|
style: TextStyle(
|
|
color: selected ? AppTheme.primaryColor : AppTheme.textPrimary,
|
|
fontWeight: selected ? FontWeight.w600 : FontWeight.normal,
|
|
),
|
|
),
|
|
trailing: Icon(Icons.chevron_right, color: AppTheme.idleColor),
|
|
onTap: onTap,
|
|
),
|
|
);
|
|
}
|
|
}
|