From d638f7e180bcf4d85a69ce9ec13eab5d8a27c768 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sun, 1 Oct 2023 12:57:18 +0200 Subject: [PATCH] fix(neon): Fix server icon explicit null color Signed-off-by: jld3103 --- .../neon/neon/lib/src/widgets/server_icon.dart | 17 +++++------------ .../lib/src/widgets/unified_search_results.dart | 2 +- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/packages/neon/neon/lib/src/widgets/server_icon.dart b/packages/neon/neon/lib/src/widgets/server_icon.dart index b1b039f0..b8705306 100644 --- a/packages/neon/neon/lib/src/widgets/server_icon.dart +++ b/packages/neon/neon/lib/src/widgets/server_icon.dart @@ -8,7 +8,7 @@ class NeonServerIcon extends StatelessWidget { /// Creates a new server icon const NeonServerIcon({ required this.icon, - this.color, + this.colorFilter, this.size, super.key, }); @@ -16,13 +16,7 @@ class NeonServerIcon extends StatelessWidget { /// Name of the server icon to draw. final String icon; - /// The color to use when drawing the icon. - /// - /// Defaults to the nearest [IconTheme]'s [IconThemeData.color]. - /// - /// The color (whether specified explicitly here or obtained from the - /// [IconTheme]) will be further adjusted by the nearest [IconTheme]'s - /// [IconThemeData.opacity]. + /// The color filter to use when drawing the icon. /// /// {@tool snippet} /// Typically, a Material Design color will be used, as follows: @@ -30,11 +24,11 @@ class NeonServerIcon extends StatelessWidget { /// ```dart /// NeonServerIcon( /// icon: 'icon-add', - /// color: Colors.blue.shade400, + /// colorFilter: ColorFilter.mode(Colors.blue.shade400, BlendMode.srcIn), /// ) /// ``` /// {@end-tool} - final Color? color; + final ColorFilter? colorFilter; /// The size of the icon in logical pixels. /// @@ -53,12 +47,11 @@ class NeonServerIcon extends StatelessWidget { final iconTheme = Theme.of(context).iconTheme; final size = this.size ?? iconTheme.size; - final color = this.color ?? iconTheme.color; return VectorGraphic( width: size, height: size, - colorFilter: color != null ? ColorFilter.mode(color, BlendMode.srcIn) : null, + colorFilter: colorFilter, loader: AssetBytesLoader( 'assets/icons/server/${icon.replaceFirst(RegExp('^icon-'), '').replaceFirst(RegExp(r'-(dark|white)$'), '')}.svg.vec', packageName: 'neon', diff --git a/packages/neon/neon/lib/src/widgets/unified_search_results.dart b/packages/neon/neon/lib/src/widgets/unified_search_results.dart index 0a0b70a3..06d8d3fd 100644 --- a/packages/neon/neon/lib/src/widgets/unified_search_results.dart +++ b/packages/neon/neon/lib/src/widgets/unified_search_results.dart @@ -137,7 +137,7 @@ class NeonUnifiedSearchResults extends StatelessWidget { if (entry.icon.startsWith('icon-')) { return NeonServerIcon( - color: Theme.of(context).colorScheme.primary, + colorFilter: ColorFilter.mode(Theme.of(context).colorScheme.primary, BlendMode.srcIn), icon: entry.icon, ); }