|
|
@ -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, |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
), |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
); |
|
|
|
); |
|
|
|