You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1160 lines
43 KiB
1160 lines
43 KiB
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 '../../../core/theme/app_colors.dart';
|
|
import '../controllers/settings_controller.dart';
|
|
import '../../../core/widgets/common_bottom_nav.dart';
|
|
import '../../../routes/app_routes.dart';
|
|
//import '../../../data/models/user_Info.dart';
|
|
import 'dart:io';
|
|
|
|
class SettingsView extends GetView<SettingsController> {
|
|
const SettingsView({Key? key}) : super(key: key);
|
|
|
|
// 正确获取用户名方式
|
|
// String get userName => User.getname();
|
|
|
|
// String get deviceInfo => User.getdeviceInfo();
|
|
// String get userId => User.getuserId();
|
|
// String get standing => User.getstanding();
|
|
// String get avatar => User.getnavatar();
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// 直接使用 Theme.of(context) 获取当前主题
|
|
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
|
|
|
|
return Scaffold(
|
|
backgroundColor: isDarkMode ? Colors.black : Colors.grey[50],
|
|
appBar: AppBar(
|
|
backgroundColor: isDarkMode ? Colors.black : Colors.white,
|
|
elevation: 0.5,
|
|
title: Text(
|
|
'settings'.tr, // 设置
|
|
style: TextStyle(
|
|
fontSize: 17.sp,
|
|
fontWeight: FontWeight.w600,
|
|
color: isDarkMode ? Colors.white : Colors.black,
|
|
),
|
|
),
|
|
centerTitle: true,
|
|
),
|
|
body: ListView(
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h),
|
|
children: [
|
|
_buildUserInfoCard(isDarkMode),
|
|
SizedBox(height: 20.h),
|
|
_buildSystemSettingsSection(isDarkMode),
|
|
SizedBox(height: 20.h),
|
|
_buildAboutSection(isDarkMode),
|
|
SizedBox(height: 50.h),
|
|
],
|
|
),
|
|
bottomNavigationBar: const CommonBottomNav(currentIndex: 2),
|
|
);
|
|
}
|
|
|
|
// 用户信息卡片
|
|
Widget _buildUserInfoCard(bool isDarkMode) {
|
|
return Container(
|
|
padding: EdgeInsets.all(16.w),
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
colors: isDarkMode
|
|
? [
|
|
const Color(0xFF1A1A1A).withOpacity(0.7),
|
|
const Color(0xFF2A2A2A).withOpacity(0.7)
|
|
]
|
|
: [const Color(0xFFE3F2FD), const Color(0xFFF3E5F5)],
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
),
|
|
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: 10, sigmaY: 10)
|
|
: ImageFilter.blur(sigmaX: 0, sigmaY: 0),
|
|
child: Row(
|
|
children: [
|
|
Obx(() => GestureDetector(
|
|
//onTap: ()=>controller.updateUserAvatar(),
|
|
child: Container(
|
|
//用户头像部分
|
|
width: 60.w,
|
|
height: 60.w,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(30.r),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.1),
|
|
blurRadius: 8,
|
|
offset: const Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: ClipRRect(
|
|
// 裁剪圆形头像
|
|
borderRadius: BorderRadius.circular(30.r),
|
|
child: controller.userInfo.value.avatar.isEmpty
|
|
? Image.network(
|
|
'https://images.unsplash.com/photo-1534528741775-53994a69daeb?ixlib=rb-1.2.1&auto=format&fit=crop&w=200&q=80',
|
|
fit: BoxFit.cover, // 图片填充方式
|
|
)
|
|
: Image.network(
|
|
controller.userInfo.value.avatar,
|
|
fit: BoxFit.cover, // 图片填充方式
|
|
)),
|
|
),
|
|
)),
|
|
SizedBox(width: 16.w),
|
|
Expanded(
|
|
// 占据剩余空间
|
|
child: Obx(
|
|
() => Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start, // 左对齐
|
|
children: [
|
|
Text(
|
|
//用户名
|
|
controller.userInfo.value.name,
|
|
style: TextStyle(
|
|
fontSize: 18.sp,
|
|
fontWeight: FontWeight.w600,
|
|
color: isDarkMode ? Colors.white : Colors.black87,
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
SizedBox(height: 4.h),
|
|
Row(
|
|
children: [
|
|
Container(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal: 8.w, vertical: 2.h),
|
|
decoration: BoxDecoration(
|
|
color: Colors.blue[600],
|
|
borderRadius: BorderRadius.circular(10.r),
|
|
),
|
|
child: Obx(() {
|
|
final membershipMap = {
|
|
0: 'freeUser', //'免费用户'
|
|
1: 'standardUser', //'标准用户'
|
|
2: 'proUser', //'专业用户'
|
|
};
|
|
final membershipString = membershipMap[controller
|
|
.userInfo.value.membershipLevel] ??
|
|
'Unknown';
|
|
return Text(
|
|
membershipString,
|
|
style: TextStyle(
|
|
fontSize: 10.sp,
|
|
color: Colors.white,
|
|
),
|
|
);
|
|
}),
|
|
),
|
|
SizedBox(width: 8.w),
|
|
Flexible(
|
|
child: Text(
|
|
'${'joinDevice'.tr} DeepSound Pro', // 已连接设备:
|
|
style: TextStyle(
|
|
fontSize: 12.sp,
|
|
color: isDarkMode
|
|
? Colors.white70
|
|
: Colors.black54,
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 4.h),
|
|
Text(
|
|
controller.userInfo.value.uid,
|
|
style: TextStyle(
|
|
fontSize: 12.sp,
|
|
color: isDarkMode ? Colors.white70 : Colors.black54,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
// 编辑按钮
|
|
width: 32.w,
|
|
height: 32.w,
|
|
decoration: BoxDecoration(
|
|
color: isDarkMode
|
|
? Colors.white.withOpacity(0.1)
|
|
: Colors.white.withOpacity(0.7),
|
|
borderRadius: BorderRadius.circular(16.r),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.05),
|
|
blurRadius: 4,
|
|
offset: const Offset(0, 1),
|
|
),
|
|
],
|
|
),
|
|
child: InkWell(
|
|
onTap: () => Get.toNamed(Routes.editProfile),
|
|
child: Icon(
|
|
Icons.edit,
|
|
size: 16.w,
|
|
color: isDarkMode ? Colors.white70 : Colors.grey[600],
|
|
),
|
|
)),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
// 系统设置部分
|
|
Widget _buildSystemSettingsSection(bool isDarkMode) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding: EdgeInsets.only(left: 4.w, bottom: 8.h),
|
|
child: Text(
|
|
'systemSetting'.tr, // 系统设置
|
|
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: [
|
|
// 语言设置
|
|
Obx(
|
|
() => _buildSimpleNavigationSetting(
|
|
title: 'languageSetting'.tr, // 语言设置
|
|
subtitle: controller.language.value.name.tr,
|
|
icon: Icons.language,
|
|
iconBgColor: isDarkMode
|
|
? Colors.indigo[900]!.withOpacity(0.3)
|
|
: Colors.indigo[100]!,
|
|
iconColor: isDarkMode
|
|
? Colors.indigo[300]!
|
|
: Colors.indigo[600]!,
|
|
titleColor: isDarkMode ? Colors.white : null,
|
|
subtitleColor: isDarkMode ? Colors.white70 : null,
|
|
onTap: () {
|
|
_showLanguageSelectionDialog(isDarkMode);
|
|
},
|
|
isDarkMode: isDarkMode,
|
|
),
|
|
),
|
|
Divider(
|
|
height: 1,
|
|
color: isDarkMode
|
|
? Colors.white.withOpacity(0.1)
|
|
: Colors.grey[200]),
|
|
|
|
// 主题设置
|
|
_buildToggleSetting(
|
|
title: 'darkMode'.tr, // 暗黑模式
|
|
subtitle: 'darkModeInfo'.tr, // 切换应用的明暗主题
|
|
icon: isDarkMode ? Icons.dark_mode : Icons.light_mode,
|
|
iconBgColor: isDarkMode
|
|
? Colors.indigo[900]!.withOpacity(0.3)
|
|
: Colors.amber[100]!,
|
|
iconColor:
|
|
isDarkMode ? Colors.indigo[300]! : Colors.amber[600]!,
|
|
value: isDarkMode,
|
|
onChanged: (value) {
|
|
controller.toggleTheme();
|
|
},
|
|
isDarkMode: isDarkMode,
|
|
),
|
|
Divider(
|
|
height: 1,
|
|
color: isDarkMode
|
|
? Colors.white.withOpacity(0.1)
|
|
: Colors.grey[200]),
|
|
|
|
// 备份与恢复
|
|
_buildNavigationSetting(
|
|
title: 'backups'.tr, // 备份与恢复
|
|
subtitle: 'backupsInfo'.tr, // 备份设置和AI互动历史
|
|
icon: Icons.cloud_upload_outlined,
|
|
iconBgColor: isDarkMode
|
|
? Colors.cyan[900]!.withOpacity(0.3)
|
|
: Colors.cyan[100]!,
|
|
iconColor:
|
|
isDarkMode ? Colors.cyan[300]! : Colors.cyan[600]!,
|
|
value: '${'lastBackup'.tr} 今天', // 上次备份:
|
|
valueStyle: TextStyle(
|
|
fontSize: 12.sp,
|
|
color: isDarkMode ? Colors.white70 : Colors.grey[500],
|
|
),
|
|
onTap: () {
|
|
// 打开备份设置页面
|
|
},
|
|
isDarkMode: isDarkMode,
|
|
),
|
|
Divider(
|
|
height: 1,
|
|
color: isDarkMode
|
|
? Colors.white.withOpacity(0.1)
|
|
: Colors.grey[200]),
|
|
|
|
// 语音服务选择
|
|
_buildSpeechServiceSetting(isDarkMode),
|
|
Divider(
|
|
height: 1,
|
|
color: isDarkMode
|
|
? Colors.white.withOpacity(0.1)
|
|
: Colors.grey[200]),
|
|
// 隐私设置
|
|
_buildSimpleNavigationSetting(
|
|
title: 'privacySettings'.tr, // 隐私设置
|
|
subtitle: 'privacySettingsInfo'.tr, // 管理数据收集和权限
|
|
icon: Icons.shield_outlined,
|
|
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: () {
|
|
AppSettings.openAppSettings();
|
|
},
|
|
isDarkMode: isDarkMode,
|
|
),
|
|
Divider(
|
|
height: 1,
|
|
color: isDarkMode
|
|
? Colors.white.withOpacity(0.1)
|
|
: Colors.grey[200]),
|
|
|
|
// 退出登录
|
|
_buildSimpleNavigationSetting(
|
|
title: 'logout'.tr, // 退出登录
|
|
icon: Icons.logout,
|
|
iconBgColor: isDarkMode
|
|
? Colors.red[900]!.withOpacity(0.3)
|
|
: Colors.red[50]!,
|
|
iconColor: isDarkMode ? Colors.red[300]! : Colors.red[600]!,
|
|
titleColor:
|
|
isDarkMode ? Colors.red[300]! : Colors.red[600]!,
|
|
onTap: () {
|
|
// 退出登录确认对话框
|
|
Get.dialog(
|
|
AlertDialog(
|
|
backgroundColor:
|
|
isDarkMode ? Colors.grey[900] : Colors.white,
|
|
title: Text(
|
|
'logout'.tr, // 退出登录
|
|
style: TextStyle(
|
|
color: isDarkMode ? Colors.white : Colors.black87,
|
|
),
|
|
),
|
|
content: Text(
|
|
'logoutTips'.tr, // 确定要退出当前账号吗?
|
|
style: TextStyle(
|
|
color:
|
|
isDarkMode ? Colors.white70 : Colors.black54,
|
|
),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Get.back(),
|
|
child: Text(
|
|
'cancel'.tr, // 取消
|
|
style: TextStyle(
|
|
color: isDarkMode
|
|
? Colors.white70
|
|
: Colors.black54,
|
|
),
|
|
),
|
|
),
|
|
TextButton(
|
|
onPressed: () {
|
|
Get.back();
|
|
controller.signOut();
|
|
},
|
|
child: Text(
|
|
'confirm'.tr, // 确定
|
|
style: TextStyle(
|
|
color: isDarkMode
|
|
? Colors.red[300]
|
|
: Colors.red[600],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
isDarkMode: isDarkMode,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
// 关于应用部分
|
|
Widget _buildAboutSection(bool isDarkMode) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding: EdgeInsets.only(left: 4.w, bottom: 8.h),
|
|
child: Text(
|
|
'aboutApplication'.tr, // 关于应用
|
|
style: TextStyle(
|
|
fontSize: 12.sp,
|
|
fontWeight: FontWeight.w500,
|
|
color: isDarkMode ? Colors.blue[400] : Colors.blue[600],
|
|
letterSpacing: 1,
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
padding: EdgeInsets.all(16.w),
|
|
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: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Container(
|
|
width: 40.w,
|
|
height: 40.w,
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
colors: [
|
|
const Color(0xFF2196F3)
|
|
.withOpacity(isDarkMode ? 0.7 : 1.0),
|
|
const Color(0xFF9C27B0)
|
|
.withOpacity(isDarkMode ? 0.7 : 1.0)
|
|
],
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
),
|
|
borderRadius: BorderRadius.circular(12.r),
|
|
),
|
|
child: Icon(
|
|
Icons.headphones,
|
|
size: 24.w,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
SizedBox(width: 12.w),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'DeepSound',
|
|
style: TextStyle(
|
|
fontSize: 16.sp,
|
|
fontWeight: FontWeight.w500,
|
|
color: isDarkMode ? Colors.white : Colors.black87,
|
|
),
|
|
),
|
|
SizedBox(height: 2.h),
|
|
Text(
|
|
'${'versions'.tr} 2.4.1 (Build 87)', // 版本
|
|
style: TextStyle(
|
|
fontSize: 12.sp,
|
|
color:
|
|
isDarkMode ? Colors.white70 : Colors.black54,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
Container(
|
|
padding:
|
|
EdgeInsets.symmetric(horizontal: 12.w, vertical: 6.h),
|
|
decoration: BoxDecoration(
|
|
color: isDarkMode
|
|
? Colors.blue[900]!.withOpacity(0.3)
|
|
: Colors.blue[100],
|
|
borderRadius: BorderRadius.circular(16.r),
|
|
),
|
|
child: Text(
|
|
'checkUpdates'.tr, // 检查更新
|
|
style: TextStyle(
|
|
fontSize: 12.sp,
|
|
color: isDarkMode ? Colors.blue[300] : Colors.blue[600],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 16.h),
|
|
Center(
|
|
child: Column(
|
|
children: [
|
|
Text(
|
|
'© 2025 DeepSound Technologies',
|
|
style: TextStyle(
|
|
fontSize: 12.sp,
|
|
color: isDarkMode ? Colors.grey[400] : Colors.grey[500],
|
|
),
|
|
),
|
|
SizedBox(height: 4.h),
|
|
Text(
|
|
'homeSlogan'.tr, // 连接世界,超越声音
|
|
style: TextStyle(
|
|
fontSize: 12.sp,
|
|
color: isDarkMode ? Colors.grey[400] : Colors.grey[500],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
// 开关类设置项
|
|
Widget _buildToggleSetting({
|
|
required String title,
|
|
String? subtitle,
|
|
required IconData icon,
|
|
required Color iconBgColor,
|
|
required Color iconColor,
|
|
required bool value,
|
|
required Function(bool) onChanged,
|
|
required bool isDarkMode,
|
|
}) {
|
|
return 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,
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
if (subtitle != null) SizedBox(height: 2.h),
|
|
if (subtitle != null)
|
|
Text(
|
|
subtitle,
|
|
style: TextStyle(
|
|
fontSize: 12.sp,
|
|
color: isDarkMode ? Colors.white70 : Colors.black54,
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Switch(
|
|
value: value,
|
|
onChanged: onChanged,
|
|
activeColor: Colors.blue[600],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
// 带导航的设置项
|
|
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,
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
if (subtitle != null) SizedBox(height: 2.h),
|
|
if (subtitle != null)
|
|
Text(
|
|
subtitle,
|
|
style: TextStyle(
|
|
fontSize: 12.sp,
|
|
color:
|
|
isDarkMode ? Colors.white70 : Colors.black54,
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
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,
|
|
String? subtitle,
|
|
required IconData icon,
|
|
required Color iconBgColor,
|
|
required Color iconColor,
|
|
Color? titleColor,
|
|
Color? subtitleColor,
|
|
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: titleColor ??
|
|
(isDarkMode ? Colors.white : Colors.black87),
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
if (subtitle != null) SizedBox(height: 2.h),
|
|
if (subtitle != null)
|
|
Text(
|
|
subtitle,
|
|
style: TextStyle(
|
|
fontSize: 12.sp,
|
|
color: subtitleColor ??
|
|
(isDarkMode
|
|
? Colors.white70
|
|
: Colors.black54),
|
|
),
|
|
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],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
// 语音服务设置项
|
|
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)['name'];
|
|
return Flexible(
|
|
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 InkWell(
|
|
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: [
|
|
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,
|
|
),
|
|
SizedBox(width: 12.w),
|
|
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,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
});
|
|
}).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(
|
|
Dialog(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(24.r),
|
|
),
|
|
insetPadding: EdgeInsets.symmetric(horizontal: 20.w),
|
|
backgroundColor: isDarkMode ? AppColors.cardBackground : Colors.white,
|
|
child: Container(
|
|
width: 0.9.sw,
|
|
padding: EdgeInsets.only(top: 32.h, bottom: 16.h),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 24.w),
|
|
child: Text(
|
|
'selectLanguage'.tr, // 选择语言
|
|
style: TextStyle(
|
|
fontSize: 20.sp,
|
|
fontWeight: FontWeight.bold,
|
|
color: isDarkMode ? Colors.white : Colors.black,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 16.h),
|
|
Container(
|
|
constraints: BoxConstraints(maxHeight: 0.5.sh),
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: controller.languageList.map((language) {
|
|
return ListTile(
|
|
title: Text(
|
|
language.name.tr,
|
|
style: TextStyle(
|
|
color: isDarkMode ? Colors.white : Colors.black,
|
|
),
|
|
),
|
|
trailing:
|
|
controller.language.value.value == language.value
|
|
? Icon(
|
|
Icons.check_circle,
|
|
color: isDarkMode
|
|
? AppColors.primary
|
|
: Colors.blue,
|
|
)
|
|
: const SizedBox.shrink(),
|
|
onTap: () {
|
|
controller.setLanguage(language);
|
|
},
|
|
);
|
|
}).toList(),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 16.h),
|
|
Align(
|
|
alignment: Alignment.centerRight,
|
|
child: Padding(
|
|
padding: EdgeInsets.only(right: 24.w),
|
|
child: TextButton(
|
|
onPressed: () => Get.back(),
|
|
child: Text(
|
|
'cancel'.tr, // 取消
|
|
style: TextStyle(
|
|
color: isDarkMode ? AppColors.primary : Colors.blue,
|
|
fontSize: 16.sp,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|