Browse Source

refactor(settings): 移除未使用的语音服务和AI设置相关代码

清理settings模块中未使用的语音服务、AI设置和用户信息相关代码
简化语言模型注释并修复主题设置注释格式
newdev_shunjiawei
lxm 9 months ago
parent
commit
77b5f769d4
  1. 2
      lib/main.dart
  2. 222
      lib/modules/settings/controllers/settings_controller.dart
  3. 9
      lib/modules/settings/models/language_model.dart
  4. 608
      lib/modules/settings/views/settings_view.dart

2
lib/main.dart

@ -111,7 +111,7 @@ class MainApp extends StatelessWidget {
Widget build(BuildContext context) {
// 在应用构建时立即初始化深链接处理
_initDeepLinkHandler();
// 获取保存的主题设置
// 获取保存的主题设置
final themeMode = ThemeService().getThemeMode();
return ScreenUtilInit(

222
lib/modules/settings/controllers/settings_controller.dart

@ -3,7 +3,6 @@ import 'dart:async';
import 'package:agent_service/agent_service.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:dio/dio.dart';
import 'package:get_storage/get_storage.dart';
import 'package:logger/logger.dart';
import 'package:package_info_plus/package_info_plus.dart';
@ -11,10 +10,8 @@ import 'package:package_info_plus/package_info_plus.dart';
import '../../../core/themes/theme_service.dart';
import '../../../core/translations/app_translations.dart';
import '../../../data/services/network/dio_manager.dart';
import '../../../data/services/speech_factory.dart';
import '../../../routes/app_routes.dart';
import '../models/language_model.dart';
import '../../../data/services/ble_manager.dart';
import '../../../data/services/language_manager.dart';
import '../../../data/services/version_update_service.dart';
import '../../common/widgets/version_update_dialog.dart';
@ -29,7 +26,9 @@ class SettingsController extends GetxController {
LanguageModel(
name: 'traditionalChinese', alias: '繁體中文', value: 'zh_TW'), // 添加繁体中文
LanguageModel(
name: 'traditionalChineseHK', alias: '繁體中文(HK)', value: 'zh_HK'), // 添加香港繁体中文
name: 'traditionalChineseHK',
alias: '繁體中文(HK)',
value: 'zh_HK'), // 添加香港繁体中文
LanguageModel(
name: 'spanish', alias: 'Español', value: 'es_ES'), // 添加西班牙语选项
LanguageModel(
@ -94,41 +93,6 @@ class SettingsController extends GetxController {
// 是否是暗黑模式
final RxBool isDarkMode = false.obs;
// 翻译语言对
final RxString sourceLanguage = '中文'.obs;
final RxString targetLanguage = '英文'.obs;
final List<String> availableLanguages = [
'中文',
'英文',
'日文',
'韩文',
'法文',
'德文',
'西班牙文',
'俄文'
];
// 语音服务类型
final Rx<SpeechServiceType> speechServiceType = SpeechServiceType.azure.obs;
final List<Map<String, dynamic>> availableSpeechServices = [
{
'type': SpeechServiceType.azure,
'name': 'azureVoiceService', // Azure 语音服务.tr
'description': 'azureVoiceServiceInfo' // 微软云端语音服务,支持高质量语音合成和识别.tr
},
{
'type': SpeechServiceType.flutter,
'name': 'flutterVoiceService', // Flutter 本地语音服务.tr
'description': 'flutterVoiceServiceInfo' // 设备本地语音服务,无需联网即可使用.tr
},
];
RxString timbreName = 'defaultTimbre'.obs;
//用户信息
// static const String userKey = 'user_info';
// final Rx<User> userInfo = User.instance.obs; //使用单例实例
// 添加版本信息变量
final appVersion = ''.obs;
final buildNumber = ''.obs;
@ -148,17 +112,12 @@ class SettingsController extends GetxController {
// 获取系统语言
_getLanguage();
_getTimbre();
// 从存储中加载上次保存的主题设置
final savedDarkMode = _themeService.isSavedDarkMode();
// 设置当前主题状态
isDarkMode.value = savedDarkMode;
// 获取当前语音服务类型
_loadCurrentSpeechServiceType();
//获取用户信息
// loadUserInfo();
@ -178,111 +137,6 @@ class SettingsController extends GetxController {
}
}
// void loadUserInfo() {
// final userJson = _storage.read(userKey);
// Logger().d('加载用户信息: $userJson');
// if (userJson != null) {
// userInfo.value = User.instance;
// Logger().d('用户信息已加载: ${userInfo.value.toJson()}');
// if (userInfo.value.avatar.isNotEmpty) {
// Logger().d('开始下载头像');
// _downloadAndSaveAvatar(userInfo.value.avatar);
// } else {
// Logger().d('用户没有头像');
// }
// } else {
// Logger().d('没有找到用户信息');
// }
// }
// Future<void> saveUserInfo() async {
// await _storage.write(userKey, userInfo.value.toJson());
// }
// 下载并保存远程头像
// Future<void> _downloadAndSaveAvatar(String url) async {
// try {
// Logger().d('开始下载头像: $url');
// final dio = Dio(BaseOptions(
// headers: {
// 'accept': '*/*',
// 'Authorization': _storage.read<String>("logintoken"),
// },
// ));
// final response = await dio.get(
// url,
// options: Options(responseType: ResponseType.bytes),
// );
// Logger().d('下载状态: ${response.statusCode}');
// if (response.statusCode == 200) {
// // 保存到应用文档目录
// final appDir = await getApplicationSupportDirectory();
// final fileName =
// '/UserAvatar/avatar_${DateTime.now().millisecondsSinceEpoch}.jpg';
// final localPath = '${appDir.path}/$fileName';
// // 确保目录存在
// final file = File(localPath);
// await file.parent.create(recursive: true);
// await file.writeAsBytes(response.data);
// // 更新本地头像路径
// //localAvatar.value = localPath;
// await _storage.write('local_avatar', localPath);
// Logger().d('头像已下载到本地: $localPath');
// //Get.snackbar('头像', '头像已下载到本地');
// }
// } catch (e) {
// Logger().e('下载头像失败: $e');
// }
// }
// Future<void> updateUserAvatar() async {
// final XFile? image = await _picker.pickImage(
// source: ImageSource.gallery,
// maxWidth: 800,
// maxHeight: 800,
// imageQuality: 85,
// );
// if (image != null) {
// userInfo.update((user) {
// if (user != null) {
// user.avatar = image.path;
// }
// });
// await saveUserInfo();
// }
// }
// Future<void> updateUserName(String name) async {
// if (name.trim().isNotEmpty) {
// userInfo.update((user) {
// if (user != null) {
// user.name = name.trim();
// }
// });
// await saveUserInfo();
// }
// }
// Future<void> updateDeviceName(String deviceName) async {
// userInfo.update((user) {
// if (user != null) {
// user.deviceName = deviceName;
// }
// });
// await saveUserInfo();
// }
// }
void _getLanguage() {
String? languageValue = _storage.read('language');
LanguageModel data = languageList.firstWhere(
@ -292,21 +146,6 @@ class SettingsController extends GetxController {
language.value = data;
}
// 获取音色
void _getTimbre() {
List? timbreList = _storage.read('timbreList');
String? timbre = _storage.read('timbre');
if (timbreList != null && timbre != null) {
Map data = timbreList.firstWhere(
(element) => element['type'] == timbre,
orElse: () => {},
);
if (data.isNotEmpty) {
timbreName.value = data['name'];
}
}
}
/// 设置语言
Future<void> setLanguage(LanguageModel data) async {
try {
@ -335,12 +174,12 @@ class SettingsController extends GetxController {
if (targetLocale != null) {
Get.updateLocale(targetLocale);
print("设置语言: ${data.value} -> ${targetLocale.toString()}");
Logger().i("设置语言: ${data.value} -> ${targetLocale.toString()}");
} else {
// 如果无法确定目标语言,使用智能fallback
targetLocale = AppTranslations.getSmartFallbackLocale();
Get.updateLocale(targetLocale);
print("使用fallback语言: ${targetLocale.toString()}");
Logger().i("使用fallback语言: ${targetLocale.toString()}");
}
// 保存用户选择
@ -351,12 +190,7 @@ class SettingsController extends GetxController {
await _updateAgentLanguageSettings(data);
// 显示语言切换成功提示
// Get.snackbar(
// 'success'.tr,
// 'languageChanged'.tr, // 需要在语言文件中添加这个key
// snackPosition: SnackPosition.TOP,
// duration: const Duration(seconds: 2),
// );
Logger().i("语言切换成功: ${data.value}");
// 延迟一下确保语言更新完成,然后重新进入应用
await Future.delayed(const Duration(milliseconds: 500));
@ -365,14 +199,7 @@ class SettingsController extends GetxController {
Get.offAllNamed(Routes.splash);
Get.back();
} catch (e) {
print("设置语言时出错: $e");
// Get.snackbar(
// 'error'.tr,
// 'languageChangeFailed'.tr, // 需要在语言文件中添加这个key
// snackPosition: SnackPosition.TOP,
// backgroundColor: Colors.red.withValues(alpha: 0.8),
// colorText: Colors.white,
// );
Logger().e("设置语言时出错: $e");
}
}
@ -437,16 +264,6 @@ class SettingsController extends GetxController {
}
}
// 加载当前语音服务类型
void _loadCurrentSpeechServiceType() {
try {
final factory = Get.find<SpeechFactory>();
speechServiceType.value = factory.currentServiceType;
} catch (e) {
// 如果找不到SpeechFactory实例,使用默认值
}
}
// 切换主题
Future<void> toggleTheme() async {
// 切换暗黑模式状态
@ -459,31 +276,6 @@ class SettingsController extends GetxController {
await _themeService.saveThemeMode(isDarkMode.value);
}
// 设置语音服务类型
void setSpeechServiceType(SpeechServiceType type) {
try {
final factory = Get.find<SpeechFactory>();
factory.setServiceType(type);
speechServiceType.value = type;
} catch (e) {
// 处理错误
}
}
void setSourceLanguage(String language) {
sourceLanguage.value = language;
}
void setTargetLanguage(String language) {
targetLanguage.value = language;
}
void swapLanguages() {
final temp = sourceLanguage.value;
sourceLanguage.value = targetLanguage.value;
targetLanguage.value = temp;
}
/// 清除BLE配对设备
// Future<void> clearBleDevices() async {
// // 显示确认对话框

9
lib/modules/settings/models/language_model.dart

@ -1,7 +1,10 @@
/// 语言模型
/// 包含语言的名称、别名和值
/// 用于表示应用支持的不同语言
class LanguageModel {
final String name;
final String alias;
final String value;
final String name; //语言名称
final String alias; //语言别名
final String value; //语言代码
LanguageModel({
this.name = '',

608
lib/modules/settings/views/settings_view.dart

@ -1,10 +1,7 @@
import 'package:app_settings/app_settings.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'dart:ui';
import 'dart:io';
import '../../../core/theme/app_colors.dart';
import '../controllers/settings_controller.dart';
import '../../../core/widgets/common_bottom_nav.dart';
import '../../../routes/app_routes.dart';
@ -67,8 +64,8 @@ class SettingsView extends GetView<SettingsController> {
gradient: LinearGradient(
colors: isDarkMode
? [
const Color(0xFF1A1A1A).withOpacity(0.7),
const Color(0xFF2A2A2A).withOpacity(0.7)
const Color(0xFF1A1A1A).withValues(alpha: 0.7),
const Color(0xFF2A2A2A).withValues(alpha: 0.7)
]
: [const Color(0xFFE3F2FD), const Color(0xFFF3E5F5)],
begin: Alignment.topLeft,
@ -78,8 +75,8 @@ class SettingsView extends GetView<SettingsController> {
boxShadow: [
BoxShadow(
color: isDarkMode
? Colors.black.withOpacity(0.2)
: Colors.black.withOpacity(0.05),
? Colors.black.withValues(alpha: 0.2)
: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@ -106,7 +103,7 @@ class SettingsView extends GetView<SettingsController> {
isDarkMode: isDarkMode,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
color: Colors.black.withValues(alpha: 0.1),
blurRadius: 8,
offset: const Offset(0, 2),
),
@ -190,12 +187,12 @@ class SettingsView extends GetView<SettingsController> {
height: 32.w,
decoration: BoxDecoration(
color: isDarkMode
? Colors.white.withOpacity(0.1)
: Colors.white.withOpacity(0.7),
? Colors.white.withValues(alpha: 0.1)
: Colors.white.withValues(alpha: 0.7),
borderRadius: BorderRadius.circular(16.r),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.05),
color: Colors.black.withValues(alpha: 0.05),
blurRadius: 4,
offset: const Offset(0, 1),
),
@ -225,8 +222,8 @@ class SettingsView extends GetView<SettingsController> {
gradient: LinearGradient(
colors: isDarkMode
? [
const Color(0xFF0D47A1).withOpacity(0.5),
const Color(0xFF1976D2).withOpacity(0.5)
const Color(0xFF0D47A1).withValues(alpha: 0.5),
const Color(0xFF1976D2).withValues(alpha: 0.5)
]
: [const Color(0xFFE3F2FD), const Color(0xFFBBDEFB)],
begin: Alignment.topLeft,
@ -236,8 +233,8 @@ class SettingsView extends GetView<SettingsController> {
boxShadow: [
BoxShadow(
color: isDarkMode
? Colors.black.withOpacity(0.2)
: Colors.black.withOpacity(0.05),
? Colors.black.withValues(alpha: 0.2)
: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@ -262,7 +259,7 @@ class SettingsView extends GetView<SettingsController> {
icon: Icons.workspace_premium,
label: 'aiRecharge'.tr, //AI充值
iconBg: isDarkMode
? Colors.amber[900]!.withOpacity(0.3)
? Colors.amber[900]!.withValues(alpha: 0.3)
: Colors.amber[100]!,
iconColor: isDarkMode ? Colors.amber[300]! : Colors.amber[600]!,
textColor: isDarkMode ? Colors.white : Colors.black87,
@ -272,7 +269,7 @@ class SettingsView extends GetView<SettingsController> {
icon: Icons.translate,
label: 'translationRecharge'.tr, //翻译充值
iconBg: isDarkMode
? Colors.indigo[900]!.withOpacity(0.3)
? Colors.indigo[900]!.withValues(alpha: 0.3)
: Colors.indigo[100]!,
iconColor:
isDarkMode ? Colors.indigo[300]! : Colors.indigo[600]!,
@ -283,7 +280,7 @@ class SettingsView extends GetView<SettingsController> {
icon: Icons.people,
label: 'meetingAssistantRecharge'.tr, //会议充值
iconBg: isDarkMode
? Colors.pink[900]!.withOpacity(0.3)
? Colors.pink[900]!.withValues(alpha: 0.3)
: Colors.pink[100]!,
iconColor: isDarkMode ? Colors.pink[300]! : Colors.pink[600]!,
textColor: isDarkMode ? Colors.white : Colors.black87,
@ -293,7 +290,7 @@ class SettingsView extends GetView<SettingsController> {
icon: Icons.analytics_outlined,
label: 'usageStats'.tr, //用量统计
iconBg: isDarkMode
? Colors.teal[900]!.withOpacity(0.3)
? Colors.teal[900]!.withValues(alpha: 0.3)
: Colors.teal[100]!,
iconColor: isDarkMode ? Colors.teal[300]! : Colors.teal[600]!,
textColor: isDarkMode ? Colors.white : Colors.black87,
@ -357,104 +354,6 @@ class SettingsView extends GetView<SettingsController> {
);
}
// AI设置
Widget _buildAISettingsSection(bool isDarkMode) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(left: 4.w, bottom: 8.h),
child: Text(
'AIsettings'.tr, // AI设置
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.w500,
color: isDarkMode ? Colors.blue[400] : Colors.blue[600],
letterSpacing: 1,
),
),
),
Container(
decoration: BoxDecoration(
color: isDarkMode ? Colors.white.withOpacity(0.05) : Colors.white,
borderRadius: BorderRadius.circular(16.r),
boxShadow: [
BoxShadow(
color: isDarkMode
? Colors.black.withOpacity(0.2)
: Colors.black.withOpacity(0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(16.r),
child: BackdropFilter(
filter: isDarkMode
? ImageFilter.blur(sigmaX: 5, sigmaY: 5)
: ImageFilter.blur(sigmaX: 0, sigmaY: 0),
child: Column(
children: [
// 语音服务选择
_buildSpeechServiceSetting(isDarkMode),
Divider(
height: 1,
color: isDarkMode
? Colors.white.withOpacity(0.1)
: Colors.grey[200]),
Obx(
() => _buildNavigationSetting(
title: 'timbreService'.tr, // 音色服务
subtitle: 'timbreServiceInfo'.tr, // 选择音色服务
icon: Icons.photo_camera_front_outlined,
iconBgColor: isDarkMode
? Colors.cyan[900]!.withOpacity(0.3)
: Colors.cyan[100]!,
iconColor:
isDarkMode ? Colors.cyan[300]! : Colors.cyan[600]!,
value: controller.timbreName.value.tr, // 当前音色
valueStyle: TextStyle(
fontSize: 12.sp,
color: isDarkMode ? Colors.white70 : Colors.grey[500],
),
onTap: () {
Get.toNamed(Routes.timbre);
},
isDarkMode: isDarkMode,
),
),
Divider(
height: 1,
color: isDarkMode
? Colors.white.withOpacity(0.1)
: Colors.grey[200]),
// 实时对话入口
_buildSimpleNavigationSetting(
title: 'realtimeVoiceChat'.tr, // 实时语音对话
subtitle: 'realtimeVoiceChatInfo'.tr, // 实时语音对话信息
icon: Icons.chat_bubble_outline,
iconBgColor: isDarkMode
? Colors.purple[900]!.withOpacity(0.3)
: Colors.purple[100]!,
iconColor:
isDarkMode ? Colors.purple[300]! : Colors.purple[600]!,
titleColor: isDarkMode ? Colors.white : null,
subtitleColor: isDarkMode ? Colors.white70 : null,
onTap: () {
Get.toNamed(Routes.realtime);
},
isDarkMode: isDarkMode,
),
],
),
),
),
),
],
);
}
// 系统设置部分
Widget _buildSystemSettingsSection(bool isDarkMode) {
return Column(
@ -474,13 +373,15 @@ class SettingsView extends GetView<SettingsController> {
// ),
Container(
decoration: BoxDecoration(
color: isDarkMode ? Colors.white.withOpacity(0.05) : Colors.white,
color: isDarkMode
? Colors.white.withValues(alpha: 0.05)
: Colors.white,
borderRadius: BorderRadius.circular(16.r),
boxShadow: [
BoxShadow(
color: isDarkMode
? Colors.black.withOpacity(0.2)
: Colors.black.withOpacity(0.05),
? Colors.black.withValues(alpha: 0.2)
: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@ -501,7 +402,7 @@ class SettingsView extends GetView<SettingsController> {
subtitle: controller.language.value.name.tr, // 当前语言
icon: Icons.language,
iconBgColor: isDarkMode
? Colors.indigo[900]!.withOpacity(0.3)
? Colors.indigo[900]!.withValues(alpha: 0.3)
: Colors.indigo[100]!,
iconColor: isDarkMode
? Colors.indigo[300]!
@ -517,7 +418,7 @@ class SettingsView extends GetView<SettingsController> {
Divider(
height: 1,
color: isDarkMode
? Colors.white.withOpacity(0.1)
? Colors.white.withValues(alpha: 0.1)
: Colors.grey[200]),
// 主题设置
@ -526,7 +427,7 @@ class SettingsView extends GetView<SettingsController> {
subtitle: 'darkModeInfo'.tr, // 切换应用的明暗主题
icon: isDarkMode ? Icons.dark_mode : Icons.light_mode,
iconBgColor: isDarkMode
? Colors.indigo[900]!.withOpacity(0.3)
? Colors.indigo[900]!.withValues(alpha: 0.3)
: Colors.amber[100]!,
iconColor:
isDarkMode ? Colors.indigo[300]! : Colors.amber[600]!,
@ -539,7 +440,7 @@ class SettingsView extends GetView<SettingsController> {
Divider(
height: 1,
color: isDarkMode
? Colors.white.withOpacity(0.1)
? Colors.white.withValues(alpha: 0.1)
: Colors.grey[200]),
// 用户反馈
@ -548,7 +449,7 @@ class SettingsView extends GetView<SettingsController> {
subtitle: 'feedbackInfo'.tr, // 提供反馈或建议
icon: Icons.feedback_outlined,
iconBgColor: isDarkMode
? Colors.orange[900]!.withOpacity(0.3)
? Colors.orange[900]!.withValues(alpha: 0.3)
: Colors.orange[100]!,
iconColor:
isDarkMode ? Colors.orange[300]! : Colors.orange[600]!,
@ -589,7 +490,7 @@ class SettingsView extends GetView<SettingsController> {
Divider(
height: 1,
color: isDarkMode
? Colors.white.withOpacity(0.1)
? Colors.white.withValues(alpha: 0.1)
: Colors.grey[200]),
// 配对设备管理
@ -598,7 +499,7 @@ class SettingsView extends GetView<SettingsController> {
subtitle: 'manageConnectedDevices'.tr, // 管理已绑定的蓝牙设备
icon: Icons.device_hub,
iconBgColor: isDarkMode
? Colors.red[900]!.withOpacity(0.3)
? Colors.red[900]!.withValues(alpha: 0.3)
: Colors.red[100]!,
iconColor: isDarkMode ? Colors.red[300]! : Colors.red[600]!,
titleColor: isDarkMode ? Colors.white : null,
@ -609,7 +510,7 @@ class SettingsView extends GetView<SettingsController> {
Divider(
height: 1,
color: isDarkMode
? Colors.white.withOpacity(0.1)
? Colors.white.withValues(alpha: 0.1)
: Colors.grey[200]),
// // 杰理测试
@ -665,7 +566,7 @@ class SettingsView extends GetView<SettingsController> {
subtitle: '测试opus解码',
icon: Icons.bluetooth_searching,
iconBgColor: isDarkMode
? Colors.green[900]!.withOpacity(0.3)
? Colors.green[900]!.withValues(alpha: 0.3)
: Colors.green[100]!,
iconColor: isDarkMode
? Colors.green[300]!
@ -749,7 +650,7 @@ class SettingsView extends GetView<SettingsController> {
subtitle: 'bleHeadsetFirmwareUpgrade'.tr, // BLE耳机固件版本升级
icon: Icons.system_update_alt,
iconBgColor: isDarkMode
? Colors.orange[900]!.withOpacity(0.3)
? Colors.orange[900]!.withValues(alpha: 0.3)
: Colors.orange[100]!,
iconColor:
isDarkMode ? Colors.orange[300]! : Colors.orange[600]!,
@ -761,7 +662,7 @@ class SettingsView extends GetView<SettingsController> {
Divider(
height: 1,
color: isDarkMode
? Colors.white.withOpacity(0.1)
? Colors.white.withValues(alpha: 0.1)
: Colors.grey[200]),
// 权限管理设置项
@ -770,7 +671,7 @@ class SettingsView extends GetView<SettingsController> {
subtitle: 'permissionManagementInfo'.tr, // 管理应用权限设置
icon: Icons.security,
iconBgColor: isDarkMode
? Colors.orange[900]!.withOpacity(0.3)
? Colors.orange[900]!.withValues(alpha: 0.3)
: Colors.orange[100]!,
iconColor:
isDarkMode ? Colors.orange[300]! : Colors.orange[600]!,
@ -811,13 +712,15 @@ class SettingsView extends GetView<SettingsController> {
Container(
padding: EdgeInsets.all(16.w),
decoration: BoxDecoration(
color: isDarkMode ? Colors.white.withOpacity(0.05) : Colors.white,
color: isDarkMode
? Colors.white.withValues(alpha: 0.05)
: Colors.white,
borderRadius: BorderRadius.circular(16.r),
boxShadow: [
BoxShadow(
color: isDarkMode
? Colors.black.withOpacity(0.2)
: Colors.black.withOpacity(0.05),
? Colors.black.withValues(alpha: 0.2)
: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@ -842,9 +745,9 @@ class SettingsView extends GetView<SettingsController> {
gradient: LinearGradient(
colors: [
const Color(0xFF2196F3)
.withOpacity(isDarkMode ? 0.7 : 1.0),
.withValues(alpha: isDarkMode ? 0.7 : 1.0),
const Color(0xFF9C27B0)
.withOpacity(isDarkMode ? 0.7 : 1.0)
.withValues(alpha: isDarkMode ? 0.7 : 1.0)
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
@ -908,7 +811,7 @@ class SettingsView extends GetView<SettingsController> {
),
decoration: BoxDecoration(
color: isDarkMode
? Colors.blue[900]!.withOpacity(0.3)
? Colors.blue[900]!.withValues(alpha: 0.3)
: Colors.blue[100],
borderRadius: BorderRadius.circular(16.r),
),
@ -1089,114 +992,6 @@ class SettingsView extends GetView<SettingsController> {
);
}
// 带导航的设置项
Widget _buildNavigationSetting({
required String title,
String? subtitle,
required IconData icon,
required Color iconBgColor,
required Color iconColor,
required String value,
TextStyle? valueStyle,
required VoidCallback onTap,
required bool isDarkMode,
}) {
return InkWell(
onTap: onTap,
child: Padding(
padding: EdgeInsets.all(16.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Row(
children: [
Container(
width: 32.w,
height: 32.w,
decoration: BoxDecoration(
color: iconBgColor,
borderRadius: BorderRadius.circular(16.r),
),
child: Icon(
icon,
size: 16.w,
color: iconColor,
),
),
SizedBox(width: 12.w),
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w500,
color: isDarkMode ? Colors.white : Colors.black87,
height: 1.2, // 设置行高,提升多行文本可读性
),
softWrap: true, // 启用软换行
overflow: TextOverflow.visible, // 确保文本完全显示
),
if (subtitle != null) SizedBox(height: 2.h),
if (subtitle != null)
Text(
subtitle,
style: TextStyle(
fontSize: 12.sp,
color:
isDarkMode ? Colors.white70 : Colors.black54,
height: 1.3, // 设置行高,提升多行文本可读性
),
softWrap: true, // 启用软换行
overflow: TextOverflow.visible, // 确保文本完全显示
),
],
),
),
],
),
),
Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: Text(
value,
style: valueStyle ??
TextStyle(
fontSize: 14.sp,
color: isDarkMode ? Colors.white : Colors.black87,
),
overflow: TextOverflow.ellipsis,
),
),
SizedBox(width: 8.w),
Container(
width: 32.w,
height: 32.w,
decoration: BoxDecoration(
color: isDarkMode
? Colors.white.withOpacity(0.05)
: Colors.grey[100],
borderRadius: BorderRadius.circular(16.r),
),
child: Icon(
Icons.chevron_right,
size: 16.w,
color: isDarkMode ? Colors.white70 : Colors.grey[500],
),
),
],
),
],
),
),
);
}
// 简单导航设置项
Widget _buildSimpleNavigationSetting({
required String title,
@ -1275,7 +1070,7 @@ class SettingsView extends GetView<SettingsController> {
height: 32.w,
decoration: BoxDecoration(
color: isDarkMode
? Colors.white.withOpacity(0.05)
? Colors.white.withValues(alpha: 0.05)
: Colors.grey[100],
borderRadius: BorderRadius.circular(16.r),
),
@ -1291,244 +1086,6 @@ class SettingsView extends GetView<SettingsController> {
);
}
// 语音服务设置项
Widget _buildSpeechServiceSetting(bool isDarkMode) {
return InkWell(
onTap: () {
_showSpeechServiceSelectionDialog(isDarkMode);
},
child: Padding(
padding: EdgeInsets.all(16.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Row(
children: [
Container(
//语音服务图标
width: 32.w,
height: 32.w,
decoration: BoxDecoration(
color: isDarkMode
? Colors.teal[900]!.withOpacity(0.3)
: Colors.teal[100]!,
borderRadius: BorderRadius.circular(16.r),
),
child: Icon(
Icons.record_voice_over,
size: 16.w,
color: isDarkMode ? Colors.teal[300]! : Colors.teal[600]!,
),
),
SizedBox(width: 12.w),
Flexible(
//语音服务标题和副标题
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'voiceService'.tr, // 语音服务
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w500,
color: isDarkMode ? Colors.white : Colors.black87,
),
),
SizedBox(height: 2.h),
Text(
'voiceServiceInfo'.tr, // 选择语音识别和合成服务
style: TextStyle(
fontSize: 12.sp,
color: isDarkMode ? Colors.white70 : Colors.black54,
),
overflow: TextOverflow.ellipsis,
),
],
),
),
],
),
),
Row(
mainAxisSize: MainAxisSize.min,
children: [
Obx(() {
final serviceType = controller.speechServiceType.value;
final serviceName = controller.availableSpeechServices
.firstWhere((service) => service['type'] == serviceType,
orElse: () => {'name': 'unknown'})['name'];
return Container(
constraints: BoxConstraints(maxWidth: 120.w), // 限制最大宽度
child: Text(
'$serviceName'.tr, // 语音服务名称
style: TextStyle(
fontSize: 12.sp,
color: isDarkMode ? Colors.white70 : Colors.grey[600],
),
overflow: TextOverflow.ellipsis,
),
);
}),
SizedBox(width: 8.w),
Container(
width: 32.w,
height: 32.w,
decoration: BoxDecoration(
color: isDarkMode
? Colors.white.withOpacity(0.05)
: Colors.grey[100],
borderRadius: BorderRadius.circular(16.r),
),
child: Icon(
Icons.chevron_right,
size: 16.w,
color: isDarkMode ? Colors.white70 : Colors.grey[500],
),
),
],
),
],
),
),
);
}
// 显示语音服务选择对话框
void _showSpeechServiceSelectionDialog(bool isDarkMode) {
Get.dialog(
Dialog(
backgroundColor: isDarkMode ? Colors.grey[900] : Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.r),
),
child: Padding(
padding: EdgeInsets.all(16.w),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'selectVoiceService'.tr, // 选择语音服务
style: TextStyle(
fontSize: 18.sp,
fontWeight: FontWeight.w600,
color: isDarkMode ? Colors.white : Colors.black87,
),
),
SizedBox(height: 16.h),
...controller.availableSpeechServices.map((service) {
return Obx(() {
final isSelected =
controller.speechServiceType.value == service['type'];
return GestureDetector(
onTap: () {
controller.setSpeechServiceType(service['type']);
Get.back();
},
child: Container(
margin: EdgeInsets.only(bottom: 12.h),
padding: EdgeInsets.all(12.w),
decoration: BoxDecoration(
color: isSelected
? (isDarkMode
? Colors.teal[900]!.withOpacity(0.3)
: Colors.teal[50]!)
: (isDarkMode
? Colors.white.withOpacity(0.05)
: Colors.grey[100]!),
borderRadius: BorderRadius.circular(12.r),
border: Border.all(
color: isSelected
? (isDarkMode
? Colors.teal[300]!
: Colors.teal[600]!)
: Colors.transparent,
width: 1,
),
),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'${service['name']}'.tr, // 服务名称
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w500,
color: isDarkMode
? Colors.white
: Colors.black87,
),
overflow: TextOverflow.ellipsis,
),
SizedBox(height: 4.h),
Text(
'${service['description']}'.tr, // 服务描述
style: TextStyle(
fontSize: 12.sp,
color: isDarkMode
? Colors.white70
: Colors.black54,
),
overflow: TextOverflow.ellipsis,
maxLines: 2,
),
],
),
),
SizedBox(width: 12.w),
Container(
width: 24.w,
height: 24.w,
decoration: BoxDecoration(
color: isSelected
? (isDarkMode
? Colors.teal[300]
: Colors.teal[600])
: (isDarkMode
? Colors.white.withOpacity(0.1)
: Colors.grey[300]),
shape: BoxShape.circle,
),
child: isSelected
? Icon(
Icons.check,
size: 16.w,
color: Colors.white,
)
: null,
),
],
),
),
);
});
}).toList(),
SizedBox(height: 16.h),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () => Get.back(),
child: Text(
'cancel'.tr, // 取消
style: TextStyle(
color: isDarkMode ? Colors.white70 : Colors.black54,
),
),
),
],
),
],
),
),
),
);
}
// 显示语言选择对话框
void _showLanguageSelectionDialog(bool isDarkMode) {
Get.dialog(
@ -1572,10 +1129,10 @@ class SettingsView extends GetView<SettingsController> {
decoration: BoxDecoration(
color: isSelected
? (isDarkMode
? Colors.teal[900]!.withOpacity(0.3)
? Colors.teal[900]!.withValues(alpha: 0.3)
: Colors.teal[50]!)
: (isDarkMode
? Colors.white.withOpacity(0.05)
? Colors.white.withValues(alpha: 0.05)
: Colors.grey[100]!),
borderRadius: BorderRadius.circular(12.r),
border: Border.all(
@ -1621,7 +1178,8 @@ class SettingsView extends GetView<SettingsController> {
? Colors.teal[300]
: Colors.teal[600])
: (isDarkMode
? Colors.white.withOpacity(0.1)
? Colors.white
.withValues(alpha: 0.1)
: Colors.grey[300]),
shape: BoxShape.circle,
),
@ -1663,78 +1221,4 @@ class SettingsView extends GetView<SettingsController> {
),
);
}
// 添加权限管理设置项
Widget _buildSettingItem({
required IconData icon,
required Color iconColor,
required String title,
required bool isDarkMode,
required VoidCallback onTap,
}) {
return InkWell(
onTap: onTap,
child: Padding(
padding: EdgeInsets.all(16.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Row(
children: [
Container(
width: 32.w,
height: 32.w,
decoration: BoxDecoration(
color: isDarkMode
? Colors.white.withOpacity(0.05)
: Colors.grey[100],
borderRadius: BorderRadius.circular(16.r),
),
child: Icon(
icon,
size: 16.w,
color: iconColor,
),
),
SizedBox(width: 12.w),
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w500,
color: isDarkMode ? Colors.white : Colors.black87,
),
overflow: TextOverflow.ellipsis,
),
],
),
),
],
),
),
Container(
width: 32.w,
height: 32.w,
decoration: BoxDecoration(
color: isDarkMode
? Colors.white.withOpacity(0.05)
: Colors.grey[100],
borderRadius: BorderRadius.circular(16.r),
),
child: Icon(
Icons.chevron_right,
size: 16.w,
color: isDarkMode ? Colors.white70 : Colors.grey[500],
),
),
],
),
),
);
}
}

Loading…
Cancel
Save