Skip to content

Commit

Permalink
[automated commit] lint format and import sort
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Mar 15, 2024
1 parent fb69806 commit 819c5fc
Showing 1 changed file with 10 additions and 29 deletions.
39 changes: 10 additions & 29 deletions lib/src/components/avatars/avatar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,23 @@ class ZetaAvatar extends StatelessWidget {
/// Notification Badge shown at top right corner of avatar.
final ZetaIndicator? upperBadge;

bool get _showPlaceholder =>
image == null && (initials == null || initials!.isEmpty);
bool get _showPlaceholder => image == null && (initials == null || initials!.isEmpty);

@override
Widget build(BuildContext context) {
final zetaColors = Zeta.of(context).colors;

final borderSize = size.borderSize;
final sizePixels = size.pixelSize;
final contentSizePixels =
size.pixelSize - (borderColor != null ? size.borderSize * 2 : 0);
final contentSizePixels = size.pixelSize - (borderColor != null ? size.borderSize * 2 : 0);

final innerContent = ClipRRect(
borderRadius: BorderRadius.circular(64),
clipBehavior: Clip.hardEdge,
child: image ??
(_showPlaceholder
? Container(
transform: Matrix4.translationValues(
-contentSizePixels * 0.2, -contentSizePixels * 0.1, 0),
transform: Matrix4.translationValues(-contentSizePixels * 0.2, -contentSizePixels * 0.1, 0),
child: IconTheme(
data: IconThemeData(
color: Zeta.of(context).colors.cool,
Expand All @@ -121,11 +118,8 @@ class ZetaAvatar extends StatelessWidget {
)
: Center(
child: Text(
size == ZetaAvatarSize.xs
? initials!.substring(0, 1)
: initials!,
style:
TextStyle(fontSize: size.fontSize, letterSpacing: -0.5),
size == ZetaAvatarSize.xs ? initials!.substring(0, 1) : initials!,
style: TextStyle(fontSize: size.fontSize, letterSpacing: -0.5),
),
)),
);
Expand All @@ -137,33 +131,20 @@ class ZetaAvatar extends StatelessWidget {
width: sizePixels,
height: sizePixels,
decoration: BoxDecoration(
border: borderColor != null
? Border.all(
color: borderColor!, width: borderSize / ZetaSpacing.x0_5)
: null,
border: borderColor != null ? Border.all(color: borderColor!, width: borderSize / ZetaSpacing.x0_5) : null,
borderRadius: ZetaRadius.full,
color: backgroundColor ??
(_showPlaceholder
? zetaColors.surfacePrimary
: zetaColors.cool.shade20),
color: backgroundColor ?? (_showPlaceholder ? zetaColors.surfacePrimary : zetaColors.cool.shade20),
),
child: borderColor != null
? Container(
width: contentSizePixels,
height: contentSizePixels,
decoration: BoxDecoration(
color: _showPlaceholder
? backgroundColor ?? zetaColors.surfaceHovered
: null,
border: Border.all(
color: zetaColors.surfacePrimary,
width: borderSize / ZetaSpacing.x0_5),
color: _showPlaceholder ? backgroundColor ?? zetaColors.surfaceHovered : null,
border: Border.all(color: zetaColors.surfacePrimary, width: borderSize / ZetaSpacing.x0_5),
borderRadius: ZetaRadius.full,
),
child: ClipRRect(
borderRadius: ZetaRadius.full,
clipBehavior: Clip.hardEdge,
child: innerContent),
child: ClipRRect(borderRadius: ZetaRadius.full, clipBehavior: Clip.hardEdge, child: innerContent),
)
: DecoratedBox(
decoration: BoxDecoration(
Expand Down

0 comments on commit 819c5fc

Please sign in to comment.