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?>(
stream: Provider.of<AccountsBloc>(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,
),
),
),
),
);
},
),
],
);

Loading…
Cancel
Save