merge: 合并 K44-A 个人资料页修正
This commit is contained in:
commit
0ad2cd5e95
4 files changed
+7
-48
No files matched your search
@@ -429,7 +429,7 @@ class AppLocalizationsZh extends AppLocalizations {
|
||||
String get like => '喜欢';
|
||||
|
||||
@override
|
||||
String get save => '收藏';
|
||||
String get save => '保存';
|
||||
|
||||
@override
|
||||
String get comments => '评论';
|
||||
|
||||
+1
-1
@@ -171,7 +171,7 @@
|
||||
"mute": "静音",
|
||||
"unmute": "取消静音",
|
||||
"like": "喜欢",
|
||||
"save": "收藏",
|
||||
"save": "保存",
|
||||
"comments": "评论",
|
||||
"share": "分享",
|
||||
"noComments": "还没有评论。",
|
||||
|
||||
@@ -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});
|
||||
|
||||
|
||||
@@ -28,15 +28,19 @@ void main() {
|
||||
AccountProfilePage(),
|
||||
repository: repository,
|
||||
auth: auth,
|
||||
locale: const Locale('zh'),
|
||||
);
|
||||
|
||||
final nickname = find.byKey(const Key('account-nickname'));
|
||||
expect(find.byKey(const Key('account-birthday')), findsNothing);
|
||||
expect(find.text('保存'), findsOneWidget);
|
||||
expect(tester.widget<TextField>(nickname).controller?.text, 'Nadia');
|
||||
await tester.enterText(nickname, 'Nadia Baru');
|
||||
await tester.tap(find.byKey(const Key('account-profile-save')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(repository.lastUpdate?.nickname, 'Nadia Baru');
|
||||
expect(repository.lastUpdate?.birthday, isNull);
|
||||
});
|
||||
|
||||
testWidgets('should_show_device_empty_state_when_list_is_empty', (
|
||||
|
||||
Reference in new issue
Block a user