Browse Source

refactor(neon): Use Stacks conditionally

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/863/head
jld3103 1 year ago
parent
commit
7c3c3ca8e6
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  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;
@override
Widget build(final BuildContext context) => Stack(
alignment: Alignment.bottomRight,
children: [
Container(
Widget build(final BuildContext context) {
final icon = Container(
margin: const EdgeInsets.all(5),
child: appImplementation.buildIcon(
size: size,
color: color,
),
),
if (unreadCount > 0) ...[
);
if (unreadCount == 0) {
return icon;
}
return Stack(
alignment: Alignment.bottomRight,
children: [
icon,
Text(
unreadCount.toString(),
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;
size = constraints.constrain(Size.square(widget.size ?? largeIconSize)).shortestSide;
final pixelSize = (size * MediaQuery.of(context).devicePixelRatio).toInt();
return Stack(
alignment: Alignment.center,
children: [
CircleAvatar(
final avatar = CircleAvatar(
radius: size / 2,
backgroundColor: widget.backgroundColor,
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?>(
stream: _userStatusBloc.statuses.mapNotNull((final statuses) => statuses[widget.username]),
builder: _userStatusIconBuilder,
),
],
],
);
},
);

Loading…
Cancel
Save