tanlongsheng 2 years ago
parent
commit
046ac1007a
  1. 7
      lib/core/translations/language/en_us.dart
  2. 7
      lib/core/translations/language/zh_cn.dart
  3. 39
      lib/data/models/user_model.dart
  4. 4
      lib/data/services/classic_bluetooth_service.dart
  5. 2
      lib/modules/explore/views/explore_view.dart
  6. 2
      lib/modules/home/bindings/home_binding.dart
  7. 7
      lib/modules/home/controllers/home_controller.dart
  8. 3
      lib/modules/home/views/home_view.dart
  9. 2
      lib/modules/login/views/login_view.dart
  10. 2
      lib/modules/pairing/views/pairing_view.dart
  11. 198
      lib/modules/profile/controllers/profile_controller.dart
  12. 135
      lib/modules/profile/views/profile_view.dart
  13. 61
      lib/modules/settings/controllers/settings_controller.dart
  14. 59
      lib/modules/settings/views/settings_view.dart
  15. 2
      lib/modules/splash/views/splash_view.dart
  16. 6
      lib/routes/app_pages.dart
  17. 3
      lib/routes/app_routes.dart
  18. 4
      pubspec.yaml

7
lib/core/translations/language/en_us.dart

@ -84,7 +84,7 @@ const Map<String, String> enUS = {
// 发现页 // 发现页
"searchAi": "Search AI features...", "searchAi": "Search AI features...",
"exploreSlogan": "Smart Earbuds, Infinite Possibilities", "exploreSlogan": "Smart Earbuds, Infinite Possibilities",
"exploreAi": "Explore AI features provided by DeepVoice", "exploreAi": "Explore AI features provided by DeepSound",
"aiFunction": "AI Features", "aiFunction": "AI Features",
"allRoundAssistant": "All-round Assistant", "allRoundAssistant": "All-round Assistant",
"allRoundAssistantInfo": "Helps solve various problems", "allRoundAssistantInfo": "Helps solve various problems",
@ -152,4 +152,9 @@ const Map<String, String> enUS = {
// 翻译页 // 翻译页
"selectSourceLanguage": "Select Source Language", "selectSourceLanguage": "Select Source Language",
"selectTargetLanguage": "Select Target Language", "selectTargetLanguage": "Select Target Language",
//编辑个人信息页
"editProfile": "Edit Profile",
"nickname": "Nickname",
"save": "Save",
}; };

7
lib/core/translations/language/zh_cn.dart

@ -83,7 +83,7 @@ const Map<String, String> zhCN = {
// 发现页 // 发现页
"searchAi": "搜索AI功能...", "searchAi": "搜索AI功能...",
"exploreSlogan": "智能耳机,无限可能", "exploreSlogan": "智能耳机,无限可能",
"exploreAi": "探索DeepVoice提供的AI功能", "exploreAi": "探索DeepSound提供的AI功能",
"aiFunction": "AI功能", "aiFunction": "AI功能",
"allRoundAssistant": "全能助理", "allRoundAssistant": "全能助理",
"allRoundAssistantInfo": "帮你解决各类问题", "allRoundAssistantInfo": "帮你解决各类问题",
@ -147,4 +147,9 @@ const Map<String, String> zhCN = {
// 翻译页 // 翻译页
"selectSourceLanguage": "选择源语言", "selectSourceLanguage": "选择源语言",
"selectTargetLanguage": "选择目标语言", "selectTargetLanguage": "选择目标语言",
//编辑个人信息页
"editProfile": "编辑个人信息",
"nickname": "昵称",
"save": "保存",
}; };

39
lib/data/models/user_model.dart

@ -0,0 +1,39 @@
class UserModel {
String name; // 用户名
String avatar; // 头像
String id;
//final String deviceName;
String membershipLevel; // 会员等级
UserModel({
required this.name,
required this.avatar,
required this.id,
//required this.deviceName,
required this.membershipLevel,
});
Map<String, dynamic> toJson() => {
'name': name,
'avatar': avatar,
'id': id,
//'deviceName': deviceName,
'membershipLevel': membershipLevel,
};
factory UserModel.fromJson(Map<String, dynamic> json) => UserModel(
name: json['name'] ?? '未设置昵称',
avatar: json['avatar'] ?? '',
id: json['id'] ?? '',
//deviceName: json['deviceName'] ?? '',
membershipLevel: json['membershipLevel'] ?? '普通会员',
);
factory UserModel.defaultUser() => UserModel(
name: '未设置昵称',
avatar: '',
id: 'DeepSound_${DateTime.now().millisecondsSinceEpoch.toString()}',
//deviceName: '',
membershipLevel: '普通会员',
);
}

