From 8c8c5e16a9a56b67793e4e90c3b5b3da7b03088a Mon Sep 17 00:00:00 2001 From: lxm <1274844347@qq.com> Date: Thu, 20 Mar 2025 15:51:21 +0800 Subject: [PATCH] =?UTF-8?q?editProfile=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=A4=9A=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core/translations/language/en_us.dart | 5 ++ lib/core/translations/language/zh_cn.dart | 5 ++ lib/modules/profile/views/profile_view.dart | 52 +++++++++------------ 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/lib/core/translations/language/en_us.dart b/lib/core/translations/language/en_us.dart index 1df8d03eb..72a8c0c35 100644 --- a/lib/core/translations/language/en_us.dart +++ b/lib/core/translations/language/en_us.dart @@ -152,4 +152,9 @@ const Map enUS = { // 翻译页 "selectSourceLanguage": "Select Source Language", "selectTargetLanguage": "Select Target Language", + + //编辑个人信息页 + "editProfile": "Edit Profile", + "nickname": "Nickname", + "save": "Save", }; diff --git a/lib/core/translations/language/zh_cn.dart b/lib/core/translations/language/zh_cn.dart index 657a6880c..c1828d06c 100644 --- a/lib/core/translations/language/zh_cn.dart +++ b/lib/core/translations/language/zh_cn.dart @@ -147,4 +147,9 @@ const Map zhCN = { // 翻译页 "selectSourceLanguage": "选择源语言", "selectTargetLanguage": "选择目标语言", + + //编辑个人信息页 + "editProfile": "编辑个人信息", + "nickname": "昵称", + "save": "保存", }; diff --git a/lib/modules/profile/views/profile_view.dart b/lib/modules/profile/views/profile_view.dart index dd21ed8bc..c2947f532 100644 --- a/lib/modules/profile/views/profile_view.dart +++ b/lib/modules/profile/views/profile_view.dart @@ -149,35 +149,13 @@ class EditProfileView extends GetView { 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,12 +199,26 @@ class EditProfileView extends GetView { SizedBox(height: 20.h), // 昵称编辑 - 使用外部定义的controller而不是每次重建 - TextField( - controller: nameController, - decoration: const InputDecoration( - labelText: '昵称', - border: OutlineInputBorder(), - ), + 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, + ), + ), + ), + ], ), // ... 其他编辑项 ... @@ -249,7 +241,7 @@ class EditProfileView extends GetView { ), ), child: Text( - '保存', + 'save'.tr, style: TextStyle( fontSize: 16.sp, color: Colors.white,