Skip to content

Commit

Permalink
docs: added brief docs for fontSize function in avatar
Browse files Browse the repository at this point in the history
fix: get initials now returns the first and last name initials rather than first and second names.
  • Loading branch information
DE7924 committed Oct 9, 2024
1 parent 4396a17 commit b355c25
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/src/components/avatars/avatar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,14 @@ class ZetaAvatar extends ZetaStatelessWidget {
}
}

/// Font size for initials
static double fontSize(BuildContext context, ZetaAvatarSize size) {
return pixelSize(context, size) * 4 / 9;
}
}

extension on ZetaAvatarSize {
double pixelSize(BuildContext context) {
//TODO BK butchered this to make pixelSize reusable. Mike, is this ok?
return ZetaAvatar.pixelSize(context, this);
}

Expand Down
4 changes: 1 addition & 3 deletions lib/src/utils/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ extension StringExtensions on String? {
final List<String> nameParts = this!.split(RegExp(r'\W+'))..removeWhere((item) => item.isEmpty);
if (nameParts.isEmpty) return '';
return (nameParts.length > 1
// TODODE: Should the initials be the first letter of the first name and the last name or the second name?
// ? nameParts[0].substring(0, 1) + nameParts[nameParts.length - 1].substring(0, 1)
? nameParts[0].substring(0, 1) + nameParts[1].substring(0, 1)
? nameParts[0].substring(0, 1) + nameParts[nameParts.length - 1].substring(0, 1)
: nameParts[0].length > 1
? nameParts[0].substring(0, 2)
: nameParts[0])
Expand Down

0 comments on commit b355c25

Please sign in to comment.