4
lib/data/services/classic_bluetooth_service.dart

@ -316,7 +316,7 @@ class ClassicBluetoothService extends GetxService {
if (event is Map) { if (event is Map) {
final type = event['type'] as String?; final type = event['type'] as String?;
if (type == 'stateChanged') { if (type == 'bluetoothStateChanged') {
final state = event['state'] as String?; final state = event['state'] as String?;
if (state != null) { if (state != null) {
_handleBluetoothStateChange(state); _handleBluetoothStateChange(state);
@ -353,7 +353,7 @@ class ClassicBluetoothService extends GetxService {
/// 处理蓝牙状态变化 /// 处理蓝牙状态变化
void _handleBluetoothStateChange(String state) { void _handleBluetoothStateChange(String state) {
Logger.info('蓝牙状态变化: $state'); Logger.info('----蓝牙状态变化: $state');
// 如果蓝牙关闭,清除设备信息 // 如果蓝牙关闭,清除设备信息
if (state == 'off') { if (state == 'off') {

2
lib/modules/explore/views/explore_view.dart

@ -205,7 +205,7 @@ class ExploreView extends GetView<ExploreController> {
), ),
SizedBox(height: 4.h), SizedBox(height: 4.h),
Text( Text(
'exploreAi'.tr, // 探索DeepVoice提供的AI功能 'exploreAi'.tr, // 探索DeepSound提供的AI功能
style: TextStyle( style: TextStyle(
fontSize: 14.sp, fontSize: 14.sp,
color: Colors.white.withOpacity(0.8), color: Colors.white.withOpacity(0.8),

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

@ -1,3 +1,4 @@
import 'package:deep_voice/modules/explore/controllers/explore_controller.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../controllers/home_controller.dart'; import '../controllers/home_controller.dart';
@ -5,5 +6,6 @@ class HomeBinding extends Bindings {
@override @override
void dependencies() { void dependencies() {
Get.lazyPut<HomeController>(() => HomeController()); Get.lazyPut<HomeController>(() => HomeController());
Get.lazyPut<ExploreController>(()=>ExploreController());// 注册ExploreController
} }
} }

7
lib/modules/home/controllers/home_controller.dart

@ -6,6 +6,7 @@ import 'package:flutter_blue_plus/flutter_blue_plus.dart' hide BluetoothDevice;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../data/services/voice_interaction_service.dart'; import '../../../data/services/voice_interaction_service.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import '../../explore/controllers/explore_controller.dart';
// 连接状态枚举 // 连接状态枚举
enum ConnectionStatus { enum ConnectionStatus {
@ -17,6 +18,7 @@ enum ConnectionStatus {
class HomeController extends GetxController { class HomeController extends GetxController {
static HomeController get to => Get.find(); static HomeController get to => Get.find();
final ExploreController exploreController = Get.find<ExploreController>();
// 经典蓝牙服务 // 经典蓝牙服务
late classic.ClassicBluetoothService _bluetoothService; late classic.ClassicBluetoothService _bluetoothService;
@ -111,6 +113,7 @@ class HomeController extends GetxController {
// 设置蓝牙监听器 // 设置蓝牙监听器
void _setupBluetoothListeners() { void _setupBluetoothListeners() {
// 监听设备连接 // 监听设备连接
_bluetoothService.onDeviceConnected((device) { _bluetoothService.onDeviceConnected((device) {
Logger.info('监听到蓝牙设备连接: ${device.name}'); Logger.info('监听到蓝牙设备连接: ${device.name}');
@ -185,13 +188,13 @@ class HomeController extends GetxController {
// 打开AI伴侣功能 // 打开AI伴侣功能
void openAIGirlfriend() { void openAIGirlfriend() {
Get.toNamed(Routes.chat); exploreController.onAIFeatureTap(2);//进入AI女友页面
} }
// 展示AI功能 // 展示AI功能
void exploreAIFeatures() { void exploreAIFeatures() {
// 简单实现,直接跳转到AI聊天页面 // 简单实现,直接跳转到AI聊天页面
openAIGirlfriend(); Get.toNamed(Routes.chat);
} }
// 获取连接状态对应的颜色 // 获取连接状态对应的颜色

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

@ -69,6 +69,7 @@ class _AnimatedPulsingState extends State<AnimatedPulsing>
} }
} }
//首页视图
class HomeView extends GetView<HomeController> { class HomeView extends GetView<HomeController> {
const HomeView({Key? key}) : super(key: key); const HomeView({Key? key}) : super(key: key);
@ -115,7 +116,7 @@ class HomeView extends GetView<HomeController> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
'DeepVoice', 'DeepSound',
style: TextStyle( style: TextStyle(
fontSize: 20.sp, fontSize: 20.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,

2
lib/modules/login/views/login_view.dart

@ -131,7 +131,7 @@ class LoginView extends GetView<LoginController> {
), ),
SizedBox(height: 16.h), SizedBox(height: 16.h),
Text( Text(
'DeepVoice', 'DeepSound',
style: TextStyle( style: TextStyle(
fontSize: 24.sp, fontSize: 24.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,

2
lib/modules/pairing/views/pairing_view.dart

@ -75,7 +75,7 @@ class PairingView extends GetView<PairingController> {
return Column( return Column(
children: [ children: [
Text( Text(
'DeepVoice', 'DeepSound',
style: TextStyle( style: TextStyle(
fontSize: 30.sp, fontSize: 30.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,

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

@ -1,47 +1,58 @@
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:image_picker/image_picker.dart';
import 'package:logger/logger.dart';
import '../../../data/models/user_model.dart';
import '../../settings/controllers/settings_controller.dart';
import 'dart:io';
import 'package:flutter_image_compress/flutter_image_compress.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 _userName = ''.obs;
final _email = ''.obs; // final _email = ''.obs;
final _avatar = ''.obs; // final _avatar = ''.obs;
final _isEditing = false.obs; // final _isEditing = false.obs;
// final _storage = GetStorage();
//用户信息
static const String userKey = 'user_info';
final _storage = GetStorage(); final _storage = GetStorage();
final ImagePicker _picker = ImagePicker();
final Rx<UserModel> userInfo = UserModel.defaultUser().obs;
// 使用响应式变量 // 使用响应式变量
final currentLanguage = 'zh'.obs; final currentLanguage = 'zh'.obs;
String get userName => _userName.value; // String get userName => _userName.value;
String get email => _email.value; // String get email => _email.value;
String get avatar => _avatar.value; // String get avatar => _avatar.value;
bool get isEditing => _isEditing.value; // bool get isEditing => _isEditing.value;
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
loadUserData(); loadUserInfo();
loadLanguagePreference(); loadLanguagePreference();
} }
void loadUserData() { // void loadUserData() {
try { // try {
_userName.value = _storage.read('userName') ?? 'User Name'; // _userName.value = _storage.read('userName') ?? 'User Name';
_email.value = _storage.read('userEmail') ?? 'user@example.com'; // _email.value = _storage.read('userEmail') ?? 'user@example.com';
_avatar.value = _storage.read('userAvatar') ?? ''; // _avatar.value = _storage.read('userAvatar') ?? '';
} catch (e) { // } catch (e) {
Get.snackbar('Error', 'Failed to load user data'); // Get.snackbar('Error', 'Failed to load user data');
} // }
} // }
// 加载用户语言偏好设置 // 加载用户语言偏好设置
void loadLanguagePreference() { void loadLanguagePreference() {
try { try {
final String? languageCode = _storage.read('languageCode'); final String? languageCode = _storage.read('languageCode');
final String? countryCode = _storage.read('countryCode'); final String? countryCode = _storage.read('countryCode');
if (languageCode != null && countryCode != null) { if (languageCode != null && countryCode != null) {
Get.updateLocale(Locale(languageCode, countryCode)); Get.updateLocale(Locale(languageCode, countryCode));
currentLanguage.value = languageCode; currentLanguage.value = languageCode;
@ -50,7 +61,7 @@ class ProfileController extends GetxController {
print('Failed to load language preference: $e'); print('Failed to load language preference: $e');
} }
} }
// 保存用户语言偏好设置 // 保存用户语言偏好设置
Future<void> saveLanguagePreference(Locale locale) async { Future<void> saveLanguagePreference(Locale locale) async {
try { try {
@ -60,7 +71,7 @@ class ProfileController extends GetxController {
print('Failed to save language preference: $e'); print('Failed to save language preference: $e');
} }
} }
// 切换应用语言 // 切换应用语言
void changeLanguage(String languageCode, String countryCode) { void changeLanguage(String languageCode, String countryCode) {
// 使用Future.delayed来避免在构建过程中更新UI // 使用Future.delayed来避免在构建过程中更新UI
@ -71,32 +82,119 @@ class ProfileController extends GetxController {
currentLanguage.value = languageCode; currentLanguage.value = languageCode;
}); });
} }
Future<void> updateUserData({ // Future<void> updateUserData({
String? userName, // String? userName,
String? email, // String? email,
String? avatar, // String? avatar,
}) async { // }) async {
try { // try {
if (userName != null) { // if (userName != null) {
await _storage.write('userName', userName); // await _storage.write('userName', userName);
_userName.value = userName; // _userName.value = userName;
// }
// if (email != null) {
// await _storage.write('userEmail', email);
// _email.value = email;
// }
// if (avatar != null) {
// await _storage.write('userAvatar', avatar);
// _avatar.value = avatar;
// }
// Get.snackbar('Success', 'Profile updated successfully');
// } catch (e) {
// Get.snackbar('Error', 'Failed to update profile');
// }
// }
// void toggleEditing() {
// _isEditing.value = !_isEditing.value;
// }
void loadUserInfo() {
final userJson = _storage.read(userKey);
if (userJson != null) {
userInfo.value = UserModel.fromJson(userJson);
}
}
Future<void> saveUserInfo() async {
await _storage.write(userKey, userInfo.value.toJson());
}
Future<void> updateUserAvatar() async {
final XFile? image = await _picker.pickImage(
source: ImageSource.gallery,
maxWidth: 800,
maxHeight: 800,
imageQuality: 85,
);
if (image != null) {
// 检查文件大小
final file = File(image.path);
var fileSize = await file.length();
var quality = 85;
// 如果文件大于1MB,进行压缩
while (fileSize > 1024 * 1024 && quality > 30) {
final compressedImage = await FlutterImageCompress.compressAndGetFile(
file.absolute.path,
file.absolute.path, // 覆盖原文件
quality: quality,
minWidth: 800,
minHeight: 800,
);
if (compressedImage == null) {
Get.snackbar('错误', '图片压缩失败');
return;
}
//更新文件大小和质量
fileSize = await compressedImage.length();
quality -= 5;
Logger().d('压缩后文件大小:$fileSize');
} }
if (email != null) {
await _storage.write('userEmail', email); userInfo.update((user) {
_email.value = email; if (user != null) {
user.avatar = image.path;
}
});
await saveUserInfo();
// 通知 SettingsController 更新
if (Get.isRegistered<SettingsController>()) {
Get.find<SettingsController>().loadUserInfo();
} }
if (avatar != null) { }
await _storage.write('userAvatar', avatar); }
_avatar.value = avatar;
Future<void> updateUserName(String name) async {
if (name.trim().isEmpty) {
Logger().e('Invalid name: $name');
return;
}
try {
userInfo.update((user) {
if (user != null) {
user.name = name.trim();
Logger().d('Name updated to: ${user.name}');
}
});
await saveUserInfo();
// 同步更新 SettingsController
if (Get.isRegistered<SettingsController>()) {
final settingsController = Get.find<SettingsController>();
settingsController.loadUserInfo();
} }
Get.snackbar('Success', 'Profile updated successfully');
} catch (e) { } catch (e) {
Get.snackbar('Error', 'Failed to update profile'); Logger().e('Error updating name: $e');
Get.snackbar('Error', 'Failed to update user name');
} }
} }
}
void toggleEditing() {
_isEditing.value = !_isEditing.value;
}
}

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

@ -4,7 +4,9 @@ import '../controllers/profile_controller.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../../core/widgets/common_bottom_nav.dart'; import '../../../core/widgets/common_bottom_nav.dart';
import '../../../routes/app_routes.dart'; import '../../../routes/app_routes.dart';
import 'dart:io';
// 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);
@ -61,7 +63,6 @@ class ProfileView extends GetView<ProfileController> {
body: ListView( body: ListView(
children: [ children: [
SizedBox(height: 12.h), SizedBox(height: 12.h),
const Divider(), const Divider(),
_buildMenuItem( _buildMenuItem(
title: '关于'.tr, title: '关于'.tr,
@ -70,7 +71,6 @@ class ProfileView extends GetView<ProfileController> {
// TODO: 实现关于页面 // TODO: 实现关于页面
}, },
), ),
const Divider(), const Divider(),
_buildMenuItem( _buildMenuItem(
title: '火山语音合成测试'.tr, title: '火山语音合成测试'.tr,
@ -80,8 +80,6 @@ class ProfileView extends GetView<ProfileController> {
Get.toNamed(Routes.TTS_TEST); Get.toNamed(Routes.TTS_TEST);
}, },
), ),
const Divider(), const Divider(),
_buildMenuItem( _buildMenuItem(
title: '火山语音识别测试'.tr, title: '火山语音识别测试'.tr,
@ -100,7 +98,7 @@ class ProfileView extends GetView<ProfileController> {
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,
@ -132,4 +130,129 @@ class ProfileView extends GetView<ProfileController> {
bottomNavigationBar: const CommonBottomNav(currentIndex: 2), bottomNavigationBar: const CommonBottomNav(currentIndex: 2),
); );
} }
} }
// EditProfileView: 编辑个人资料页面
class EditProfileView extends GetView<ProfileController> {
const EditProfileView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
final nameController =
TextEditingController(text: controller.userInfo.value.name);
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
centerTitle: true,
elevation: 0,
backgroundColor: isDarkMode ? Colors.black : Colors.white,
title: Text(
'editProfile'.tr,
style: TextStyle(
fontSize: 17.sp,
fontWeight: FontWeight.w600,
color: isDarkMode ? Colors.white : Colors.black,
),
),
),
body: Padding(
padding: EdgeInsets.all(16.w),
child: Column(
children: [
// 头像编辑
Center(
child: GestureDetector(
onTap: () => controller.updateUserAvatar(),
child: Stack(
children: [
Obx(() => CircleAvatar(
radius: 50.r,
backgroundImage:
controller.userInfo.value.avatar.isNotEmpty
? FileImage(
File(controller.userInfo.value.avatar))
: null,
child: controller.userInfo.value.avatar.isEmpty
? Icon(Icons.person, size: 50.r)
: null,
)),
Positioned(
right: 0,
bottom: 0,
child: Container(
padding: EdgeInsets.all(4.w),
decoration: const BoxDecoration(
color: Colors.blue,
shape: BoxShape.circle,
),
child: Icon(
Icons.camera_alt,
size: 20.w,
color: Colors.white,
)),
)
],
)),
),
SizedBox(height: 20.h),
// 昵称编辑 - 使用外部定义的controller而不是每次重建
Row(
children: [
Expanded(
child: TextField(
controller: nameController,
decoration: InputDecoration(
labelText: 'nickname'.tr,
border: OutlineInputBorder(),
suffixIcon: nameController.text.isNotEmpty
? IconButton(
icon: Icon(Icons.clear),
onPressed: () {
nameController.clear();
},
)
: null,
),
),
),
],
),
// ... 其他编辑项 ...
SizedBox(height: 30.h),
// 添加一个大的保存按钮
SizedBox(
width: double.infinity,
height: 50.h,
child: ElevatedButton(
onPressed: () {
// 保存用户名
controller.updateUserName(nameController.text);
// 返回上一级页面
Get.back();
},
style: ElevatedButton.styleFrom(
backgroundColor: isDarkMode ? Colors.blue[700] : Colors.blue,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.r),
),
),
child: Text(
'save'.tr,
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
),
),
],
),
),
);
}
}

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

@ -1,9 +1,11 @@
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:get_storage/get_storage.dart'; import 'package:get_storage/get_storage.dart';
import '../../../core/themes/theme_service.dart'; import '../../../core/themes/theme_service.dart';
import '../../../data/services/speech_factory.dart'; import '../../../data/services/speech_factory.dart';
import '../models/language_model.dart'; import '../models/language_model.dart';
import '../../../data/models/user_model.dart';
class SettingsController extends GetxController { class SettingsController extends GetxController {
// 语言设置 // 语言设置
@ -55,6 +57,12 @@ class SettingsController extends GetxController {
}, },
]; ];
//用户信息
static const String userKey='user_info';
//final _storage=GetStorage();
final ImagePicker _picker=ImagePicker();
final Rx<UserModel> userInfo=UserModel.defaultUser().obs;
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
@ -70,8 +78,61 @@ class SettingsController extends GetxController {
// 获取当前语音服务类型 // 获取当前语音服务类型
_loadCurrentSpeechServiceType(); _loadCurrentSpeechServiceType();
//获取用户信息
loadUserInfo();
}
void loadUserInfo() {
final userJson = _storage.read(userKey);
if (userJson != null) {
userInfo.value = UserModel.fromJson(userJson);
}
}
Future<void> saveUserInfo() async {
await _storage.write(userKey, userInfo.value.toJson());
}
Future<void> updateUserAvatar() async {
final XFile? image = await _picker.pickImage(
source: ImageSource.gallery,
maxWidth: 800,
maxHeight: 800,
imageQuality: 85,
);
if (image != null) {
userInfo.update((user) {
if (user != null) {
user.avatar = image.path;
}
});
await saveUserInfo();
}
} }
Future<void> updateUserName(String name) async {
if (name.trim().isNotEmpty) {
userInfo.update((user) {
if (user != null) {
user.name = name.trim();
}
});
await saveUserInfo();
}
}
// Future<void> updateDeviceName(String deviceName) async {
// userInfo.update((user) {
// if (user != null) {
// user.deviceName = deviceName;
// }
// });
// await saveUserInfo();
// }
// }
void _getLanguage() { void _getLanguage() {
String? languageValue = _storage.read('language'); String? languageValue = _storage.read('language');
LanguageModel data = languageList.firstWhere( LanguageModel data = languageList.firstWhere(

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

@ -7,6 +7,7 @@ import '../../../core/theme/app_colors.dart';
import '../controllers/settings_controller.dart'; import '../controllers/settings_controller.dart';
import '../../../core/widgets/common_bottom_nav.dart'; import '../../../core/widgets/common_bottom_nav.dart';
import '../../../routes/app_routes.dart'; import '../../../routes/app_routes.dart';
import 'dart:io';
class SettingsView extends GetView<SettingsController> { class SettingsView extends GetView<SettingsController> {
const SettingsView({Key? key}) : super(key: key); const SettingsView({Key? key}) : super(key: key);
@ -72,7 +73,7 @@ class SettingsView extends GetView<SettingsController> {
), ),
], ],
), ),
child: ClipRRect( child: ClipRRect(//裁剪圆角矩形
borderRadius: BorderRadius.circular(16.r), borderRadius: BorderRadius.circular(16.r),
child: BackdropFilter( child: BackdropFilter(
filter: isDarkMode filter: isDarkMode
@ -80,7 +81,9 @@ class SettingsView extends GetView<SettingsController> {
: ImageFilter.blur(sigmaX: 0, sigmaY: 0), : ImageFilter.blur(sigmaX: 0, sigmaY: 0),
child: Row( child: Row(
children: [ children: [
Container( Obx(()=>GestureDetector(
//onTap: ()=>controller.updateUserAvatar(),
child:Container(//用户头像部分
width: 60.w, width: 60.w,
height: 60.w, height: 60.w,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -93,21 +96,27 @@ class SettingsView extends GetView<SettingsController> {
), ),
], ],
), ),
child: ClipRRect( child: ClipRRect(// 裁剪圆形头像
borderRadius: BorderRadius.circular(30.r), borderRadius: BorderRadius.circular(30.r),
child: Image.network( 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', 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?ixlib=rb-1.2.1&auto=format&fit=crop&w=200&q=80',
fit: BoxFit.cover, fit: BoxFit.cover,// 图片填充方式
), )
:Image.file(
File(controller.userInfo.value.avatar),
fit: BoxFit.cover,// 图片填充方式
)
), ),
), ),
)),
SizedBox(width: 16.w), SizedBox(width: 16.w),
Expanded( Expanded(// 占据剩余空间
child: Column( child: Obx(()=>Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,// 左对齐
children: [ children: [
Text( Text(//用户名
'林美珍', controller.userInfo.value.name,
style: TextStyle( style: TextStyle(
fontSize: 18.sp, fontSize: 18.sp,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
@ -126,7 +135,7 @@ class SettingsView extends GetView<SettingsController> {
borderRadius: BorderRadius.circular(10.r), borderRadius: BorderRadius.circular(10.r),
), ),
child: Text( child: Text(
'premiumMember'.tr, // 高级会员 controller.userInfo.value.membershipLevel,
style: TextStyle( style: TextStyle(
fontSize: 10.sp, fontSize: 10.sp,
color: Colors.white, color: Colors.white,
@ -136,7 +145,7 @@ class SettingsView extends GetView<SettingsController> {
SizedBox(width: 8.w), SizedBox(width: 8.w),
Flexible( Flexible(
child: Text( child: Text(
'${'joinDevice'.tr} DeepVoice Pro', // 已连接设备: '${'joinDevice'.tr} DeepSound Pro', // 已连接设备:
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
color: color:
@ -149,7 +158,7 @@ class SettingsView extends GetView<SettingsController> {
), ),
SizedBox(height: 4.h), SizedBox(height: 4.h),
Text( Text(
'${'accountId'.tr} deepvoice_834291', // 账号ID: controller.userInfo.value.id,
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
color: isDarkMode ? Colors.white70 : Colors.black54, color: isDarkMode ? Colors.white70 : Colors.black54,
@ -157,8 +166,8 @@ class SettingsView extends GetView<SettingsController> {
), ),
], ],
), ),
), ),),
Container( Container(// 编辑按钮
width: 32.w, width: 32.w,
height: 32.w, height: 32.w,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -174,11 +183,15 @@ class SettingsView extends GetView<SettingsController> {
), ),
], ],
), ),
child: Icon( child: InkWell(
Icons.edit, onTap: () => Get.toNamed(Routes.editProfile),
size: 16.w, child: Icon(
color: isDarkMode ? Colors.white70 : Colors.grey[600], Icons.edit,
), size: 16.w,
color: isDarkMode ? Colors.white70 : Colors.grey[600],
),
)
), ),
], ],
), ),
@ -472,7 +485,7 @@ class SettingsView extends GetView<SettingsController> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
'DeepVoice', 'DeepSound',
style: TextStyle( style: TextStyle(
fontSize: 16.sp, fontSize: 16.sp,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
@ -519,7 +532,7 @@ class SettingsView extends GetView<SettingsController> {
child: Column( child: Column(
children: [ children: [
Text( Text(
'© 2023 DeepVoice Technologies', '© 2025 DeepSound Technologies',
style: TextStyle( style: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
color: isDarkMode ? Colors.grey[400] : Colors.grey[500], color: isDarkMode ? Colors.grey[400] : Colors.grey[500],

2
lib/modules/splash/views/splash_view.dart

@ -105,7 +105,7 @@ class SplashView extends GetView<SplashController> {
child: Padding( child: Padding(
padding: EdgeInsets.only(top: 24.h), padding: EdgeInsets.only(top: 24.h),
child: Text( child: Text(
'DeepVoice', 'DeepSound',
style: TextStyle( style: TextStyle(
fontSize: 28.sp, fontSize: 28.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,

6
lib/routes/app_pages.dart

@ -66,6 +66,12 @@ abstract class AppPages {
page: () => const ProfileView(), page: () => const ProfileView(),
binding: ProfileBinding(), binding: ProfileBinding(),
), ),
GetPage(
name: Routes.editProfile,
page: () => const EditProfileView(),
binding: ProfileBinding(),
),
GetPage( GetPage(
name: Routes.translation, name: Routes.translation,
page: () => const TranslationView(), page: () => const TranslationView(),

3
lib/routes/app_routes.dart

@ -19,4 +19,5 @@ abstract class Routes {
static const translationHistory = '/translation_history'; static const translationHistory = '/translation_history';
static const FLUTTER_TTS_TEST = '/flutter_tts_test'; static const FLUTTER_TTS_TEST = '/flutter_tts_test';
static const FLUTTER_ASR_TEST = '/flutter_asr_test'; static const FLUTTER_ASR_TEST = '/flutter_asr_test';
} static const editProfile='/edit_profile';
}

4
pubspec.yaml

@ -56,7 +56,9 @@ dependencies:
google_sign_in: ^6.2.2 google_sign_in: ^6.2.2
flutter_facebook_auth: ^7.1.1 flutter_facebook_auth: ^7.1.1
common_utils: ^2.1.0 common_utils: ^2.1.0
flutter_image_compress: ^2.4.0
# image_cropper: ^9.0.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter

Loading…
Cancel
Save