From 418277000d1ed3c66884b92b0d596fab82e245e1 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Wed, 7 Jun 2023 10:25:15 +0200 Subject: [PATCH 1/2] neon: Add background and foreground color to user avatar --- packages/neon/neon/lib/src/widgets/user_avatar.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/neon/neon/lib/src/widgets/user_avatar.dart b/packages/neon/neon/lib/src/widgets/user_avatar.dart index ce23ce3b..a9613302 100644 --- a/packages/neon/neon/lib/src/widgets/user_avatar.dart +++ b/packages/neon/neon/lib/src/widgets/user_avatar.dart @@ -11,6 +11,8 @@ class NeonUserAvatar extends StatefulWidget { final String? username, this.showStatus = true, this.size = kAvatarSize, + this.backgroundColor, + this.foregroundColor, super.key, }) : username = username ?? account.client.username!; @@ -18,6 +20,8 @@ class NeonUserAvatar extends StatefulWidget { final String username; final bool showStatus; final double size; + final Color? backgroundColor; + final Color? foregroundColor; @override State createState() => _UserAvatarState(); @@ -45,6 +49,7 @@ class _UserAvatarState extends State { children: [ CircleAvatar( radius: size / 2, + backgroundColor: widget.backgroundColor, child: ClipOval( child: NeonCachedApiImage( account: widget.account, @@ -85,7 +90,7 @@ class _UserAvatarState extends State { 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( From 342c9fed87ebdddedf74243016899cb92ace900e Mon Sep 17 00:00:00 2001 From: jld3103 Date: Wed, 7 Jun 2023 10:26:09 +0200 Subject: [PATCH 2/2] neon: Only load user status of status will be shown --- packages/neon/neon/lib/src/widgets/user_avatar.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/neon/neon/lib/src/widgets/user_avatar.dart b/packages/neon/neon/lib/src/widgets/user_avatar.dart index a9613302..3d1643e8 100644 --- a/packages/neon/neon/lib/src/widgets/user_avatar.dart +++ b/packages/neon/neon/lib/src/widgets/user_avatar.dart @@ -35,7 +35,9 @@ class _UserAvatarState extends State { void initState() { super.initState(); - unawaited(_userStatusBloc.load(widget.username)); + if (widget.showStatus) { + unawaited(_userStatusBloc.load(widget.username)); + } } @override