From a043fc3b26067f20b6def0981f76c6eb26ed3b59 Mon Sep 17 00:00:00 2001 From: mikecoomber Date: Mon, 11 Nov 2024 14:48:13 +0000 Subject: [PATCH] fixed avatar initials text scaling --- .../lib/pages/components/avatar_example.dart | 12 ++++++++ .../Flutter/GeneratedPluginRegistrant.swift | 2 +- lib/src/components/avatars/avatar.dart | 30 ++++++++----------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/example/lib/pages/components/avatar_example.dart b/example/lib/pages/components/avatar_example.dart index 990f3c68..ff3aaa90 100644 --- a/example/lib/pages/components/avatar_example.dart +++ b/example/lib/pages/components/avatar_example.dart @@ -18,6 +18,13 @@ class AvatarExample extends StatelessWidget { ); return ExampleScaffold( + actions: [ + ZetaAvatar.initials( + initials: 'W W', + size: ZetaAvatarSize.xxs, + backgroundColor: Zeta.of(context).colors.green, + ), + ], name: AvatarExample.name, child: SingleChildScrollView( scrollDirection: Axis.horizontal, @@ -25,6 +32,11 @@ class AvatarExample extends StatelessWidget { padding: EdgeInsets.all(Zeta.of(context).spacing.medium), child: Column( children: [ + ZetaAvatar.initials( + initials: 'WW', + size: ZetaAvatarSize.xxs, + backgroundColor: Zeta.of(context).colors.green, + ), Column( children: [ Text( diff --git a/example/macos/Flutter/GeneratedPluginRegistrant.swift b/example/macos/Flutter/GeneratedPluginRegistrant.swift index 8c72a8c7..63ad0d13 100644 --- a/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,7 +7,7 @@ import Foundation import path_provider_foundation import shared_preferences_foundation -import sqflite_darwin +import sqflite import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { diff --git a/lib/src/components/avatars/avatar.dart b/lib/src/components/avatars/avatar.dart index 145d9e7c..7ca1443f 100644 --- a/lib/src/components/avatars/avatar.dart +++ b/lib/src/components/avatars/avatar.dart @@ -228,15 +228,17 @@ class ZetaAvatar extends ZetaStatelessWidget { final innerChild = image ?? (initials != null ? Center( - child: Text( - initials!, - style: initialTextStyle ?? - TextStyle( - fontSize: size.fontSize(context), - letterSpacing: Zeta.of(context).spacing.none, - color: backgroundColor?.onColor, - fontWeight: FontWeight.w500, - ), + child: FittedBox( + child: Text( + initials!, + style: initialTextStyle ?? + TextStyle( + fontSize: size.fontSize(context), + letterSpacing: Zeta.of(context).spacing.none, + color: backgroundColor?.onColor, + fontWeight: FontWeight.w500, + ), + ), ), ) : null); @@ -280,20 +282,14 @@ class ZetaAvatar extends ZetaStatelessWidget { border: Border.all(color: borderColor!, width: borderSize(context)), borderRadius: Zeta.of(context).radius.full, ), - child: ClipRRect( - borderRadius: Zeta.of(context).radius.full, - child: innerContent, - ), + child: innerContent, ) : DecoratedBox( decoration: BoxDecoration( borderRadius: Zeta.of(context).radius.full, color: backgroundColor ?? zetaColors.surfaceHover, ), - child: ClipRRect( - borderRadius: Zeta.of(context).radius.full, - child: innerContent, - ), + child: innerContent, ), ), ),