Skip to content

Commit

Permalink
Merge pull request #368 from provokateurin/fix/user-avatars
Browse files Browse the repository at this point in the history
Cleanup user avatars
  • Loading branch information
provokateurin authored Jun 7, 2023
2 parents 7918047 + 342c9fe commit 42b7f78
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/neon/neon/lib/src/widgets/user_avatar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ class NeonUserAvatar extends StatefulWidget {
final String? username,
this.showStatus = true,
this.size = kAvatarSize,
this.backgroundColor,
this.foregroundColor,
super.key,
}) : username = username ?? account.client.username!;

final Account account;
final String username;
final bool showStatus;
final double size;
final Color? backgroundColor;
final Color? foregroundColor;

@override
State<NeonUserAvatar> createState() => _UserAvatarState();
Expand All @@ -31,7 +35,9 @@ class _UserAvatarState extends State<NeonUserAvatar> {
void initState() {
super.initState();

unawaited(_userStatusBloc.load(widget.username));
if (widget.showStatus) {
unawaited(_userStatusBloc.load(widget.username));
}
}

@override
Expand All @@ -45,6 +51,7 @@ class _UserAvatarState extends State<NeonUserAvatar> {
children: [
CircleAvatar(
radius: size / 2,
backgroundColor: widget.backgroundColor,
child: ClipOval(
child: NeonCachedApiImage(
account: widget.account,
Expand Down Expand Up @@ -85,7 +92,7 @@ class _UserAvatarState extends State<NeonUserAvatar> {
if (result.loading) {
child = CircularProgressIndicator(
strokeWidth: 1.5,
color: Theme.of(context).colorScheme.onPrimary,
color: widget.foregroundColor ?? Theme.of(context).colorScheme.onPrimary,
);
} else if (result.error != null) {
child = Icon(
Expand Down

0 comments on commit 42b7f78

Please sign in to comment.