Browse Source

Merge pull request #863 from nextcloud/refactor/neon/conditional-stacks

refactor(neon): Use Stacks conditionally
pull/865/head
Kate 1 year ago committed by GitHub
parent
commit
3cf9bfe76b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      packages/neon/neon/lib/src/widgets/app_implementation_icon.dart
  2. 19
      packages/neon/neon/lib/src/widgets/user_avatar.dart

20
packages/neon/neon/lib/src/widgets/app_implementation_icon.dart

@ -21,17 +21,23 @@ class NeonAppImplementationIcon extends StatelessWidget {
final double? size; final double? size;
@override @override
Widget build(final BuildContext context) => Stack( Widget build(final BuildContext context) {
alignment: Alignment.bottomRight, final icon = Container(
children: [
Container(
margin: const EdgeInsets.all(5), margin: const EdgeInsets.all(5),
child: appImplementation.buildIcon( child: appImplementation.buildIcon(
size: size, size: size,
color: color, color: color,
), ),
), );
if (unreadCount > 0) ...[
if (unreadCount == 0) {
return icon;
}
return Stack(
alignment: Alignment.bottomRight,
children: [
icon,
Text( Text(
unreadCount.toString(), unreadCount.toString(),
style: TextStyle( style: TextStyle(
@ -40,6 +46,6 @@ class NeonAppImplementationIcon extends StatelessWidget {
), ),
), ),
], ],
],
); );
} }
}

19
packages/neon/neon/lib/src/widgets/user_avatar.dart

@ -56,10 +56,8 @@ class _UserAvatarState extends State<NeonUserAvatar> {
final brightness = Theme.of(context).brightness; final brightness = Theme.of(context).brightness;
size = constraints.constrain(Size.square(widget.size ?? largeIconSize)).shortestSide; size = constraints.constrain(Size.square(widget.size ?? largeIconSize)).shortestSide;
final pixelSize = (size * MediaQuery.of(context).devicePixelRatio).toInt(); final pixelSize = (size * MediaQuery.of(context).devicePixelRatio).toInt();
return Stack(
alignment: Alignment.center, final avatar = CircleAvatar(
children: [
CircleAvatar(
radius: size / 2, radius: size / 2,
backgroundColor: widget.backgroundColor, backgroundColor: widget.backgroundColor,
child: ClipOval( child: ClipOval(
@ -82,14 +80,21 @@ class _UserAvatarState extends State<NeonUserAvatar> {
}, },
), ),
), ),
), );
if (widget.showStatus) ...[
if (!widget.showStatus) {
return avatar;
}
return Stack(
alignment: Alignment.center,
children: [
avatar,
ResultBuilder<UserStatusPublicInterface?>( ResultBuilder<UserStatusPublicInterface?>(
stream: _userStatusBloc.statuses.mapNotNull((final statuses) => statuses[widget.username]), stream: _userStatusBloc.statuses.mapNotNull((final statuses) => statuses[widget.username]),
builder: _userStatusIconBuilder, builder: _userStatusIconBuilder,
), ),
], ],
],
); );
}, },
); );

Loading…
Cancel
Save