fix(flutter): 精简个人资料并修正保存文案

This commit is contained in:
Zhou Weidong committed 2026-10-20 16:42:27 +08:00
1 parent dc73f4e3bb
commit b2a8bfa59f
4 files changed
+7 -48

No files matched your search

+1 -1
View File
@@ -429,7 +429,7 @@ class AppLocalizationsZh extends AppLocalizations {
String get like => '喜欢';
@override
String get save => '收藏';
String get save => '保存';
@override
String get comments => '评论';
+1 -1
View File
@@ -171,7 +171,7 @@
"mute": "静音",
"unmute": "取消静音",
"like": "喜欢",
"save": "收藏",
"save": "保存",
"comments": "评论",
"share": "分享",
"noComments": "还没有评论。",
+1 -46
View File
@@ -23,7 +23,6 @@ import 'account_profile_logic.dart';
const _avatarSize = 64.0;
const _fieldGap = 14.0;
const _datePadWidth = 2;
/// 个人资料编辑页。
class AccountProfilePage extends StatefulWidget {
@@ -37,7 +36,6 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
late final AccountProfileLogic _logic;
final _nickname = TextEditingController();
var _gender = 'unknown';
String? _birthday;
bool _formReady = false;
@override
@@ -163,8 +161,6 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
_nicknameField(l10n),
const SizedBox(height: _fieldGap),
_genderField(l10n),
const SizedBox(height: _fieldGap),
_birthdayField(l10n),
if (_logic.error != null) _saveError(l10n),
const SizedBox(height: 16),
_saveButton(l10n),
@@ -200,26 +196,6 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
},
);
Widget _birthdayField(AppLocalizations l10n) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
OutlinedButton.icon(
key: const Key('account-birthday'),
onPressed: _pickBirthday,
icon: const Icon(Icons.cake_outlined),
label: Text(_birthday ?? l10n.accountSelectBirthday),
),
const SizedBox(height: 6),
Text(
l10n.accountBirthdayHint,
style: const TextStyle(
color: AppColors.muted,
fontSize: AppDimens.caption,
),
),
],
);
Widget _saveError(AppLocalizations l10n) => Padding(
padding: const EdgeInsets.only(top: 8),
child: Text(
@@ -307,24 +283,8 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
),
);
Future<void> _pickBirthday() async {
final value = await showDatePicker(
context: context,
initialDate: DateTime(2000),
firstDate: DateTime(1900),
lastDate: DateTime.now(),
);
if (value != null && mounted) {
setState(() => _birthday = _formatDate(value));
}
}
Future<void> _save() async {
final ok = await _logic.save(
nickname: _nickname.text,
gender: _gender,
birthday: _birthday,
);
final ok = await _logic.save(nickname: _nickname.text, gender: _gender);
if (!ok || !mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(AppLocalizations.of(context)!.accountSaved)),
@@ -335,11 +295,6 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
const {'male', 'female', 'unknown'}.contains(value) ? value : 'unknown';
}
String _formatDate(DateTime value) =>
'${value.year.toString().padLeft(4, '0')}-'
'${value.month.toString().padLeft(_datePadWidth, '0')}-'
'${value.day.toString().padLeft(_datePadWidth, '0')}';
class _AccountCard extends StatelessWidget {
const _AccountCard({required this.child});