Browse Source

fix(neon): Fix server icon explicit null color

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/900/head
jld3103 1 year ago
parent
commit
d638f7e180
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 17
      packages/neon/neon/lib/src/widgets/server_icon.dart
  2. 2
      packages/neon/neon/lib/src/widgets/unified_search_results.dart

17
packages/neon/neon/lib/src/widgets/server_icon.dart

@ -8,7 +8,7 @@ class NeonServerIcon extends StatelessWidget {
/// Creates a new server icon /// Creates a new server icon
const NeonServerIcon({ const NeonServerIcon({
required this.icon, required this.icon,
this.color, this.colorFilter,
this.size, this.size,
super.key, super.key,
}); });
@ -16,13 +16,7 @@ class NeonServerIcon extends StatelessWidget {
/// Name of the server icon to draw. /// Name of the server icon to draw.
final String icon; final String icon;
/// The color to use when drawing the icon. /// The color filter 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].
/// ///
/// {@tool snippet} /// {@tool snippet}
/// Typically, a Material Design color will be used, as follows: /// Typically, a Material Design color will be used, as follows:
@ -30,11 +24,11 @@ class NeonServerIcon extends StatelessWidget {
/// ```dart /// ```dart
/// NeonServerIcon( /// NeonServerIcon(
/// icon: 'icon-add', /// icon: 'icon-add',
/// color: Colors.blue.shade400, /// colorFilter: ColorFilter.mode(Colors.blue.shade400, BlendMode.srcIn),
/// ) /// )
/// ``` /// ```
/// {@end-tool} /// {@end-tool}
final Color? color; final ColorFilter? colorFilter;
/// The size of the icon in logical pixels. /// The size of the icon in logical pixels.
/// ///
@ -53,12 +47,11 @@ class NeonServerIcon extends StatelessWidget {
final iconTheme = Theme.of(context).iconTheme; final iconTheme = Theme.of(context).iconTheme;
final size = this.size ?? iconTheme.size; final size = this.size ?? iconTheme.size;
final color = this.color ?? iconTheme.color;
return VectorGraphic( return VectorGraphic(
width: size, width: size,
height: size, height: size,
colorFilter: color != null ? ColorFilter.mode(color, BlendMode.srcIn) : null, colorFilter: colorFilter,
loader: AssetBytesLoader( loader: AssetBytesLoader(
'assets/icons/server/${icon.replaceFirst(RegExp('^icon-'), '').replaceFirst(RegExp(r'-(dark|white)$'), '')}.svg.vec', 'assets/icons/server/${icon.replaceFirst(RegExp('^icon-'), '').replaceFirst(RegExp(r'-(dark|white)$'), '')}.svg.vec',
packageName: 'neon', packageName: 'neon',

2
packages/neon/neon/lib/src/widgets/unified_search_results.dart

@ -137,7 +137,7 @@ class NeonUnifiedSearchResults extends StatelessWidget {
if (entry.icon.startsWith('icon-')) { if (entry.icon.startsWith('icon-')) {
return NeonServerIcon( return NeonServerIcon(
color: Theme.of(context).colorScheme.primary, colorFilter: ColorFilter.mode(Theme.of(context).colorScheme.primary, BlendMode.srcIn),
icon: entry.icon, icon: entry.icon,
); );
} }

Loading…
Cancel
Save