Skip to content

Commit

Permalink
fixed avatar initials text scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecoomber committed Nov 11, 2024
1 parent 35ae61d commit a043fc3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
12 changes: 12 additions & 0 deletions example/lib/pages/components/avatar_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,25 @@ 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,
child: SingleChildScrollView(
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(
Expand Down
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_darwin
import sqflite
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
Expand Down
30 changes: 13 additions & 17 deletions lib/src/components/avatars/avatar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
),
),
),
Expand Down

0 comments on commit a043fc3

Please sign in to comment.