From b74c599bfac94246fe5aa6b73324cb0daa292eb4 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Tue, 14 Nov 2023 17:54:13 +0100 Subject: [PATCH] feat(neon_dashboard): Support server icons as dashboard widget icons Signed-off-by: jld3103 --- .../lib/src/widgets/widget.dart | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/packages/neon/neon_dashboard/lib/src/widgets/widget.dart b/packages/neon/neon_dashboard/lib/src/widgets/widget.dart index d2559c62..5daaa639 100644 --- a/packages/neon/neon_dashboard/lib/src/widgets/widget.dart +++ b/packages/neon/neon_dashboard/lib/src/widgets/widget.dart @@ -47,11 +47,7 @@ class DashboardWidget extends StatelessWidget { ), leading: SizedBox.square( dimension: largeIconSize, - child: NeonUrlImage( - url: widget.iconUrl, - svgColorFilter: ColorFilter.mode(Theme.of(context).colorScheme.primary, BlendMode.srcIn), - size: const Size.square(largeIconSize), - ), + child: _buildWidgetIcon(context), ), ), const SizedBox( @@ -82,6 +78,32 @@ class DashboardWidget extends StatelessWidget { ); } + Widget? _buildWidgetIcon(final BuildContext context) { + final colorFilter = ColorFilter.mode(Theme.of(context).colorScheme.primary, BlendMode.srcIn); + + if (widget.iconUrl.isNotEmpty) { + return NeonUrlImage( + url: widget.iconUrl, + svgColorFilter: colorFilter, + size: const Size.square(largeIconSize), + ); + } + + if (widget.iconClass.isNotEmpty) { + return NeonServerIcon( + icon: widget.iconClass, + colorFilter: colorFilter, + size: largeIconSize, + ); + } + + return Icon( + Icons.question_mark, + color: Theme.of(context).colorScheme.primary, + size: largeIconSize, + ); + } + Widget? _renderMessage(final String? message) { if (message == null || message.isEmpty) { return null;