Browse Source

refactor: 清理代码并优化路由和用户资料编辑功能

newdev_shunjiawei
lxm 1 year ago
parent
commit
62fa015977
  1. 1
      lib/modules/home/bindings/home_binding.dart
  2. 168
      lib/modules/home/views/home_view.dart
  3. 23
      lib/modules/profile/controllers/profile_controller.dart
  4. 309
      lib/modules/profile/views/profile_view.dart
  5. 365
      lib/modules/settings/views/settings_view.dart
  6. 14
      lib/routes/app_pages.dart
  7. 61
      lib/routes/app_routes.dart

1
lib/modules/home/bindings/home_binding.dart

@ -1,6 +1,5 @@
import '../../explore/controllers/explore_controller.dart'; import '../../explore/controllers/explore_controller.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../../explore/controllers/explore_controller.dart';
import '../controllers/home_controller.dart'; import '../controllers/home_controller.dart';
class HomeBinding extends Bindings { class HomeBinding extends Bindings {

168
lib/modules/home/views/home_view.dart

@ -160,43 +160,43 @@ class HomeView extends GetView<HomeController> {
child: ClipRRect( child: ClipRRect(
// 添加 ClipRRect 来实现圆角 // 添加 ClipRRect 来实现圆角
borderRadius: BorderRadius.circular(16.r), // 使用与其他部件一致的圆角大小 borderRadius: BorderRadius.circular(16.r), // 使用与其他部件一致的圆角大小
child: SizedBox( child: SizedBox(
width: double.infinity, width: double.infinity,
height: 200.h, height: 200.h,
child: Image.asset( child: Image.asset(
isDarkMode isDarkMode
? 'assets/images/robot_light.png' ? 'assets/images/robot_light.png'
: 'assets/images/robot_light.png', : 'assets/images/robot_light.png',
fit: BoxFit.fitWidth, fit: BoxFit.fitWidth,
),
), ),
), ),
), ),
),
Center( Center(
child: ClipRRect( child: ClipRRect(
// 添加 ClipRRect // 添加 ClipRRect
borderRadius: BorderRadius.circular(16.r), borderRadius: BorderRadius.circular(16.r),
child: Image.asset( child: Image.asset(
isDarkMode isDarkMode
? 'assets/images/headphone_dark.png' ? 'assets/images/headphone_dark.png'
: 'assets/images/headphone_light.png', : 'assets/images/headphone_light.png',
height: 180.h, height: 180.h,
fit: BoxFit.contain, fit: BoxFit.contain,
),
), ),
), ),
),
Center( Center(
child: ClipRRect( child: ClipRRect(
// 添加 ClipRRect // 添加 ClipRRect
borderRadius: BorderRadius.circular(16.r), borderRadius: BorderRadius.circular(16.r),
child: SizedBox( child: SizedBox(
width: double.infinity, width: double.infinity,
height: 200.h, height: 200.h,
child: Image.asset( child: Image.asset(
isDarkMode isDarkMode
? 'assets/images/glasses_light.png' ? 'assets/images/glasses_light.png'
: 'assets/images/glasses_light.png', : 'assets/images/glasses_light.png',
fit: BoxFit.fitWidth, fit: BoxFit.fitWidth,
), ),
), ),
), ),
@ -283,50 +283,52 @@ class HomeView extends GetView<HomeController> {
], ],
), ),
Obx(() => Row( Obx(() => Row(
children: [ children: [
Container( Container(
width: 8.w, width: 8.w,
height: 8.w, height: 8.w,
decoration: BoxDecoration( decoration: BoxDecoration(
color: controller.getConnectionStatusColor(), color: controller.getConnectionStatusColor(),
shape: BoxShape.circle, shape: BoxShape.circle,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: controller.getConnectionStatusColor().withOpacity(0.3), color: controller
blurRadius: 4, .getConnectionStatusColor()
spreadRadius: 1, .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( SizedBox(width: 4.w),
Icons.refresh, Text(
size: 14.sp, controller.getConnectionStatusText(),
color: isDarkMode ? Colors.grey[400] : Colors.grey[600], 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<HomeController> {
Container( Container(
padding: EdgeInsets.all(12.w), padding: EdgeInsets.all(12.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isDarkMode color:
? Colors.red[900]!.withOpacity(0.2) isDarkMode ? Colors.red[900]!.withOpacity(0.2) : Colors.red[50],
: Colors.red[50],
borderRadius: BorderRadius.circular(12.r), borderRadius: BorderRadius.circular(12.r),
border: Border.all( border: Border.all(
color: isDarkMode ? Colors.red[800]! : Colors.red[200]!), color: isDarkMode ? Colors.red[800]! : Colors.red[200]!),
@ -440,12 +441,12 @@ class HomeView extends GetView<HomeController> {
final leftBattery = controller.leftEarBattery; final leftBattery = controller.leftEarBattery;
final rightBattery = controller.rightEarBattery; final rightBattery = controller.rightEarBattery;
final caseBattery = controller.caseBattery; final caseBattery = controller.caseBattery;
// 获取充电状态 // 获取充电状态
final leftEarCharging = controller.leftEarCharging; final leftEarCharging = controller.leftEarCharging;
final rightEarCharging = controller.rightEarCharging; final rightEarCharging = controller.rightEarCharging;
final caseCharging = controller.caseCharging; final caseCharging = controller.caseCharging;
return GridView.count( return GridView.count(
crossAxisCount: 3, crossAxisCount: 3,
shrinkWrap: true, shrinkWrap: true,
@ -461,7 +462,7 @@ class HomeView extends GetView<HomeController> {
isCharging: leftEarCharging, isCharging: leftEarCharging,
isDarkMode: isDarkMode, isDarkMode: isDarkMode,
), ),
// 右耳机 // 右耳机
_buildBatteryGridItem( _buildBatteryGridItem(
icon: Icons.headphones, icon: Icons.headphones,
@ -470,7 +471,7 @@ class HomeView extends GetView<HomeController> {
isCharging: rightEarCharging, isCharging: rightEarCharging,
isDarkMode: isDarkMode, isDarkMode: isDarkMode,
), ),
// 充电盒 // 充电盒
_buildBatteryGridItem( _buildBatteryGridItem(
icon: Icons.charging_station, icon: Icons.charging_station,
@ -483,7 +484,7 @@ class HomeView extends GetView<HomeController> {
); );
}); });
} }
// 单个电池网格项 // 单个电池网格项
Widget _buildBatteryGridItem({ Widget _buildBatteryGridItem({
required IconData icon, required IconData icon,
@ -495,7 +496,7 @@ class HomeView extends GetView<HomeController> {
// 获取电池图标和颜色 // 获取电池图标和颜色
IconData batteryIcon; IconData batteryIcon;
Color batteryColor; Color batteryColor;
if (batteryLevel > 75) { if (batteryLevel > 75) {
batteryIcon = Icons.battery_full; batteryIcon = Icons.battery_full;
batteryColor = Colors.green[600]!; batteryColor = Colors.green[600]!;
@ -512,16 +513,16 @@ class HomeView extends GetView<HomeController> {
batteryIcon = Icons.battery_alert; batteryIcon = Icons.battery_alert;
batteryColor = Colors.red[600]!; batteryColor = Colors.red[600]!;
} }
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: isDarkMode ? Colors.grey[900] : Colors.grey[100], color: isDarkMode ? Colors.grey[900] : Colors.grey[100],
borderRadius: BorderRadius.circular(12.r), borderRadius: BorderRadius.circular(12.r),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: isDarkMode ? color: isDarkMode
Colors.black.withOpacity(0.1) : ? Colors.black.withOpacity(0.1)
Colors.grey.withOpacity(0.1), : Colors.grey.withOpacity(0.1),
blurRadius: 4, blurRadius: 4,
spreadRadius: 0, spreadRadius: 0,
offset: Offset(0, 2), offset: Offset(0, 2),
@ -545,7 +546,7 @@ class HomeView extends GetView<HomeController> {
), ),
), ),
SizedBox(height: 6.h), SizedBox(height: 6.h),
// 标签 // 标签
Text( Text(
label, label,
@ -557,7 +558,7 @@ class HomeView extends GetView<HomeController> {
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
SizedBox(height: 6.h), SizedBox(height: 6.h),
// 电池指示器 // 电池指示器
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@ -614,7 +615,7 @@ class HomeView extends GetView<HomeController> {
isDarkMode: isDarkMode, isDarkMode: isDarkMode,
), ),
SizedBox(height: 8.h), SizedBox(height: 8.h),
// 固件版本 // 固件版本
_buildInfoRow( _buildInfoRow(
icon: Icons.info_outline, icon: Icons.info_outline,
@ -622,8 +623,7 @@ class HomeView extends GetView<HomeController> {
value: controller.firmwareVersion, value: controller.firmwareVersion,
isDarkMode: isDarkMode, isDarkMode: isDarkMode,
), ),
// 连接状态标签 // 连接状态标签
SizedBox(height: 10.h), SizedBox(height: 10.h),
Container( Container(
@ -763,7 +763,7 @@ class HomeView extends GetView<HomeController> {
), ),
); );
} }
// 热门AI体验标题 // 热门AI体验标题
Widget _buildSectionTitle(bool isDarkMode) { Widget _buildSectionTitle(bool isDarkMode) {
return Row( return Row(

23
lib/modules/profile/controllers/profile_controller.dart

@ -1,7 +1,6 @@
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart'; import 'package:get_storage/get_storage.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
//import 'package:http/http.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:logger/logger.dart'; import 'package:logger/logger.dart';
import '../../../data/models/user_Info.dart'; import '../../../data/models/user_Info.dart';
@ -19,26 +18,17 @@ import '../../../modules/login/controllers/facebookLogin.dart';
class ProfileController extends GetxController { class ProfileController extends GetxController {
static ProfileController get to => Get.find(); 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'; //用户信息存储键 static const String userKey = 'user_info'; //用户信息存储键
final _storage = GetStorage(); //本地存储 final _storage = GetStorage(); //本地存储
final ImagePicker _picker = ImagePicker(); //图片选择器 final ImagePicker _picker = ImagePicker(); //图片选择器
final Rx<User> userInfo = User.instance.obs; // 响应式用户信息对象,使用单例模式确保全局唯一性 final Rx<User> userInfo = User.instance.obs; // 响应式用户信息对象,使用单例模式确保全局唯一性
final RxString localAvatar = ''.obs; // 本地头像路径,便于响应式更新UI final RxString localAvatar = ''.obs; // 本地头像路径,便于响应式更新UI
final RxBool hasEdits = false.obs; // 是否有编辑
// 使用响应式变量 // 使用响应式变量
final currentLanguage = 'zh'.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 @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
@ -46,16 +36,6 @@ class ProfileController extends GetxController {
loadLanguagePreference(); 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() { void loadLanguagePreference() {
try { try {
@ -332,6 +312,7 @@ class ProfileController extends GetxController {
// if (Get.isRegistered<SettingsController>()) { // if (Get.isRegistered<SettingsController>()) {
// Get.find<SettingsController>().loadUserInfo(); // Get.find<SettingsController>().loadUserInfo();
// } // }
hasEdits.value = true; //表示有编辑
} }
} }

309
lib/modules/profile/views/profile_view.dart

@ -9,130 +9,130 @@ import 'dart:ui';
import '../../common/webview_page.dart'; import '../../common/webview_page.dart';
// ProfileView: 用户设置页面 // ProfileView: 用户设置页面
class ProfileView extends GetView<ProfileController> { // class ProfileView extends GetView<ProfileController> {
const ProfileView({Key? key}) : super(key: key); // const ProfileView({Key? key}) : super(key: key);
Widget _buildMenuItem({ // Widget _buildMenuItem({
required String title, // required String title,
required IconData icon, // required IconData icon,
String? subtitle, // String? subtitle,
required VoidCallback onTap, // required VoidCallback onTap,
}) { // }) {
return ListTile( // return ListTile(
leading: Icon(icon, size: 24.sp, color: Colors.grey[700]), // leading: Icon(icon, size: 24.sp, color: Colors.grey[700]),
title: Text( // title: Text(
title, // title,
style: TextStyle( // style: TextStyle(
fontSize: 16.sp, // fontSize: 16.sp,
fontWeight: FontWeight.w500, // fontWeight: FontWeight.w500,
), // ),
), // ),
subtitle: subtitle != null // subtitle: subtitle != null
? Text( // ? Text(
subtitle, // subtitle,
style: TextStyle( // style: TextStyle(
fontSize: 14.sp, // fontSize: 14.sp,
color: Colors.grey[600], // color: Colors.grey[600],
), // ),
) // )
: null, // : null,
trailing: Icon( // trailing: Icon(
Icons.chevron_right, // Icons.chevron_right,
size: 24.sp, // size: 24.sp,
color: Colors.grey[400], // color: Colors.grey[400],
), // ),
onTap: onTap, // onTap: onTap,
); // );
} // }
@override // @override
Widget build(BuildContext context) { // Widget build(BuildContext context) {
return Scaffold( // return Scaffold(
backgroundColor: Colors.white, // backgroundColor: Colors.white,
appBar: AppBar( // appBar: AppBar(
backgroundColor: Colors.white, // backgroundColor: Colors.white,
elevation: 0, // elevation: 0,
title: Text( // title: Text(
'设置'.tr, // '设置'.tr,
style: TextStyle( // style: TextStyle(
fontSize: 17.sp, // fontSize: 17.sp,
fontWeight: FontWeight.w600, // fontWeight: FontWeight.w600,
color: Colors.black, // color: Colors.black,
), // ),
), // ),
centerTitle: true, // centerTitle: true,
), // ),
body: ListView( // body: ListView(
children: [ // children: [
SizedBox(height: 12.h), // SizedBox(height: 12.h),
const Divider(), // const Divider(),
_buildMenuItem( // _buildMenuItem(
title: '关于'.tr, // title: '关于'.tr,
icon: Icons.info_outline, // icon: Icons.info_outline,
onTap: () { // onTap: () {
// TODO: 实现关于页面 // // TODO: 实现关于页面
}, // },
), // ),
const Divider(), // const Divider(),
_buildMenuItem( // _buildMenuItem(
title: '火山语音合成测试'.tr, // title: '火山语音合成测试'.tr,
icon: Icons.record_voice_over, // icon: Icons.record_voice_over,
subtitle: '测试火山语音TTS功能', // subtitle: '测试火山语音TTS功能',
onTap: () { // onTap: () {
Get.toNamed(Routes.TTS_TEST); // Get.toNamed(Routes.TTS_TEST);
}, // },
), // ),
const Divider(), // const Divider(),
_buildMenuItem( // _buildMenuItem(
title: '火山语音识别测试'.tr, // title: '火山语音识别测试'.tr,
icon: Icons.mic_external_on, // icon: Icons.mic_external_on,
subtitle: '测试火山语音ASR功能', // subtitle: '测试火山语音ASR功能',
onTap: () { // onTap: () {
Get.toNamed(Routes.VOLCANO_ASR_TEST); // Get.toNamed(Routes.VOLCANO_ASR_TEST);
}, // },
), // ),
const Divider(), // const Divider(),
_buildMenuItem( // _buildMenuItem(
title: 'Azure语音识别测试'.tr, // title: 'Azure语音识别测试'.tr,
icon: Icons.mic, // icon: Icons.mic,
subtitle: '测试Azure语音ASR功能', // subtitle: '测试Azure语音ASR功能',
onTap: () { // onTap: () {
Get.toNamed(Routes.AZURE_ASR_TEST); // Get.toNamed(Routes.AZURE_ASR_TEST);
}, // },
), // ),
const Divider(), // const Divider(),
_buildMenuItem( // _buildMenuItem(
title: 'Azure语音合成测试'.tr, // title: 'Azure语音合成测试'.tr,
icon: Icons.record_voice_over, // icon: Icons.record_voice_over,
subtitle: '测试Azure语音TTS功能', // subtitle: '测试Azure语音TTS功能',
onTap: () { // onTap: () {
Get.toNamed(Routes.AZURE_TTS_TEST); // Get.toNamed(Routes.AZURE_TTS_TEST);
}, // },
), // ),
const Divider(), // const Divider(),
_buildMenuItem( // _buildMenuItem(
title: '本地语音合成测试'.tr, // title: '本地语音合成测试'.tr,
icon: Icons.speaker_phone, // icon: Icons.speaker_phone,
subtitle: '测试Flutter TTS本地语音合成功能', // subtitle: '测试Flutter TTS本地语音合成功能',
onTap: () { // onTap: () {
Get.toNamed(Routes.FLUTTER_TTS_TEST); // Get.toNamed(Routes.FLUTTER_TTS_TEST);
}, // },
), // ),
const Divider(), // const Divider(),
_buildMenuItem( // _buildMenuItem(
title: '本地语音识别测试'.tr, // title: '本地语音识别测试'.tr,
icon: Icons.mic_none, // icon: Icons.mic_none,
subtitle: '测试Flutter本地语音识别功能', // subtitle: '测试Flutter本地语音识别功能',
onTap: () { // onTap: () {
Get.toNamed(Routes.FLUTTER_ASR_TEST); // Get.toNamed(Routes.FLUTTER_ASR_TEST);
}, // },
), // ),
], // ],
), // ),
bottomNavigationBar: const CommonBottomNav(currentIndex: 2), // bottomNavigationBar: const CommonBottomNav(currentIndex: 2),
); // );
} // }
} // }
// EditProfileView: 编辑个人资料页面 // EditProfileView: 编辑个人资料页面
class EditProfileView extends GetView<ProfileController> { class EditProfileView extends GetView<ProfileController> {
@ -146,19 +146,19 @@ class EditProfileView extends GetView<ProfileController> {
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false, // 添加这一行,防止键盘挤压内容 resizeToAvoidBottomInset: false, // 添加这一行,防止键盘挤压内容
appBar: AppBar( appBar: AppBar(
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
centerTitle: true, centerTitle: true,
elevation: 0, elevation: 0,
backgroundColor: isDarkMode ? Colors.black : Colors.white, backgroundColor: isDarkMode ? Colors.black : Colors.white,
leading: IconButton( leading: IconButton(
icon: Icon( icon: Icon(
Icons.arrow_back_ios, Icons.arrow_back_ios,
size: 20.sp, size: 20.sp,
color: isDarkMode? Colors.white : Colors.black, color: isDarkMode ? Colors.white : Colors.black,
),
onPressed: () => Get.back(),
), ),
onPressed: () => Get.back(),
),
// title: Text( // title: Text(
// 'editProfile'.tr, // 'editProfile'.tr,
// style: TextStyle( // style: TextStyle(
@ -168,22 +168,25 @@ class EditProfileView extends GetView<ProfileController> {
// ), // ),
// ), // ),
actions: [ actions: [
TextButton( Obx(() => Visibility(
onPressed: () { visible: controller.hasEdits.value,
// 保存用户名 child: TextButton(
controller.updateUserNameAndAvatar(nameController.text); onPressed: () {
// 返回上一级页面 // 保存用户名
Get.back(); controller.updateUserNameAndAvatar(nameController.text);
}, // 返回上一级页面
child: Text( Get.back();
'save'.tr, },
style: TextStyle( child: Text(
fontSize: 16.sp, 'save'.tr,
color: isDarkMode ? Colors.blue[300] : Colors.blue, style: TextStyle(
fontWeight: FontWeight.w500, fontSize: 16.sp,
), color: isDarkMode ? Colors.blue[300] : Colors.blue,
), fontWeight: FontWeight.w500,
), ),
),
),
))
], ],
), ),
body: Padding( body: Padding(
@ -472,6 +475,12 @@ class EditProfileView extends GetView<ProfileController> {
onPressed: () { onPressed: () {
// 确认时,将对话框输入的值更新回主 nameController // 确认时,将对话框输入的值更新回主 nameController
nameController.text = dialogNameController.text; nameController.text = dialogNameController.text;
controller.userInfo.update((user) {
if (user != null) {
user.name = dialogNameController.text;
}
});
controller.hasEdits.value = true; // 标记已编辑
Get.back(); // 关闭对话框 Get.back(); // 关闭对话框
// 注意:实际的保存操作由 AppBar 中的保存按钮触发 // 注意:实际的保存操作由 AppBar 中的保存按钮触发
}, },

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

@ -62,156 +62,155 @@ class SettingsView extends GetView<SettingsController> {
return GestureDetector( return GestureDetector(
onTap: () => Get.toNamed(Routes.editProfile), onTap: () => Get.toNamed(Routes.editProfile),
child: Container( child: Container(
padding: EdgeInsets.all(16.w), padding: EdgeInsets.all(16.w),
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
colors: isDarkMode colors: isDarkMode
? [ ? [
const Color(0xFF1A1A1A).withOpacity(0.7), const Color(0xFF1A1A1A).withOpacity(0.7),
const Color(0xFF2A2A2A).withOpacity(0.7) const Color(0xFF2A2A2A).withOpacity(0.7)
] ]
: [const Color(0xFFE3F2FD), const Color(0xFFF3E5F5)], : [const Color(0xFFE3F2FD), const Color(0xFFF3E5F5)],
begin: Alignment.topLeft, begin: Alignment.topLeft,
end: Alignment.bottomRight, 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),
), ),
], borderRadius: BorderRadius.circular(16.r),
), boxShadow: [
child: ClipRRect( BoxShadow(
//裁剪圆角矩形 color: isDarkMode
borderRadius: BorderRadius.circular(16.r), ? Colors.black.withOpacity(0.2)
child: BackdropFilter( : Colors.black.withOpacity(0.05),
filter: isDarkMode blurRadius: 10,
? ImageFilter.blur(sigmaX: 10, sigmaY: 10) offset: const Offset(0, 2),
: ImageFilter.blur(sigmaX: 0, sigmaY: 0), ),
child: Row( ],
children: [ ),
Obx(() => GestureDetector( child: ClipRRect(
//onTap: ()=>controller.updateUserAvatar(), //裁剪圆角矩形
child: Container( borderRadius: BorderRadius.circular(16.r),
//用户头像部分 child: BackdropFilter(
width: 60.w, filter: isDarkMode
height: 60.w, ? ImageFilter.blur(sigmaX: 10, sigmaY: 10)
decoration: BoxDecoration( : ImageFilter.blur(sigmaX: 0, sigmaY: 0),
borderRadius: BorderRadius.circular(30.r), child: Row(
boxShadow: [ children: [
BoxShadow( Obx(() => GestureDetector(
color: Colors.black.withOpacity(0.1), //onTap: ()=>controller.updateUserAvatar(),
blurRadius: 8, child: Container(
offset: const Offset(0, 2), //用户头像部分
), width: 60.w,
], height: 60.w,
), decoration: BoxDecoration(
child: ClipRRect(
// 裁剪圆形头像
borderRadius: BorderRadius.circular(30.r), borderRadius: BorderRadius.circular(30.r),
child: controller.userInfo.value.avatar.isEmpty boxShadow: [
? BoxShadow(
Container( color: Colors.black.withOpacity(0.1),
decoration: BoxDecoration( blurRadius: 8,
color: Colors.blue[600], offset: const Offset(0, 2),
borderRadius: BorderRadius.circular(30.r), ),
), ],
child: Center( ),
child: Text( child: ClipRRect(
controller // 裁剪圆形头像
.userInfo.value.name.isNotEmpty borderRadius: BorderRadius.circular(30.r),
? controller.userInfo.value.name[0] child: controller.userInfo.value.avatar.isEmpty
.toUpperCase() ? Container(
: '?', decoration: BoxDecoration(
style: TextStyle( color: Colors.blue[600],
color: Colors.white, borderRadius: BorderRadius.circular(30.r),
fontSize: 24.sp,
fontWeight: FontWeight.bold,
),
), ),
), child: Center(
) child: Text(
: Image.network( controller
controller.userInfo.value.avatar, .userInfo.value.name.isNotEmpty
fit: BoxFit.cover, ? controller.userInfo.value.name[0]
errorBuilder: (context, error, stackTrace) { .toUpperCase()
// 当图片加载失败时显示用户名首字母 : '?',
return Container( style: TextStyle(
decoration: BoxDecoration( color: Colors.white,
color: Colors.blue[600], fontSize: 24.sp,
borderRadius: fontWeight: FontWeight.bold,
BorderRadius.circular(30.r), ),
), ),
child: Center( ),
child: Text( )
controller.userInfo.value.name : Image.network(
.isNotEmpty controller.userInfo.value.avatar,
? controller fit: BoxFit.cover,
.userInfo.value.name[0] errorBuilder: (context, error, stackTrace) {
.toUpperCase() // 当图片加载失败时显示用户名首字母
: '?', return Container(
style: TextStyle( decoration: BoxDecoration(
color: Colors.white, color: Colors.blue[600],
fontSize: 24.sp, borderRadius:
fontWeight: FontWeight.bold, 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( SizedBox(width: 16.w),
children: [ Expanded(
Container( // 占据剩余空间
padding: EdgeInsets.symmetric( child: Obx(
horizontal: 8.w, vertical: 2.h), () => Column(
decoration: BoxDecoration( crossAxisAlignment: CrossAxisAlignment.start, // 左对齐
color: Colors.blue[600], children: [
borderRadius: BorderRadius.circular(10.r), Text(
), //用户名
child: Obx(() { controller.userInfo.value.name,
final membershipMap = { style: TextStyle(
0: 'freeUser', //'免费用户' fontSize: 18.sp,
1: 'standardUser', //'标准用户' fontWeight: FontWeight.w600,
2: 'proUser', //'专业用户' color: isDarkMode ? Colors.white : Colors.black87,
};
final membershipString = membershipMap[
controller
.userInfo.value.membershipLevel] ??
'Unknown';
return Text(
membershipString,
style: TextStyle(
fontSize: 10.sp,
color: Colors.white,
),
);
}),
), ),
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), // SizedBox(width: 8.w),
// Flexible( // Flexible(
// child: Text( // child: Text(
@ -225,46 +224,46 @@ class SettingsView extends GetView<SettingsController> {
// overflow: TextOverflow.ellipsis, // overflow: TextOverflow.ellipsis,
// ), // ),
// ), // ),
], ],
), ),
SizedBox(height: 4.h), SizedBox(height: 4.h),
Text( Text(
'ID:${controller.userInfo.value.uid}', 'ID:${controller.userInfo.value.uid}',
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
color: isDarkMode ? Colors.white70 : Colors.black54, color: isDarkMode ? Colors.white70 : Colors.black54,
),
), ),
), ],
], ),
), ),
), ),
), Container(
Container( // 编辑按钮
// 编辑按钮 width: 32.w,
width: 32.w, height: 32.w,
height: 32.w, decoration: BoxDecoration(
decoration: BoxDecoration( color: isDarkMode
color: isDarkMode ? Colors.white.withOpacity(0.1)
? Colors.white.withOpacity(0.1) : Colors.white.withOpacity(0.7),
: Colors.white.withOpacity(0.7), borderRadius: BorderRadius.circular(16.r),
borderRadius: BorderRadius.circular(16.r), boxShadow: [
boxShadow: [ BoxShadow(
BoxShadow( color: Colors.black.withOpacity(0.05),
color: Colors.black.withOpacity(0.05), blurRadius: 4,
blurRadius: 4, offset: const Offset(0, 1),
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],
), ),
)), 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<SettingsController> {
_buildSimpleNavigationSetting( _buildSimpleNavigationSetting(
title: 'ota升级', title: 'ota升级',
subtitle: '测试ble耳机固件版本升级', subtitle: '测试ble耳机固件版本升级',
icon: Icons.record_voice_over, icon: Icons.system_update_alt,
iconBgColor: isDarkMode iconBgColor: isDarkMode
? Colors.orange[900]!.withOpacity(0.3) ? Colors.orange[900]!.withOpacity(0.3)
: Colors.orange[100]!, : Colors.orange[100]!,
@ -581,11 +580,11 @@ class SettingsView extends GetView<SettingsController> {
onTap: () => Get.toNamed(Routes.OTA_UPGRADE), onTap: () => Get.toNamed(Routes.OTA_UPGRADE),
isDarkMode: isDarkMode, isDarkMode: isDarkMode,
), ),
Divider( // Divider(
height: 1, // height: 1,
color: isDarkMode // color: isDarkMode
? Colors.white.withOpacity(0.1) // ? Colors.white.withOpacity(0.1)
: Colors.grey[200]), // : Colors.grey[200]),
// 退出登录 // 退出登录
// _buildSimpleNavigationSetting( // _buildSimpleNavigationSetting(

14
lib/routes/app_pages.dart

@ -103,13 +103,13 @@ abstract class AppPages {
page: () => const OtaUpgradeView(), page: () => const OtaUpgradeView(),
binding: OtaUpgradeBinding(), binding: OtaUpgradeBinding(),
), ),
GetPage( // GetPage(
name: Routes.profile, // name: Routes.profile,
page: () => const ProfileView(), // page: () => const ProfileView(),
binding: ProfileBinding(), // binding: ProfileBinding(),
transition: Transition.rightToLeft, // transition: Transition.rightToLeft,
transitionDuration: Duration(milliseconds: 250), // transitionDuration: Duration(milliseconds: 250),
), // ),
GetPage( GetPage(
name: Routes.editProfile, name: Routes.editProfile,
page: () => const EditProfileView(), page: () => const EditProfileView(),

61
lib/routes/app_routes.dart

@ -1,35 +1,48 @@
abstract class Routes { abstract class Routes {
// 认证相关
static const splash = '/splash'; static const splash = '/splash';
static const login = '/login'; static const login = '/login';
static const pairing = '/pairing'; static const pairing = '/pairing';
// 主功能模块
static const initial = '/home'; static const initial = '/home';
static const home = '/home'; static const home = '/home';
static const explore = '/explore'; static const explore = '/explore';
static const chat = '/chat'; static const chat = '/chat';
static const OTA_UPGRADE = '/ota_upgrade';
static const recording = '/recording';
static const profile = '/profile'; 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 editProfile = '/edit_profile';
static const feedback = '/feedback';
static const jieliTest = '/jieli_test'; // 设备管理
static const opusTest = '/opus_test'; static const OTA_UPGRADE = '/ota_upgrade'; // OTA升级
static const bleTest = '/ble_test'; static const timbre = '/timbre'; // 音色设置
static const speechTest = '/speech_test'; static const settings = '/settings'; // 系统设置
static const agent = '/agent'; 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'; // 在线客服
} }

Loading…
Cancel
Save