Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: avatar #183

Merged
merged 11 commits into from
Oct 11, 2024
2 changes: 1 addition & 1 deletion example/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Foundation

import path_provider_foundation
import shared_preferences_foundation
import sqflite
import sqflite_darwin
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
Expand Down
23 changes: 17 additions & 6 deletions lib/src/components/avatars/avatar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class ZetaAvatar extends ZetaStatelessWidget {
(initials != null
? Center(
child: Text(
size == ZetaAvatarSize.xs ? initials!.substring(0, 1) : initials!,
initials!,
style: initialTextStyle ??
TextStyle(
fontSize: size.fontSize(context),
Expand Down Expand Up @@ -288,11 +288,11 @@ class ZetaAvatar extends ZetaStatelessWidget {
..add(StringProperty('semanticLowerBadgeValue', semanticLowerBadgeLabel))
..add(DiagnosticsProperty<TextStyle>('initialTextStyle', initialTextStyle));
}
}

extension on ZetaAvatarSize {
double pixelSize(BuildContext context) {
switch (this) {
//TODO BK butchered this to make pixelSize reusable. Mike, is this ok?
DE7924 marked this conversation as resolved.
Show resolved Hide resolved
///
static double pixelSize(BuildContext context, ZetaAvatarSize size) {
switch (size) {
case ZetaAvatarSize.xxxl:
return Zeta.of(context).spacing.minimum * 50; // TODO(UX-1202): ZetaSpacingBase
// return ZetaSpacingBase.x50;
Expand All @@ -316,6 +316,17 @@ extension on ZetaAvatarSize {
}
}

static double fontSize(BuildContext context, ZetaAvatarSize size) {
thelukewalton marked this conversation as resolved.
Show resolved Hide resolved
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);
}

double borderSize(BuildContext context) {
switch (this) {
case ZetaAvatarSize.xxxl:
Expand All @@ -335,7 +346,7 @@ extension on ZetaAvatarSize {
}

double fontSize(BuildContext context) {
return pixelSize(context) * 4 / 9;
return ZetaAvatar.fontSize(context, this);
}
}

Expand Down
2 changes: 2 additions & 0 deletions lib/src/utils/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ 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)
thelukewalton marked this conversation as resolved.
Show resolved Hide resolved
? nameParts[0].substring(0, 1) + nameParts[1].substring(0, 1)
: nameParts[0].length > 1
? nameParts[0].substring(0, 2)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading