diff --git a/lib/modules/home/bindings/home_binding.dart b/lib/modules/home/bindings/home_binding.dart index a8dae0b27..5f976a98b 100644 --- a/lib/modules/home/bindings/home_binding.dart +++ b/lib/modules/home/bindings/home_binding.dart @@ -1,6 +1,5 @@ import '../../explore/controllers/explore_controller.dart'; import 'package:get/get.dart'; -import '../../explore/controllers/explore_controller.dart'; import '../controllers/home_controller.dart'; class HomeBinding extends Bindings { diff --git a/lib/modules/home/views/home_view.dart b/lib/modules/home/views/home_view.dart index abdb2f920..8c10c7d03 100644 --- a/lib/modules/home/views/home_view.dart +++ b/lib/modules/home/views/home_view.dart @@ -160,43 +160,43 @@ class HomeView extends GetView { child: ClipRRect( // 添加 ClipRRect 来实现圆角 borderRadius: BorderRadius.circular(16.r), // 使用与其他部件一致的圆角大小 - child: SizedBox( - width: double.infinity, - height: 200.h, - child: Image.asset( - isDarkMode - ? 'assets/images/robot_light.png' - : 'assets/images/robot_light.png', - fit: BoxFit.fitWidth, + child: SizedBox( + width: double.infinity, + height: 200.h, + child: Image.asset( + isDarkMode + ? 'assets/images/robot_light.png' + : 'assets/images/robot_light.png', + fit: BoxFit.fitWidth, + ), ), ), ), - ), Center( child: ClipRRect( // 添加 ClipRRect borderRadius: BorderRadius.circular(16.r), - child: Image.asset( - isDarkMode - ? 'assets/images/headphone_dark.png' - : 'assets/images/headphone_light.png', - height: 180.h, - fit: BoxFit.contain, + child: Image.asset( + isDarkMode + ? 'assets/images/headphone_dark.png' + : 'assets/images/headphone_light.png', + height: 180.h, + fit: BoxFit.contain, + ), ), ), - ), Center( child: ClipRRect( // 添加 ClipRRect borderRadius: BorderRadius.circular(16.r), - child: SizedBox( - width: double.infinity, - height: 200.h, - child: Image.asset( - isDarkMode - ? 'assets/images/glasses_light.png' - : 'assets/images/glasses_light.png', - fit: BoxFit.fitWidth, + child: SizedBox( + width: double.infinity, + height: 200.h, + child: Image.asset( + isDarkMode + ? 'assets/images/glasses_light.png' + : 'assets/images/glasses_light.png', + fit: BoxFit.fitWidth, ), ), ), @@ -283,50 +283,52 @@ class HomeView extends GetView { ], ), Obx(() => Row( - children: [ - Container( - width: 8.w, - height: 8.w, - decoration: BoxDecoration( - color: controller.getConnectionStatusColor(), - shape: BoxShape.circle, - boxShadow: [ - BoxShadow( - color: controller.getConnectionStatusColor().withOpacity(0.3), - blurRadius: 4, - spreadRadius: 1, + children: [ + Container( + width: 8.w, + height: 8.w, + decoration: BoxDecoration( + color: controller.getConnectionStatusColor(), + shape: BoxShape.circle, + boxShadow: [ + BoxShadow( + color: controller + .getConnectionStatusColor() + .withOpacity(0.3), + blurRadius: 4, + spreadRadius: 1, + ), + ], ), - ], - ), - ), - SizedBox(width: 4.w), - Text( - controller.getConnectionStatusText(), - style: TextStyle( - fontSize: 12.sp, - color: controller.getConnectionStatusColor(), - ), - ), - // 添加刷新按钮 - SizedBox(width: 8.w), - InkWell( - onTap: () => controller.refreshDeviceConnection(), - borderRadius: BorderRadius.circular(12.r), - child: Container( - padding: EdgeInsets.all(4.w), - decoration: BoxDecoration( - color: isDarkMode ? Colors.grey[800] : Colors.grey[200], - shape: BoxShape.circle, ), - child: Icon( - Icons.refresh, - size: 14.sp, - color: isDarkMode ? Colors.grey[400] : Colors.grey[600], + SizedBox(width: 4.w), + Text( + controller.getConnectionStatusText(), + style: TextStyle( + fontSize: 12.sp, + color: controller.getConnectionStatusColor(), + ), ), - ), - ), - ], - )), + // 添加刷新按钮 + SizedBox(width: 8.w), + InkWell( + onTap: () => controller.refreshDeviceConnection(), + borderRadius: BorderRadius.circular(12.r), + child: Container( + padding: EdgeInsets.all(4.w), + decoration: BoxDecoration( + color: isDarkMode ? Colors.grey[800] : Colors.grey[200], + shape: BoxShape.circle, + ), + child: Icon( + Icons.refresh, + size: 14.sp, + color: isDarkMode ? Colors.grey[400] : Colors.grey[600], + ), + ), + ), + ], + )), ], ); } @@ -338,9 +340,8 @@ class HomeView extends GetView { Container( padding: EdgeInsets.all(12.w), decoration: BoxDecoration( - color: isDarkMode - ? Colors.red[900]!.withOpacity(0.2) - : Colors.red[50], + color: + isDarkMode ? Colors.red[900]!.withOpacity(0.2) : Colors.red[50], borderRadius: BorderRadius.circular(12.r), border: Border.all( color: isDarkMode ? Colors.red[800]! : Colors.red[200]!), @@ -440,12 +441,12 @@ class HomeView extends GetView { final leftBattery = controller.leftEarBattery; final rightBattery = controller.rightEarBattery; final caseBattery = controller.caseBattery; - + // 获取充电状态 final leftEarCharging = controller.leftEarCharging; final rightEarCharging = controller.rightEarCharging; final caseCharging = controller.caseCharging; - + return GridView.count( crossAxisCount: 3, shrinkWrap: true, @@ -461,7 +462,7 @@ class HomeView extends GetView { isCharging: leftEarCharging, isDarkMode: isDarkMode, ), - + // 右耳机 _buildBatteryGridItem( icon: Icons.headphones, @@ -470,7 +471,7 @@ class HomeView extends GetView { isCharging: rightEarCharging, isDarkMode: isDarkMode, ), - + // 充电盒 _buildBatteryGridItem( icon: Icons.charging_station, @@ -483,7 +484,7 @@ class HomeView extends GetView { ); }); } - + // 单个电池网格项 Widget _buildBatteryGridItem({ required IconData icon, @@ -495,7 +496,7 @@ class HomeView extends GetView { // 获取电池图标和颜色 IconData batteryIcon; Color batteryColor; - + if (batteryLevel > 75) { batteryIcon = Icons.battery_full; batteryColor = Colors.green[600]!; @@ -512,16 +513,16 @@ class HomeView extends GetView { batteryIcon = Icons.battery_alert; batteryColor = Colors.red[600]!; } - + return Container( decoration: BoxDecoration( color: isDarkMode ? Colors.grey[900] : Colors.grey[100], borderRadius: BorderRadius.circular(12.r), boxShadow: [ BoxShadow( - color: isDarkMode ? - Colors.black.withOpacity(0.1) : - Colors.grey.withOpacity(0.1), + color: isDarkMode + ? Colors.black.withOpacity(0.1) + : Colors.grey.withOpacity(0.1), blurRadius: 4, spreadRadius: 0, offset: Offset(0, 2), @@ -545,7 +546,7 @@ class HomeView extends GetView { ), ), SizedBox(height: 6.h), - + // 标签 Text( label, @@ -557,7 +558,7 @@ class HomeView extends GetView { textAlign: TextAlign.center, ), SizedBox(height: 6.h), - + // 电池指示器 Row( mainAxisAlignment: MainAxisAlignment.center, @@ -614,7 +615,7 @@ class HomeView extends GetView { isDarkMode: isDarkMode, ), SizedBox(height: 8.h), - + // 固件版本 _buildInfoRow( icon: Icons.info_outline, @@ -622,8 +623,7 @@ class HomeView extends GetView { value: controller.firmwareVersion, isDarkMode: isDarkMode, ), - - + // 连接状态标签 SizedBox(height: 10.h), Container( @@ -763,7 +763,7 @@ class HomeView extends GetView { ), ); } - + // 热门AI体验标题 Widget _buildSectionTitle(bool isDarkMode) { return Row( diff --git a/lib/modules/profile/controllers/profile_controller.dart b/lib/modules/profile/controllers/profile_controller.dart index d3e2645ea..5bee74c6d 100644 --- a/lib/modules/profile/controllers/profile_controller.dart +++ b/lib/modules/profile/controllers/profile_controller.dart @@ -1,7 +1,6 @@ import 'package:get/get.dart'; import 'package:get_storage/get_storage.dart'; import 'package:flutter/material.dart'; -//import 'package:http/http.dart'; import 'package:image_picker/image_picker.dart'; import 'package:logger/logger.dart'; import '../../../data/models/user_Info.dart'; @@ -19,26 +18,17 @@ import '../../../modules/login/controllers/facebookLogin.dart'; class ProfileController extends GetxController { static ProfileController get to => Get.find(); - // final _userName = ''.obs; - // final _email = ''.obs; - // final _avatar = ''.obs; - // final _isEditing = false.obs; - // final _storage = GetStorage(); //用户信息 static const String userKey = 'user_info'; //用户信息存储键 final _storage = GetStorage(); //本地存储 final ImagePicker _picker = ImagePicker(); //图片选择器 final Rx userInfo = User.instance.obs; // 响应式用户信息对象,使用单例模式确保全局唯一性 final RxString localAvatar = ''.obs; // 本地头像路径,便于响应式更新UI + final RxBool hasEdits = false.obs; // 是否有编辑 // 使用响应式变量 final currentLanguage = 'zh'.obs; - // String get userName => _userName.value; - // String get email => _email.value; - // String get avatar => _avatar.value; - // bool get isEditing => _isEditing.value; - @override void onInit() { super.onInit(); @@ -46,16 +36,6 @@ class ProfileController extends GetxController { loadLanguagePreference(); } - // void loadUserData() { - // try { - // _userName.value = _storage.read('userName') ?? 'User Name'; - // _email.value = _storage.read('userEmail') ?? 'user@example.com'; - // _avatar.value = _storage.read('userAvatar') ?? ''; - // } catch (e) { - // Get.snackbar('Error', 'Failed to load user data'); - // } - // } - // 加载用户语言偏好设置 void loadLanguagePreference() { try { @@ -332,6 +312,7 @@ class ProfileController extends GetxController { // if (Get.isRegistered()) { // Get.find().loadUserInfo(); // } + hasEdits.value = true; //表示有编辑 } } diff --git a/lib/modules/profile/views/profile_view.dart b/lib/modules/profile/views/profile_view.dart index a2acf36da..23b3e38ef 100644 --- a/lib/modules/profile/views/profile_view.dart +++ b/lib/modules/profile/views/profile_view.dart @@ -9,130 +9,130 @@ import 'dart:ui'; import '../../common/webview_page.dart'; // ProfileView: 用户设置页面 -class ProfileView extends GetView { - const ProfileView({Key? key}) : super(key: key); +// class ProfileView extends GetView { +// const ProfileView({Key? key}) : super(key: key); - Widget _buildMenuItem({ - required String title, - required IconData icon, - String? subtitle, - required VoidCallback onTap, - }) { - return ListTile( - leading: Icon(icon, size: 24.sp, color: Colors.grey[700]), - title: Text( - title, - style: TextStyle( - fontSize: 16.sp, - fontWeight: FontWeight.w500, - ), - ), - subtitle: subtitle != null - ? Text( - subtitle, - style: TextStyle( - fontSize: 14.sp, - color: Colors.grey[600], - ), - ) - : null, - trailing: Icon( - Icons.chevron_right, - size: 24.sp, - color: Colors.grey[400], - ), - onTap: onTap, - ); - } +// Widget _buildMenuItem({ +// required String title, +// required IconData icon, +// String? subtitle, +// required VoidCallback onTap, +// }) { +// return ListTile( +// leading: Icon(icon, size: 24.sp, color: Colors.grey[700]), +// title: Text( +// title, +// style: TextStyle( +// fontSize: 16.sp, +// fontWeight: FontWeight.w500, +// ), +// ), +// subtitle: subtitle != null +// ? Text( +// subtitle, +// style: TextStyle( +// fontSize: 14.sp, +// color: Colors.grey[600], +// ), +// ) +// : null, +// trailing: Icon( +// Icons.chevron_right, +// size: 24.sp, +// color: Colors.grey[400], +// ), +// onTap: onTap, +// ); +// } - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: Colors.white, - appBar: AppBar( - backgroundColor: Colors.white, - elevation: 0, - title: Text( - '设置'.tr, - style: TextStyle( - fontSize: 17.sp, - fontWeight: FontWeight.w600, - color: Colors.black, - ), - ), - centerTitle: true, - ), - body: ListView( - children: [ - SizedBox(height: 12.h), - const Divider(), - _buildMenuItem( - title: '关于'.tr, - icon: Icons.info_outline, - onTap: () { - // TODO: 实现关于页面 - }, - ), - const Divider(), - _buildMenuItem( - title: '火山语音合成测试'.tr, - icon: Icons.record_voice_over, - subtitle: '测试火山语音TTS功能', - onTap: () { - Get.toNamed(Routes.TTS_TEST); - }, - ), - const Divider(), - _buildMenuItem( - title: '火山语音识别测试'.tr, - icon: Icons.mic_external_on, - subtitle: '测试火山语音ASR功能', - onTap: () { - Get.toNamed(Routes.VOLCANO_ASR_TEST); - }, - ), - const Divider(), - _buildMenuItem( - title: 'Azure语音识别测试'.tr, - icon: Icons.mic, - subtitle: '测试Azure语音ASR功能', - onTap: () { - Get.toNamed(Routes.AZURE_ASR_TEST); - }, - ), - const Divider(), - _buildMenuItem( - title: 'Azure语音合成测试'.tr, - icon: Icons.record_voice_over, - subtitle: '测试Azure语音TTS功能', - onTap: () { - Get.toNamed(Routes.AZURE_TTS_TEST); - }, - ), - const Divider(), - _buildMenuItem( - title: '本地语音合成测试'.tr, - icon: Icons.speaker_phone, - subtitle: '测试Flutter TTS本地语音合成功能', - onTap: () { - Get.toNamed(Routes.FLUTTER_TTS_TEST); - }, - ), - const Divider(), - _buildMenuItem( - title: '本地语音识别测试'.tr, - icon: Icons.mic_none, - subtitle: '测试Flutter本地语音识别功能', - onTap: () { - Get.toNamed(Routes.FLUTTER_ASR_TEST); - }, - ), - ], - ), - bottomNavigationBar: const CommonBottomNav(currentIndex: 2), - ); - } -} +// @override +// Widget build(BuildContext context) { +// return Scaffold( +// backgroundColor: Colors.white, +// appBar: AppBar( +// backgroundColor: Colors.white, +// elevation: 0, +// title: Text( +// '设置'.tr, +// style: TextStyle( +// fontSize: 17.sp, +// fontWeight: FontWeight.w600, +// color: Colors.black, +// ), +// ), +// centerTitle: true, +// ), +// body: ListView( +// children: [ +// SizedBox(height: 12.h), +// const Divider(), +// _buildMenuItem( +// title: '关于'.tr, +// icon: Icons.info_outline, +// onTap: () { +// // TODO: 实现关于页面 +// }, +// ), +// const Divider(), +// _buildMenuItem( +// title: '火山语音合成测试'.tr, +// icon: Icons.record_voice_over, +// subtitle: '测试火山语音TTS功能', +// onTap: () { +// Get.toNamed(Routes.TTS_TEST); +// }, +// ), +// const Divider(), +// _buildMenuItem( +// title: '火山语音识别测试'.tr, +// icon: Icons.mic_external_on, +// subtitle: '测试火山语音ASR功能', +// onTap: () { +// Get.toNamed(Routes.VOLCANO_ASR_TEST); +// }, +// ), +// const Divider(), +// _buildMenuItem( +// title: 'Azure语音识别测试'.tr, +// icon: Icons.mic, +// subtitle: '测试Azure语音ASR功能', +// onTap: () { +// Get.toNamed(Routes.AZURE_ASR_TEST); +// }, +// ), +// const Divider(), +// _buildMenuItem( +// title: 'Azure语音合成测试'.tr, +// icon: Icons.record_voice_over, +// subtitle: '测试Azure语音TTS功能', +// onTap: () { +// Get.toNamed(Routes.AZURE_TTS_TEST); +// }, +// ), +// const Divider(), +// _buildMenuItem( +// title: '本地语音合成测试'.tr, +// icon: Icons.speaker_phone, +// subtitle: '测试Flutter TTS本地语音合成功能', +// onTap: () { +// Get.toNamed(Routes.FLUTTER_TTS_TEST); +// }, +// ), +// const Divider(), +// _buildMenuItem( +// title: '本地语音识别测试'.tr, +// icon: Icons.mic_none, +// subtitle: '测试Flutter本地语音识别功能', +// onTap: () { +// Get.toNamed(Routes.FLUTTER_ASR_TEST); +// }, +// ), +// ], +// ), +// bottomNavigationBar: const CommonBottomNav(currentIndex: 2), +// ); +// } +// } // EditProfileView: 编辑个人资料页面 class EditProfileView extends GetView { @@ -146,19 +146,19 @@ class EditProfileView extends GetView { return Scaffold( resizeToAvoidBottomInset: false, // 添加这一行,防止键盘挤压内容 - appBar: AppBar( - automaticallyImplyLeading: false, - centerTitle: true, - elevation: 0, - backgroundColor: isDarkMode ? Colors.black : Colors.white, - leading: IconButton( - icon: Icon( - Icons.arrow_back_ios, - size: 20.sp, - color: isDarkMode? Colors.white : Colors.black, + appBar: AppBar( + automaticallyImplyLeading: false, + centerTitle: true, + elevation: 0, + backgroundColor: isDarkMode ? Colors.black : Colors.white, + leading: IconButton( + icon: Icon( + Icons.arrow_back_ios, + size: 20.sp, + color: isDarkMode ? Colors.white : Colors.black, + ), + onPressed: () => Get.back(), ), - onPressed: () => Get.back(), - ), // title: Text( // 'editProfile'.tr, // style: TextStyle( @@ -168,22 +168,25 @@ class EditProfileView extends GetView { // ), // ), actions: [ - TextButton( - onPressed: () { - // 保存用户名 - controller.updateUserNameAndAvatar(nameController.text); - // 返回上一级页面 - Get.back(); - }, - child: Text( - 'save'.tr, - style: TextStyle( - fontSize: 16.sp, - color: isDarkMode ? Colors.blue[300] : Colors.blue, - fontWeight: FontWeight.w500, - ), - ), - ), + Obx(() => Visibility( + visible: controller.hasEdits.value, + child: TextButton( + onPressed: () { + // 保存用户名 + controller.updateUserNameAndAvatar(nameController.text); + // 返回上一级页面 + Get.back(); + }, + child: Text( + 'save'.tr, + style: TextStyle( + fontSize: 16.sp, + color: isDarkMode ? Colors.blue[300] : Colors.blue, + fontWeight: FontWeight.w500, + ), + ), + ), + )) ], ), body: Padding( @@ -472,6 +475,12 @@ class EditProfileView extends GetView { onPressed: () { // 确认时,将对话框输入的值更新回主 nameController nameController.text = dialogNameController.text; + controller.userInfo.update((user) { + if (user != null) { + user.name = dialogNameController.text; + } + }); + controller.hasEdits.value = true; // 标记已编辑 Get.back(); // 关闭对话框 // 注意:实际的保存操作由 AppBar 中的保存按钮触发 }, diff --git a/lib/modules/settings/views/settings_view.dart b/lib/modules/settings/views/settings_view.dart index eb7ea7512..350b91b1b 100644 --- a/lib/modules/settings/views/settings_view.dart +++ b/lib/modules/settings/views/settings_view.dart @@ -62,156 +62,155 @@ class SettingsView extends GetView { return GestureDetector( onTap: () => Get.toNamed(Routes.editProfile), child: 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), + 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, ), - ], - ), - 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(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), - child: controller.userInfo.value.avatar.isEmpty - ? - Container( - decoration: BoxDecoration( - color: Colors.blue[600], - borderRadius: BorderRadius.circular(30.r), - ), - child: Center( - child: Text( - controller - .userInfo.value.name.isNotEmpty - ? controller.userInfo.value.name[0] - .toUpperCase() - : '?', - style: TextStyle( - color: Colors.white, - fontSize: 24.sp, - fontWeight: FontWeight.bold, - ), + 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 + ? Container( + decoration: BoxDecoration( + color: Colors.blue[600], + borderRadius: BorderRadius.circular(30.r), ), - ), - ) - : Image.network( - controller.userInfo.value.avatar, - fit: BoxFit.cover, - errorBuilder: (context, error, stackTrace) { - // 当图片加载失败时显示用户名首字母 - return Container( - decoration: BoxDecoration( - color: Colors.blue[600], - borderRadius: - BorderRadius.circular(30.r), + child: Center( + child: Text( + controller + .userInfo.value.name.isNotEmpty + ? controller.userInfo.value.name[0] + .toUpperCase() + : '?', + style: TextStyle( + color: Colors.white, + fontSize: 24.sp, + fontWeight: FontWeight.bold, + ), ), - child: Center( - child: Text( - controller.userInfo.value.name - .isNotEmpty - ? controller - .userInfo.value.name[0] - .toUpperCase() - : '?', - style: TextStyle( - color: Colors.white, - fontSize: 24.sp, - fontWeight: FontWeight.bold, + ), + ) + : Image.network( + controller.userInfo.value.avatar, + fit: BoxFit.cover, + errorBuilder: (context, error, stackTrace) { + // 当图片加载失败时显示用户名首字母 + return Container( + decoration: BoxDecoration( + color: Colors.blue[600], + borderRadius: + BorderRadius.circular(30.r), + ), + child: Center( + child: Text( + controller.userInfo.value.name + .isNotEmpty + ? controller + .userInfo.value.name[0] + .toUpperCase() + : '?', + style: TextStyle( + color: Colors.white, + fontSize: 24.sp, + fontWeight: FontWeight.bold, + ), ), ), - ), - ); - }, - )), - ), - )), - 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: 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( @@ -225,46 +224,46 @@ class SettingsView extends GetView { // overflow: TextOverflow.ellipsis, // ), // ), - ], - ), - SizedBox(height: 4.h), - Text( + ], + ), + SizedBox(height: 4.h), + Text( 'ID:${controller.userInfo.value.uid}', - style: TextStyle( - fontSize: 12.sp, - color: isDarkMode ? Colors.white70 : Colors.black54, + 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], + 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], + ), + )), + ], ), ), ), @@ -572,7 +571,7 @@ class SettingsView extends GetView { _buildSimpleNavigationSetting( title: 'ota升级', subtitle: '测试ble耳机固件版本升级', - icon: Icons.record_voice_over, + icon: Icons.system_update_alt, iconBgColor: isDarkMode ? Colors.orange[900]!.withOpacity(0.3) : Colors.orange[100]!, @@ -581,11 +580,11 @@ class SettingsView extends GetView { onTap: () => Get.toNamed(Routes.OTA_UPGRADE), isDarkMode: isDarkMode, ), - Divider( - height: 1, - color: isDarkMode - ? Colors.white.withOpacity(0.1) - : Colors.grey[200]), + // Divider( + // height: 1, + // color: isDarkMode + // ? Colors.white.withOpacity(0.1) + // : Colors.grey[200]), // 退出登录 // _buildSimpleNavigationSetting( diff --git a/lib/routes/app_pages.dart b/lib/routes/app_pages.dart index 8f36c4510..fe3576f12 100644 --- a/lib/routes/app_pages.dart +++ b/lib/routes/app_pages.dart @@ -103,13 +103,13 @@ abstract class AppPages { page: () => const OtaUpgradeView(), binding: OtaUpgradeBinding(), ), - GetPage( - name: Routes.profile, - page: () => const ProfileView(), - binding: ProfileBinding(), - transition: Transition.rightToLeft, - transitionDuration: Duration(milliseconds: 250), - ), + // GetPage( + // name: Routes.profile, + // page: () => const ProfileView(), + // binding: ProfileBinding(), + // transition: Transition.rightToLeft, + // transitionDuration: Duration(milliseconds: 250), + // ), GetPage( name: Routes.editProfile, page: () => const EditProfileView(), diff --git a/lib/routes/app_routes.dart b/lib/routes/app_routes.dart index d44a5616c..08500199f 100644 --- a/lib/routes/app_routes.dart +++ b/lib/routes/app_routes.dart @@ -1,35 +1,48 @@ abstract class Routes { + // 认证相关 static const splash = '/splash'; static const login = '/login'; static const pairing = '/pairing'; + + // 主功能模块 static const initial = '/home'; static const home = '/home'; static const explore = '/explore'; static const chat = '/chat'; - static const OTA_UPGRADE = '/ota_upgrade'; - static const recording = '/recording'; static const profile = '/profile'; - static const meeting = '/meeting'; - static const meetingRecord = '/meetingRecord'; - static const meetingDetails = '/meetingDetails'; - static const meetingEdit = '/meetingEdit'; - static const timbre = '/timbre'; - static const settings = '/settings'; - static const speechDemo = '/speech_demo'; - static const TTS_TEST = '/tts_test'; - static const ASR_TEST = '/asr_test'; - static const AZURE_ASR_TEST = '/azure_asr_test'; - static const AZURE_TTS_TEST = '/azure_tts_test'; - static const VOLCANO_ASR_TEST = '/volcano_asr_test'; - static const translation = '/translation'; - static const translationHistory = '/translation_history'; - static const FLUTTER_TTS_TEST = '/flutter_tts_test'; - static const FLUTTER_ASR_TEST = '/flutter_asr_test'; static const editProfile = '/edit_profile'; - static const feedback = '/feedback'; - static const jieliTest = '/jieli_test'; - static const opusTest = '/opus_test'; - static const bleTest = '/ble_test'; - static const speechTest = '/speech_test'; - static const agent = '/agent'; + + // 设备管理 + static const OTA_UPGRADE = '/ota_upgrade'; // OTA升级 + static const timbre = '/timbre'; // 音色设置 + static const settings = '/settings'; // 系统设置 + static const recording = '/recording'; // 录音功能 + + // 会议相关 + static const meeting = '/meeting'; + static const meetingRecord = '/meeting_record'; // 会议记录 + static const meetingDetails = '/meeting_details'; // 会议详情 + static const meetingEdit = '/meeting_edit'; // 会议编辑 + + // 语言功能 + static const translation = '/translation'; // 实时翻译 + static const translationHistory = '/translation_history'; // 翻译历史 + static const speechDemo = '/speech_demo'; // 语音演示 + + // 测试路由(生产环境建议移除) + static const ttsTest = '/tts_test'; // 文字转语音测试 + static const asrTest = '/asr_test'; // 语音识别测试 + static const azureAsrTest = '/azure_asr_test'; // Azure语音识别 + static const azureTtsTest = '/azure_tts_test'; // Azure文字转语音 + static const volcanoAsrTest = '/volcano_asr_test'; // 火山引擎语音识别 + static const flutterTtsTest = '/flutter_tts_test'; // Flutter TTS测试 + static const flutterAsrTest = '/flutter_asr_test'; // Flutter ASR测试 + static const jieliTest = '/jieli_test'; // 杰理芯片测试 + static const opusTest = '/opus_test'; // Opus编码测试 + static const bleTest = '/ble_test'; // 蓝牙测试 + static const speechTest = '/speech_test'; // 综合语音测试 + + // 支持服务 + static const feedback = '/feedback'; // 用户反馈 + static const agent = '/agent'; // 在线客服 }