mirror of
https://github.com/immich-app/immich.git
synced 2025-02-04 01:09:14 -05:00
fix(mobile): avatar without last name (#3038)
This commit is contained in:
parent
ca98d73d86
commit
b05f3fd266
1 changed files with 3 additions and 1 deletions
|
@ -6,6 +6,8 @@ import 'package:immich_mobile/shared/models/user.dart';
|
||||||
Widget userAvatar(BuildContext context, User u, {double? radius}) {
|
Widget userAvatar(BuildContext context, User u, {double? radius}) {
|
||||||
final url =
|
final url =
|
||||||
"${Store.get(StoreKey.serverEndpoint)}/user/profile-image/${u.id}";
|
"${Store.get(StoreKey.serverEndpoint)}/user/profile-image/${u.id}";
|
||||||
|
final firstNameFirstLetter = u.firstName.isNotEmpty ? u.firstName[0] : "";
|
||||||
|
final lastNameFirstLetter = u.lastName.isNotEmpty ? u.lastName[0] : "";
|
||||||
return CircleAvatar(
|
return CircleAvatar(
|
||||||
radius: radius,
|
radius: radius,
|
||||||
backgroundColor: Theme.of(context).primaryColor.withAlpha(50),
|
backgroundColor: Theme.of(context).primaryColor.withAlpha(50),
|
||||||
|
@ -16,6 +18,6 @@ Widget userAvatar(BuildContext context, User u, {double? radius}) {
|
||||||
),
|
),
|
||||||
// silence errors if user has no profile image, use initials as fallback
|
// silence errors if user has no profile image, use initials as fallback
|
||||||
onForegroundImageError: (exception, stackTrace) {},
|
onForegroundImageError: (exception, stackTrace) {},
|
||||||
child: Text((u.firstName[0] + u.lastName[0]).toUpperCase()),
|
child: Text((firstNameFirstLetter + lastNameFirstLetter).toUpperCase()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue