Skip to content

Commit

Permalink
Use realName
Browse files Browse the repository at this point in the history
  • Loading branch information
veloce committed Jun 28, 2024
1 parent 1caccf5 commit 2976187
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 25 deletions.
10 changes: 2 additions & 8 deletions lib/src/model/user/profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class Profile with _$Profile {
String? country,
String? location,
String? bio,
String? firstName,
String? lastName,
String? realName,
int? fideRating,
int? uscfRating,
int? ecfRating,
Expand All @@ -23,10 +22,6 @@ class Profile with _$Profile {

const Profile._();

String? get fullName => firstName != null && lastName != null
? '$firstName $lastName'
: firstName ?? lastName;

factory Profile.fromJson(Map<String, dynamic> json) {
return Profile.fromPick(pick(json).required());
}
Expand All @@ -41,8 +36,7 @@ class Profile with _$Profile {
pick('flag').asStringOrNull() ?? pick('country').asStringOrNull(),
location: pick('location').asStringOrNull(),
bio: pick('bio').asStringOrNull(),
firstName: pick('firstName').asStringOrNull(),
lastName: pick('lastName').asStringOrNull(),
realName: pick('realName').asStringOrNull(),
fideRating: pick('fideRating').asIntOrNull(),
uscfRating: pick('uscfRating').asIntOrNull(),
ecfRating: pick('ecfRating').asIntOrNull(),
Expand Down
17 changes: 4 additions & 13 deletions lib/src/view/account/edit_profile_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,11 @@ class _EditProfileFormState extends ConsumerState<_EditProfileForm> {
maxLength: 80,
),
_textField(
label: context.l10n.firstName,
initialValue: widget.user.profile?.firstName,
formKey: 'firstName',
label: context.l10n.name,
initialValue: widget.user.profile?.realName,
formKey: 'realName',
controller: TextEditingController(
text: widget.user.profile?.firstName,
),
maxLength: 20,
),
_textField(
label: context.l10n.lastName,
initialValue: widget.user.profile?.lastName,
formKey: 'lastName',
controller: TextEditingController(
text: widget.user.profile?.lastName,
text: widget.user.profile?.realName,
),
maxLength: 20,
),
Expand Down
4 changes: 2 additions & 2 deletions lib/src/view/user/user_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class UserProfileWidget extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final userFullName = user.profile?.fullName != null
final userFullName = user.profile?.realName != null
? Text(
user.profile!.fullName!,
user.profile!.realName!,
style: _userNameStyle,
)
: null;
Expand Down
3 changes: 1 addition & 2 deletions test/view/user/user_screen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ const testUserResponse = '''
"country": "France",
"location": "Lille",
"bio": "test bio",
"firstName": "John",
"lastName": "Doe",
"realName": "John Doe",
"fideRating": 1800,
"links": "http://test.com"
}
Expand Down

0 comments on commit 2976187

Please sign in to comment.