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.
 
 
 
 
 
 

1195 lines
47 KiB

import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../controllers/settings_controller.dart';
import '../../../routes/app_routes.dart';
import '../../../core/utils/app_features.dart';
import '../../common/webview_page.dart';
import '../../../modules/profile/controllers/profile_controller.dart';
import '../../profile/views/unified_avatar.dart';
class SettingsView extends GetView<SettingsController> {
const SettingsView({Key? key, this.embedded = false}) : super(key: key);
/// 作为底部 tab(「我的」)内嵌展示时为 true:此时它不是被 push 出来的页面,
/// 不该显示返回箭头,否则点一下会把整个主框架 pop 掉。
final bool embedded;
@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,
// 返回箭头:能返回则返回,否则回到首页;内嵌到 tab 时不显示
automaticallyImplyLeading: !embedded,
leading: embedded
? null
: IconButton(
icon: Icon(
Icons.arrow_back_ios_new,
size: 18.sp,
color: isDarkMode ? Colors.white : Colors.black,
),
onPressed: () {
if (Navigator.of(context).canPop()) {
Get.back();
} else {
Get.offAllNamed(Routes.home);
}
},
),
title: Text(
'settings'.tr, // 设置
style: TextStyle(
fontSize: 18.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: 12.h),
_buildVipPurchaseCard(isDarkMode),
SizedBox(height: 16.h),
_buildSystemSettingsSection(isDarkMode),
SizedBox(height: 20.h),
_buildAboutSection(isDarkMode),
SizedBox(height: 10.h),
],
),
);
}
// 用户信息卡片
Widget _buildUserInfoCard(bool isDarkMode) {
final ProfileController profileCtrl =
Get.find<ProfileController>(); // 从GetX中获取ProfileController实例
return GestureDetector(
onTap: () => Get.toNamed(Routes.editProfile),
child: Container(
padding: EdgeInsets.all(16.w),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: isDarkMode
? [
const Color(0xFF1A1A1A).withValues(alpha: 0.7),
const Color(0xFF2A2A2A).withValues(alpha: 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.withValues(alpha: 0.2)
: Colors.black.withValues(alpha: 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: [
// 使用统一头像组件,避免闪烁问题
UnifiedAvatarWithContainer(
width: 60.w,
height: 60.w,
radius: 30.r,
backgroundColor:
isDarkMode ? Colors.grey[800] : Colors.grey[200],
iconColor: isDarkMode ? Colors.grey[400] : Colors.grey[600],
iconSize: 30.r,
isDarkMode: isDarkMode,
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.1),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
SizedBox(width: 16.w),
Expanded(
// 占据剩余空间
child: Obx(
() => Column(
crossAxisAlignment: CrossAxisAlignment.start, // 左对齐
children: [
Text(
//用户名
profileCtrl.userInfo.value.name,
style: TextStyle(
fontSize: 18.sp,
fontWeight: FontWeight.w600,
color: isDarkMode ? Colors.white : Colors.black87,
),
overflow: TextOverflow.ellipsis,
),
// SizedBox(height: 4.h),
const 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[
// profileCtrl.userInfo.value.viplv] ??
// 'Unknown';
// return Text(
// membershipString.tr, // 会员等级
// style: TextStyle(
// fontSize: 10.sp,
// color: Colors.white,
// ),
// );
// }),
// ),
// SizedBox(width: 8.w),
// Flexible(
// child: Text(
// '${'joinDevice'.tr} Eaimar Pro', // 已连接设备:
// style: TextStyle(
// fontSize: 12.sp,
// color: isDarkMode
// ? Colors.white70
// : Colors.black54,
// ),
// overflow: TextOverflow.ellipsis,
// ),
// ),
],
),
SizedBox(height: 4.h),
Text(
'ID:${profileCtrl.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
? const Color(0xFF2C2C2C)
: Colors.white.withValues(alpha: 0.7),
borderRadius: BorderRadius.circular(16.r),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 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],
),
)),
],
),
),
),
),
);
}
// 构建Vip购买卡片
/// 会员充值:单行紧凑卡片(图标 + 文字 + 箭头同一行),紧跟用户信息卡下方
///
/// AppFeatures.rechargeEnabled=false 时整卡不渲染(当前的送额度期间不引导充值)。
Widget _buildVipPurchaseCard(bool isDarkMode) {
if (!AppFeatures.rechargeEnabled) return const SizedBox.shrink();
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => Get.toNamed(Routes.goodsvip),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 14.w, vertical: 10.h),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: isDarkMode
? [
const Color(0xFF0D47A1).withValues(alpha: 0.5),
const Color(0xFF1976D2).withValues(alpha: 0.5)
]
: [const Color(0xFFE3F2FD), const Color(0xFFBBDEFB)],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
borderRadius: BorderRadius.circular(14.r),
boxShadow: [
BoxShadow(
color: isDarkMode
? Colors.black.withValues(alpha: 0.2)
: Colors.black.withValues(alpha: 0.05),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: Row(
children: [
Container(
width: 34.w,
height: 34.w,
decoration: BoxDecoration(
color: isDarkMode
? Colors.amber[900]!.withValues(alpha: 0.3)
: Colors.amber[100]!,
shape: BoxShape.circle,
),
child: Icon(
Icons.workspace_premium,
size: 20.sp,
color: isDarkMode ? Colors.amber[300]! : Colors.amber[600]!,
),
),
SizedBox(width: 10.w),
Expanded(
child: Text(
'vipRecharge'.tr, // 会员充值
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.w600,
color: isDarkMode ? Colors.white : Colors.black87,
),
),
),
Icon(
Icons.chevron_right,
size: 20.sp,
color: isDarkMode ? Colors.white54 : Colors.black38,
),
],
),
),
);
}
Widget _buildSystemSettingsSection(bool isDarkMode) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Padding(
// padding: EdgeInsets.only(left: 4.w, bottom: 8.h),
// child: Text(
// 'systemSettings'.tr, // 系统设置
// style: TextStyle(
// fontSize: 12.sp,
// fontWeight: FontWeight.w500,
// color: isDarkMode ? Colors.blue[400] : Colors.blue[600],
// letterSpacing: 1,
// ),
// ),
// ),
Container(
decoration: BoxDecoration(
color: isDarkMode ? const Color(0xFF1E1E1E) : Colors.white,
borderRadius: BorderRadius.circular(16.r),
border: isDarkMode
? Border.all(color: const Color(0xFF2C2C2C), width: 1)
: null,
boxShadow: [
BoxShadow(
color: isDarkMode
? Colors.black.withValues(alpha: 0.4)
: Colors.black.withValues(alpha: 0.06),
blurRadius: 12,
offset: const Offset(0, 2),
),
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(16.r),
child: Column(
children: [
// 语言设置
Obx(
() => _buildSimpleNavigationSetting(
title: 'languageSetting'.tr, // 语言设置
subtitle: controller.currentLanguage.value.name.tr, // 当前语言
icon: Icons.language,
iconBgColor: isDarkMode
? Colors.indigo[900]!.withValues(alpha: 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
? const Color(0xFF2C2C2C)
: Colors.grey[200]),
// 主题设置
_buildToggleSetting(
title: 'darkMode'.tr, // 暗黑模式
subtitle: 'darkModeInfo'.tr, // 切换应用的明暗主题
icon: isDarkMode ? Icons.dark_mode : Icons.light_mode,
iconBgColor: isDarkMode
? Colors.indigo[900]!.withValues(alpha: 0.3)
: Colors.amber[100]!,
iconColor:
isDarkMode ? Colors.indigo[300]! : Colors.amber[600]!,
value: isDarkMode,
onChanged: (isThemeChanged) {
controller.toggleTheme();
},
isDarkMode: isDarkMode,
),
Divider(
height: 1,
color: isDarkMode
? const Color(0xFF2C2C2C)
: Colors.grey[200]),
// 设备自动连接(后台唤醒本应用回连 = 自启动,必须可开可关)
Obx(() => _buildToggleSetting(
title: 'autoConnectTitle'.tr,
subtitle: 'autoConnectDesc'.tr,
icon: Icons.bluetooth_connected,
iconBgColor: isDarkMode
? Colors.blue[900]!.withValues(alpha: 0.3)
: Colors.blue[100]!,
iconColor:
isDarkMode ? Colors.blue[300]! : Colors.blue[600]!,
value: controller.autoConnectEnabled.value,
onChanged: controller.toggleAutoConnect,
isDarkMode: isDarkMode,
)),
Divider(
height: 1,
color: isDarkMode
? const Color(0xFF2C2C2C)
: Colors.grey[200]),
// 广场:默认隐藏,和 opus/恒玄蓝牙测试一样,
// 连点版本号 5 次打开调试区后才出现
Obx(() => controller.showDebugInfo.value
? Column(
children: [
_buildSimpleNavigationSetting(
title: 'tabPlaza'.tr,
subtitle: 'plazaEntryDesc'.tr,
icon: Icons.grid_view_outlined,
iconBgColor: isDarkMode
? Colors.indigo[900]!.withValues(alpha: 0.3)
: Colors.indigo[100]!,
iconColor: isDarkMode
? Colors.indigo[300]!
: Colors.indigo[600]!,
titleColor: isDarkMode ? Colors.white : null,
subtitleColor: isDarkMode ? Colors.white70 : null,
onTap: () => Get.toNamed(Routes.plaza),
isDarkMode: isDarkMode,
),
Divider(
height: 1,
color: isDarkMode
? const Color(0xFF2C2C2C)
: Colors.grey[200]),
],
)
: const SizedBox.shrink()),
// 用户反馈
_buildSimpleNavigationSetting(
title: 'feedback'.tr, // 用户反馈
subtitle: 'feedbackInfo'.tr, // 提供反馈或建议
icon: Icons.feedback_outlined,
iconBgColor: isDarkMode
? Colors.orange[900]!.withValues(alpha: 0.3)
: Colors.orange[100]!,
iconColor:
isDarkMode ? Colors.orange[300]! : Colors.orange[600]!,
titleColor: isDarkMode ? Colors.white : null,
subtitleColor: isDarkMode ? Colors.white70 : null,
onTap: () {
// 打开反馈页面
Get.toNamed(Routes.feedback);
},
isDarkMode: isDarkMode,
),
// if (Platform.isAndroid) ...[
// 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
? const Color(0xFF2C2C2C)
: Colors.grey[200]),
// 「设备管理」已迁移到底部「设备」tab(device_tab.dart)
// // 杰理测试
// _buildSimpleNavigationSetting(
// title: '杰理蓝牙测试',
// subtitle: '测试杰理蓝牙设备扫描、连接和功能',
// icon: Icons.bluetooth,
// iconBgColor: isDarkMode
// ? Colors.blue[900]!.withOpacity(0.3)
// : Colors.blue[100]!,
// iconColor:
// isDarkMode ? Colors.blue[300]! : Colors.blue[600]!,
// titleColor: isDarkMode ? Colors.white : null,
// subtitleColor: isDarkMode ? Colors.white70 : null,
// onTap: () {
// Get.toNamed(Routes.jieliTest);
// },
// isDarkMode: isDarkMode,
// ),
// Divider(
// height: 1,
// color: isDarkMode
// ? Colors.white.withOpacity(0.1)
// : Colors.grey[200]),
// //BLE测试
// 支付测试
// _buildSimpleNavigationSetting(
// title: '支付测试',
// subtitle: '测试微信支付功能',
// icon: Icons.payment,
// iconBgColor: isDarkMode
// ? Colors.green[900]!.withOpacity(0.3)
// : Colors.green[100]!,
// iconColor:
// isDarkMode ? Colors.green[300]! : Colors.green[600]!,
// titleColor: isDarkMode ? Colors.white : null,
// subtitleColor: isDarkMode ? Colors.white70 : null,
// onTap: () {
// Get.toNamed(Routes.payment);
// },
// isDarkMode: isDarkMode,
// ),
// Divider(
// height: 1,
// color: isDarkMode
// ? Colors.white.withOpacity(0.1)
// : Colors.grey[200]),
Obx(() => controller.showDebugInfo.value
? _buildSimpleNavigationSetting(
title: '恒玄蓝牙测试',
subtitle: '测试恒玄(BES)芯片经典蓝牙连接模块',
icon: Icons.bluetooth_connected,
iconBgColor: isDarkMode
? Colors.blue[900]!.withValues(alpha: 0.3)
: Colors.blue[100]!,
iconColor: isDarkMode
? Colors.blue[300]!
: Colors.blue[600]!,
titleColor: isDarkMode ? Colors.white : null,
subtitleColor: isDarkMode ? Colors.white70 : null,
onTap: () {
Get.toNamed(Routes.besTest);
},
isDarkMode: isDarkMode,
)
: const SizedBox.shrink()),
Obx(() => controller.showDebugInfo.value
? _buildSimpleNavigationSetting(
title: 'logExport'.tr,
subtitle: 'logExportDesc'.tr,
icon: Icons.article_outlined,
iconBgColor: isDarkMode
? Colors.orange[900]!.withValues(alpha: 0.3)
: Colors.orange[100]!,
iconColor: isDarkMode
? Colors.orange[300]!
: Colors.orange[600]!,
titleColor: isDarkMode ? Colors.white : null,
subtitleColor: isDarkMode ? Colors.white70 : null,
onTap: () {
Get.toNamed(Routes.logExport);
},
isDarkMode: isDarkMode,
)
: const SizedBox.shrink()),
// Divider(
// height: 1,
// color: isDarkMode
// ? Colors.white.withOpacity(0.1)
// : Colors.grey[200]),
// BLE测试
// _buildSimpleNavigationSetting(
// title: 'BLE蓝牙测试',
// subtitle: '测试BLE蓝牙设备扫描、连接和功能',
// icon: Icons.bluetooth_searching,
// iconBgColor: isDarkMode
// ? Colors.green[900]!.withOpacity(0.3)
// : Colors.green[100]!,
// iconColor:
// isDarkMode ? Colors.green[300]! : Colors.green[600]!,
// titleColor: isDarkMode ? Colors.white : null,
// subtitleColor: isDarkMode ? Colors.white70 : null,
// onTap: () {
// Get.toNamed(Routes.bleTest);
// },
// isDarkMode: isDarkMode,
// ),
// Divider(
// height: 1,
// color: isDarkMode
// ? Colors.white.withOpacity(0.1)
// : Colors.grey[200]),
// // 火山语音测试
// _buildSimpleNavigationSetting(
// title: '语音测试',
// subtitle: '测试语音识别和合成功能,支持多种服务实现',
// icon: Icons.record_voice_over,
// iconBgColor: isDarkMode
// ? Colors.orange[900]!.withOpacity(0.3)
// : Colors.orange[100]!,
// iconColor:
// isDarkMode ? Colors.orange[300]! : Colors.orange[600]!,
// onTap: () => Get.toNamed(Routes.speechTest),
// isDarkMode: isDarkMode,
// ),
// Divider(
// height: 1,
// color: isDarkMode
// ? Colors.white.withOpacity(0.1)
// : Colors.grey[200]),
// 耳机唤醒词设置
// _buildSimpleNavigationSetting(
// title: '唤醒词'.tr, // 唤醒词设置
// subtitle: '唤醒词管理'.tr, // 唤醒词管理
// icon: Icons.voice_chat,
// iconBgColor: isDarkMode
// ? Colors.orange[900]!.withOpacity(0.3)
// : Colors.orange[100]!,
// iconColor:
// isDarkMode ? Colors.orange[300]! : Colors.orange[600]!,
// onTap: () => Get.toNamed(Routes.wakeupvoice),
// isDarkMode: isDarkMode,
// ),
// Divider(
// height: 1,
// color: isDarkMode
// ? Colors.white.withOpacity(0.1)
// : Colors.grey[200]),
// 「固件升级」已迁移到底部「设备」tab(device_tab.dart)
// if (Platform.isAndroid) ...[
Divider(
height: 1,
color: isDarkMode
? const Color(0xFF2C2C2C)
: Colors.grey[200]),
// 权限管理设置项
_buildSimpleNavigationSetting(
title: 'permissionManagement'.tr, // 权限管理
subtitle: 'permissionManagementInfo'.tr, // 管理应用权限设置
icon: Icons.security,
iconBgColor: isDarkMode
? Colors.orange[900]!.withValues(alpha: 0.3)
: Colors.orange[100]!,
iconColor:
isDarkMode ? Colors.orange[300]! : Colors.orange[600]!,
titleColor: isDarkMode ? Colors.white : null,
subtitleColor: isDarkMode ? Colors.white70 : null,
onTap: () {
Get.toNamed(Routes.permissions);
},
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 ? const Color(0xFF1E1E1E) : Colors.white,
borderRadius: BorderRadius.circular(16.r),
border: isDarkMode
? Border.all(color: const Color(0xFF2C2C2C), width: 1)
: null,
boxShadow: [
BoxShadow(
color: isDarkMode
? Colors.black.withValues(alpha: 0.4)
: Colors.black.withValues(alpha: 0.06),
blurRadius: 12,
offset: const Offset(0, 2),
),
],
),
clipBehavior: Clip.antiAlias,
child: Row(
children: [
// 左侧应用信息区域 - 使用固定宽度
Row(
children: [
GestureDetector(
onTap: controller.handleSecretTap, // 点击事件
// 关于应用的 logo:用 App 自己的图标,替掉原来的
// 「蓝紫渐变 + 耳机 glyph」。asset 是无圆角正方形,
// 圆角由 ClipRRect 切(与启动页同一张图、同一套做法)。
child: ClipRRect(
borderRadius: BorderRadius.circular(12.r),
child: Image.asset(
'assets/images/app_icon.png',
width: 40.w,
height: 40.w,
fit: BoxFit.cover,
),
),
),
SizedBox(width: 12.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Eaimar',
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w500,
color: isDarkMode ? Colors.white : Colors.black87,
),
),
SizedBox(height: 2.h),
Obx(() => Text(
// 如果版本信息为空,显示加载中
controller.appVersion.value.isEmpty
? '${'versions'.tr} ${'loading'.tr}' // 版本 加载中
: '${'versions'.tr} ${controller.appVersion.value} (Build ${controller.buildNumber.value})', // 版本号
style: TextStyle(
fontSize: 12.sp,
color:
isDarkMode ? Colors.white70 : Colors.black54,
),
)),
],
),
],
),
// 间距
SizedBox(width: 16.w),
// 右侧检查更新按钮 - 使用Expanded确保充分利用剩余空间
Expanded(
child: InkWell(
onTap: () {
// 调用检查更新方法
controller.checkForUpdate();
},
child: Container(
constraints: BoxConstraints(
minHeight: 36.h, // 设置最小高度而不是宽度约束
),
padding: EdgeInsets.symmetric(
horizontal: 12.w,
vertical: 8.h,
),
decoration: BoxDecoration(
color: isDarkMode
? Colors.blue[900]!.withValues(alpha: 0.3)
: Colors.blue[100],
borderRadius: BorderRadius.circular(16.r),
),
child: Center(
child: FittedBox(
fit: BoxFit.scaleDown, // 如果文本过长,自动缩小字体
child: Text(
'checkUpdates'.tr, // 检查更新
style: TextStyle(
fontSize: 12.sp,
color: isDarkMode
? Colors.blue[300]
: Colors.blue[600],
height: 1.2, // 稍微减少行高,适应FittedBox
),
textAlign: TextAlign.center,
maxLines: 2, // 最多显示2行,配合FittedBox使用
),
),
),
),
),
),
],
),
),
SizedBox(height: 16.h),
Center(
child: Column(
children: [
Text(
'© 2026 Eaimar 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],
),
),
SizedBox(height: 4.h),
if (Get.locale?.languageCode == 'zh' &&
Get.locale?.countryCode == 'CN')
InkWell(
onTap: () => Get.to(
() => WebViewPage(
url: 'https://beian.miit.gov.cn',
title: 'icpFiling'.tr,
),
),
child: Text(
'粤ICP备2026091470号-2A',
style: TextStyle(
fontSize: 12.sp,
color: isDarkMode ? Colors.grey[400] : Colors.grey[500],
),
),
),
],
),
),
// 隐藏的调试信息
Obx(() => controller.showDebugInfo.value
? Container(
margin: EdgeInsets.only(top: 12.h),
padding: EdgeInsets.all(12.w),
decoration: BoxDecoration(
color: isDarkMode ? Colors.grey[800] : Colors.grey[100],
borderRadius: BorderRadius.circular(8.r),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'版本服务调试信息',
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.bold,
color: isDarkMode ? Colors.white : Colors.black,
),
),
SizedBox(height: 8.h),
Text(
controller.getSomeAppInfo(),
style: TextStyle(
fontSize: 10.sp,
fontFamily: 'monospace',
color: isDarkMode ? Colors.white70 : Colors.black87,
),
),
],
),
)
: const SizedBox.shrink()),
],
);
}
// 开关类设置项
Widget _buildToggleSetting({
required String title,
String? subtitle,
required IconData icon,
required Color iconBgColor,
required Color iconColor,
required bool value,
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,
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, // 确保文本完全显示
),
],
),
),
],
),
),
Switch(
value: value,
onChanged: onChanged,
activeColor: Colors.blue[600],
),
],
),
);
}
// 简单导航设置项
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),
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: subtitleColor ??
(isDarkMode
? Colors.white70
: Colors.black54),
height: 1.3, // 设置行高,提升多行文本可读性
),
softWrap: true, // 启用软换行
overflow: TextOverflow.visible, // 确保文本完全显示
),
],
),
),
],
),
),
Container(
width: 32.w,
height: 32.w,
decoration: BoxDecoration(
color: isDarkMode
? Colors.white.withValues(alpha: 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 _showLanguageSelectionDialog(bool isDarkMode) {
Get.dialog(
Dialog(
backgroundColor: isDarkMode ? Colors.grey[900] : Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.r),
),
child: Padding(
padding: EdgeInsets.all(12.w),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'selectLanguage'.tr, // 选择语言
style: TextStyle(
fontSize: 18.sp,
fontWeight: FontWeight.w600,
color: isDarkMode ? Colors.white : Colors.black87,
),
),
SizedBox(height: 16.h),
Container(
constraints: BoxConstraints(maxHeight: 0.5.sh),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: controller.languageList.map((languageOption) {
return Obx(() {
final isSelected =
controller.currentLanguage.value.value ==
languageOption.value;
return GestureDetector(
onTap: () {
controller.setLanguage(languageOption);
Get.back();
},
child: Container(
margin: EdgeInsets.only(bottom: 10.h),
padding: EdgeInsets.all(10.w),
decoration: BoxDecoration(
color: isSelected
? (isDarkMode
? Colors.teal[900]!.withValues(alpha: 0.3)
: Colors.teal[50]!)
: (isDarkMode
? Colors.white.withValues(alpha: 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: Text(
languageOption.name.tr, // 语言名称
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w500,
color: isDarkMode
? Colors.white
: Colors.black87,
),
overflow: TextOverflow.ellipsis,
),
),
Text(
languageOption.alias, // 语言别名(原始名称,不加.tr)
style: TextStyle(
fontSize: 14.sp,
color: isDarkMode
? Colors.white70
: Colors.black54,
),
),
SizedBox(width: 10.w),
Container(
width: 24.w,
height: 24.w,
decoration: BoxDecoration(
color: isSelected
? (isDarkMode
? Colors.teal[300]
: Colors.teal[600])
: (isDarkMode
? Colors.white
.withValues(alpha: 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,
),
),
),
],
),
],
),
),
),
);
}
}