Added Last Name display and made it editable
This commit is contained in:
@@ -20,6 +20,14 @@ class AccountBase implements StorableDescribable {
|
||||
DateTime get updatedAt => storable.updatedAt;
|
||||
@override
|
||||
String get name => describable.name;
|
||||
String get fullName {
|
||||
final first = describable.name.trim();
|
||||
final last = lastName.trim();
|
||||
|
||||
if (last.isEmpty) return first;
|
||||
if (first.isEmpty) return last;
|
||||
return '$first $last';
|
||||
}
|
||||
@override
|
||||
String? get description => describable.description;
|
||||
|
||||
@@ -32,7 +40,7 @@ class AccountBase implements StorableDescribable {
|
||||
required this.lastName,
|
||||
});
|
||||
|
||||
String get nameInitials => getNameInitials(describable.name);
|
||||
String get nameInitials => getNameInitials(fullName);
|
||||
|
||||
AccountBase copyWith({
|
||||
Describable? describable,
|
||||
|
||||
@@ -203,6 +203,7 @@ class AccountProvider extends ChangeNotifier {
|
||||
|
||||
Future<Account?> update({
|
||||
Describable? describable,
|
||||
String? lastName,
|
||||
String? locale,
|
||||
String? avatarUrl,
|
||||
String? notificationFrequency,
|
||||
@@ -213,6 +214,7 @@ class AccountProvider extends ChangeNotifier {
|
||||
final updated = await AccountService.update(
|
||||
account!.copyWith(
|
||||
describable: describable,
|
||||
lastName: lastName,
|
||||
avatarUrl: () => avatarUrl ?? account!.avatarUrl,
|
||||
locale: locale ?? account!.locale,
|
||||
),
|
||||
@@ -250,10 +252,11 @@ class AccountProvider extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<Account?> resetUsername(String userName) async {
|
||||
Future<Account?> resetUsername(String userName, {String? lastName}) async {
|
||||
if (account == null) throw ErrorUnauthorized();
|
||||
return update(
|
||||
describable: account!.describable.copyWith(name: userName),
|
||||
lastName: lastName ?? account!.lastName,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user