From 6575467d25d823d98b6e734accd33b1aea1fa317 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Fri, 10 Mar 2023 21:54:31 +0100 Subject: [PATCH] neon: Display emojis for status --- .../neon/lib/src/widgets/account_avatar.dart | 71 +++++++++++-------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/packages/neon/lib/src/widgets/account_avatar.dart b/packages/neon/lib/src/widgets/account_avatar.dart index 866c0de1..ba5f5928 100644 --- a/packages/neon/lib/src/widgets/account_avatar.dart +++ b/packages/neon/lib/src/widgets/account_avatar.dart @@ -41,37 +41,48 @@ class AccountAvatar extends StatelessWidget { ), ResultBuilder( stream: Provider.of(context, listen: false).getUserStatusBloc(account).userStatus, - builder: (final context, final userStatus) => SizedBox( - height: kAvatarSize, - width: kAvatarSize, - child: Align( - alignment: Alignment.bottomRight, - child: Container( - height: kAvatarSize / 3, - width: kAvatarSize / 3, - decoration: userStatus.loading || userStatus.error != null || userStatus.data == null - ? null - : BoxDecoration( - shape: BoxShape.circle, - color: _userStatusToColor(userStatus.data!), - ), - child: userStatus.loading - ? CircularProgressIndicator( - strokeWidth: 1.5, - color: Theme.of(context).colorScheme.onPrimary, - ) - : userStatus.error != null && - (userStatus.error is! NextcloudApiException || - (userStatus.error! as NextcloudApiException).statusCode != 404) - ? const Icon( - Icons.error_outline, - size: kAvatarSize / 3, - color: Colors.red, - ) - : null, + builder: (final context, final userStatus) { + final hasEmoji = userStatus.data?.icon != null; + final factor = hasEmoji ? 2 : 3; + return SizedBox( + height: kAvatarSize, + width: kAvatarSize, + child: Align( + alignment: Alignment.bottomRight, + child: Container( + height: kAvatarSize / factor, + width: kAvatarSize / factor, + decoration: userStatus.loading || userStatus.error != null || userStatus.data == null || hasEmoji + ? null + : BoxDecoration( + shape: BoxShape.circle, + color: _userStatusToColor(userStatus.data!), + ), + child: userStatus.loading + ? CircularProgressIndicator( + strokeWidth: 1.5, + color: Theme.of(context).colorScheme.onPrimary, + ) + : userStatus.error != null && + (userStatus.error is! NextcloudApiException || + (userStatus.error! as NextcloudApiException).statusCode != 404) + ? Icon( + Icons.error_outline, + size: kAvatarSize / factor, + color: Colors.red, + ) + : hasEmoji + ? Text( + userStatus.data!.icon!, + style: const TextStyle( + fontSize: 16, + ), + ) + : null, + ), ), - ), - ), + ); + }, ), ], );