Skip to content

Commit

Permalink
fix space parent avatar null handling, avatar size
Browse files Browse the repository at this point in the history
  • Loading branch information
gtalha07 committed Nov 14, 2023
1 parent 8170e20 commit c80e17a
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/src/acter_avatar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ class _ActerAvatar extends State<ActerAvatar> {
Positioned(
bottom: -badgeOverflow,
right: -badgeOverflow,
child: widget.avatarsInfo == null || widget.avatarsInfo!.isEmpty
child: (widget.avatarsInfo == null ||
widget.avatarsInfo!.isEmpty ||
widget.avatarsInfo![0].avatar == null)
? SizedBox(height: badgeSize + badgeOverflow)
: Column(
children: <Widget>[
Expand Down Expand Up @@ -346,15 +348,16 @@ class _ActerAvatar extends State<ActerAvatar> {

Widget renderFallback(BuildContext context) {
double badgeOverflow = badgeSize / 5;
double fallbackSize = widget.size == null ? 48 : widget.size!;
double textFallbackSize = widget.size == null ? 48 : widget.size!;
double multiFallbackSize = widget.size == null ? 48 : widget.size! * 2.0;

/// Fallback
switch (widget.mode) {
case DisplayMode.DM:
// User fallback mode
return MultiAvatar(
uniqueId: widget.avatarInfo.uniqueId,
size: fallbackSize,
size: multiFallbackSize,
);
case DisplayMode.GroupDM:
return widget.avatarsInfo != null && widget.avatarsInfo!.isNotEmpty
Expand All @@ -364,7 +367,7 @@ class _ActerAvatar extends State<ActerAvatar> {
children: [
MultiAvatar(
uniqueId: widget.avatarInfo.uniqueId,
size: fallbackSize,
size: multiFallbackSize,
),
Positioned(
left: -7,
Expand All @@ -374,12 +377,12 @@ class _ActerAvatar extends State<ActerAvatar> {
message: secTooltipMsg(),
child: MultiAvatar(
uniqueId: widget.avatarsInfo![0].uniqueId,
size: fallbackSize,
size: multiFallbackSize,
),
)
: MultiAvatar(
uniqueId: widget.avatarsInfo![0].uniqueId,
size: fallbackSize,
size: multiFallbackSize,
),
),
widget.avatarsInfo!.length > 1
Expand Down Expand Up @@ -407,7 +410,7 @@ class _ActerAvatar extends State<ActerAvatar> {
)
: MultiAvatar(
uniqueId: widget.avatarInfo.uniqueId,
size: fallbackSize,
size: multiFallbackSize,
);
case DisplayMode.Space:
return Stack(
Expand All @@ -416,7 +419,7 @@ class _ActerAvatar extends State<ActerAvatar> {
TextAvatar(
text: widget.avatarInfo.displayName ?? widget.avatarInfo.uniqueId,
sourceText: widget.avatarInfo.uniqueId,
size: fallbackSize,
size: textFallbackSize,
shape: Shape.Rectangle,
),
Positioned(
Expand Down Expand Up @@ -457,7 +460,7 @@ class _ActerAvatar extends State<ActerAvatar> {
return TextAvatar(
text: widget.avatarInfo.displayName ?? widget.avatarInfo.uniqueId,
sourceText: widget.avatarInfo.uniqueId,
size: widget.size ?? 24,
size: widget.size ?? 48,
fontSize: 6,
shape: Shape.Rectangle,
);
Expand Down

0 comments on commit c80e17a

Please sign in to comment.