Browse Source

Merge pull request #209 from provokateurin/feature/emoji-status

neon: Display emojis for status
pull/201/head
Kate 2 years ago committed by GitHub
parent
commit
2051b30cb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 71
      packages/neon/lib/src/widgets/account_avatar.dart

71
packages/neon/lib/src/widgets/account_avatar.dart

@ -41,37 +41,48 @@ class AccountAvatar extends StatelessWidget {
), ),
ResultBuilder<UserStatusBloc, NextcloudUserStatusStatus?>( ResultBuilder<UserStatusBloc, NextcloudUserStatusStatus?>(
stream: Provider.of<AccountsBloc>(context, listen: false).getUserStatusBloc(account).userStatus, stream: Provider.of<AccountsBloc>(context, listen: false).getUserStatusBloc(account).userStatus,
builder: (final context, final userStatus) => SizedBox( builder: (final context, final userStatus) {
height: kAvatarSize, final hasEmoji = userStatus.data?.icon != null;
width: kAvatarSize, final factor = hasEmoji ? 2 : 3;
child: Align( return SizedBox(
alignment: Alignment.bottomRight, height: kAvatarSize,
child: Container( width: kAvatarSize,
height: kAvatarSize / 3, child: Align(
width: kAvatarSize / 3, alignment: Alignment.bottomRight,
decoration: userStatus.loading || userStatus.error != null || userStatus.data == null child: Container(
? null height: kAvatarSize / factor,
: BoxDecoration( width: kAvatarSize / factor,
shape: BoxShape.circle, decoration: userStatus.loading || userStatus.error != null || userStatus.data == null || hasEmoji
color: _userStatusToColor(userStatus.data!), ? null
), : BoxDecoration(
child: userStatus.loading shape: BoxShape.circle,
? CircularProgressIndicator( color: _userStatusToColor(userStatus.data!),
strokeWidth: 1.5, ),
color: Theme.of(context).colorScheme.onPrimary, child: userStatus.loading
) ? CircularProgressIndicator(
: userStatus.error != null && strokeWidth: 1.5,
(userStatus.error is! NextcloudApiException || color: Theme.of(context).colorScheme.onPrimary,
(userStatus.error! as NextcloudApiException).statusCode != 404) )
? const Icon( : userStatus.error != null &&
Icons.error_outline, (userStatus.error is! NextcloudApiException ||
size: kAvatarSize / 3, (userStatus.error! as NextcloudApiException).statusCode != 404)
color: Colors.red, ? Icon(
) Icons.error_outline,
: null, size: kAvatarSize / factor,
color: Colors.red,
)
: hasEmoji
? Text(
userStatus.data!.icon!,
style: const TextStyle(
fontSize: 16,
),
)
: null,
),
), ),
), );
), },
), ),
], ],
); );

Loading…
Cancel
Save