Browse Source

editProfile页面添加多语言

weicu
lxm 2 years ago
parent
commit
daa0b2f54b
  1. 5
      lib/core/translations/language/en_us.dart
  2. 5
      lib/core/translations/language/zh_cn.dart
  3. 46
      lib/modules/profile/views/profile_view.dart

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

@ -152,4 +152,9 @@ const Map<String, String> enUS = {
// 翻译页
"selectSourceLanguage": "Select Source Language",
"selectTargetLanguage": "Select Target Language",
//编辑个人信息页
"editProfile": "Edit Profile",
"nickname": "Nickname",
"save": "Save",
};

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

@ -147,4 +147,9 @@ const Map<String, String> zhCN = {
// 翻译页
"selectSourceLanguage": "选择源语言",
"selectTargetLanguage": "选择目标语言",
//编辑个人信息页
"editProfile": "编辑个人信息",
"nickname": "昵称",
"save": "保存",
};

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

@ -149,35 +149,13 @@ class EditProfileView extends GetView<ProfileController> {
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,
),
),
// actions: [
// TextButton(
// onPressed: () {
// // 保存用户名
// controller.updateUserName(nameController.text);
// // 返回上一级页面
// Get.back();
// },
// style: TextButton.styleFrom(
// foregroundColor: Colors.blue, // 确保按钮文字颜色
// padding: EdgeInsets.symmetric(horizontal: 16.w),
// ),
// child: Text(
// '保 存',
// style: TextStyle(
// fontSize: 16.sp,
// color: isDarkMode ? Colors.blue[300] : Colors.blue,
// fontWeight: FontWeight.w500,
// ),
// ),
// ),
// ],
),
body: Padding(
padding: EdgeInsets.all(16.w),
@ -221,13 +199,27 @@ class EditProfileView extends GetView<ProfileController> {
SizedBox(height: 20.h),
// 昵称编辑 - 使用外部定义的controller而不是每次重建
TextField(
Row(
children: [
Expanded(
child: TextField(
controller: nameController,
decoration: const InputDecoration(
labelText: '昵称',
decoration: InputDecoration(
labelText: 'nickname'.tr,
border: OutlineInputBorder(),
suffixIcon: nameController.text.isNotEmpty
? IconButton(
icon: Icon(Icons.clear),
onPressed: () {
nameController.clear();
},
)
: null,
),
),
),
],
),
// ... 其他编辑项 ...
SizedBox(height: 30.h),
@ -249,7 +241,7 @@ class EditProfileView extends GetView<ProfileController> {
),
),
child: Text(
'保存',
'save'.tr,
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,

Loading…
Cancel
Save