From 254102b74691c007763e66319ff316d6a365f661 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sat, 19 Aug 2023 16:03:15 +0200 Subject: [PATCH] feat(neon): Use user status icons Signed-off-by: jld3103 --- packages/neon/neon/lib/src/theme/colors.dart | 12 ------------ packages/neon/neon/lib/src/widgets/user_avatar.dart | 12 ++++-------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/packages/neon/neon/lib/src/theme/colors.dart b/packages/neon/neon/lib/src/theme/colors.dart index 1255dd94..c926ea00 100644 --- a/packages/neon/neon/lib/src/theme/colors.dart +++ b/packages/neon/neon/lib/src/theme/colors.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:nextcloud/nextcloud.dart'; /// [Color] constants which represent Nextcloud's /// [color palette](https://docs.nextcloud.com/server/latest/developer_manual/design/foundations.html#color). @@ -42,14 +41,3 @@ abstract final class NcColors { /// Usually used in conjunction with [NcColors.decline]. static const Color accept = Colors.green; } - -/// [UserStatusPublic] status color mapping. -extension UserStatusTypeColors on UserStatusPublic { - /// The color for the user status. - Color? get color => switch (status) { - 'online' => const Color(0xFF49B382), - 'away' => const Color(0xFFF4A331), - 'dnd' => const Color(0xFFED484C), - _ => null, - }; -} diff --git a/packages/neon/neon/lib/src/widgets/user_avatar.dart b/packages/neon/neon/lib/src/widgets/user_avatar.dart index d016f356..bc56356e 100644 --- a/packages/neon/neon/lib/src/widgets/user_avatar.dart +++ b/packages/neon/neon/lib/src/widgets/user_avatar.dart @@ -9,6 +9,7 @@ import 'package:neon/src/bloc/result_builder.dart'; import 'package:neon/src/blocs/accounts.dart'; import 'package:neon/src/models/account.dart'; import 'package:neon/src/widgets/cached_image.dart'; +import 'package:neon/src/widgets/server_icon.dart'; import 'package:nextcloud/nextcloud.dart'; import 'package:provider/provider.dart'; import 'package:rxdart/rxdart.dart'; @@ -96,10 +97,9 @@ class _UserAvatarState extends State { Widget _userStatusIconBuilder(final BuildContext context, final Result result) { final hasEmoji = result.data?.icon != null; - final scaledSize = size / (hasEmoji ? 2 : 3); + final scaledSize = size / (hasEmoji ? 2 : 2.5); Widget? child; - Decoration? decoration; if (result.isLoading) { child = CircularProgressIndicator( strokeWidth: 1.5, @@ -119,20 +119,16 @@ class _UserAvatarState extends State { ), ); } else if (result.hasData) { - decoration = BoxDecoration( - shape: BoxShape.circle, - color: result.data!.color, - ); + child = NeonServerIcon(icon: 'user-status-${result.data!.status}'); } return SizedBox.square( dimension: size, child: Align( alignment: Alignment.bottomRight, - child: Container( + child: SizedBox( width: scaledSize, height: scaledSize, - decoration: decoration, child: child, ), ),