Browse Source

fix(neon): Fix cached image SVG color

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/912/head
jld3103 1 year ago
parent
commit
042dcd6b27
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 30
      packages/neon/neon/lib/src/widgets/image.dart
  2. 1
      packages/neon/neon_news/lib/widgets/feed_icon.dart
  3. 2
      packages/neon/neon_notifications/lib/pages/main.dart

30
packages/neon/neon/lib/src/widgets/image.dart

@ -45,7 +45,7 @@ class NeonCachedImage extends StatefulWidget {
this.isSvgHint = false, this.isSvgHint = false,
this.size, this.size,
this.fit, this.fit,
this.iconColor, this.svgColorFilter,
this.errorBuilder, this.errorBuilder,
}) : image = Future.value(image); }) : image = Future.value(image);
@ -59,7 +59,7 @@ class NeonCachedImage extends StatefulWidget {
this.isSvgHint = false, this.isSvgHint = false,
this.size, this.size,
this.fit, this.fit,
this.iconColor, this.svgColorFilter,
this.errorBuilder, this.errorBuilder,
}) : image = _getImageFromUrl(url, account), }) : image = _getImageFromUrl(url, account),
super(key: key ?? Key(url)); super(key: key ?? Key(url));
@ -76,7 +76,7 @@ class NeonCachedImage extends StatefulWidget {
this.isSvgHint = false, this.isSvgHint = false,
this.size, this.size,
this.fit, this.fit,
this.iconColor, this.svgColorFilter,
this.errorBuilder, this.errorBuilder,
}) : image = _customImageGetter( }) : image = _customImageGetter(
reviver, reviver,
@ -104,12 +104,10 @@ class NeonCachedImage extends StatefulWidget {
/// {@endtemplate} /// {@endtemplate}
final BoxFit? fit; final BoxFit? fit;
/// {@template NeonCachedImage.iconColor} /// {@template NeonCachedImage.svgColorFilter}
/// The color to use when drawing the image. /// The color filter to use when drawing SVGs.
///
/// Applies to SVG images only and the loading animation.
/// {@endtemplate} /// {@endtemplate}
final Color? iconColor; final ColorFilter? svgColorFilter;
/// {@template NeonCachedImage.errorBuilder} /// {@template NeonCachedImage.errorBuilder}
/// Builder function building the error widget. /// Builder function building the error widget.
@ -189,9 +187,7 @@ class _NeonCachedImageState extends State<NeonCachedImage> {
if (!fileSnapshot.hasData) { if (!fileSnapshot.hasData) {
return SizedBox( return SizedBox(
width: widget.size?.width, width: widget.size?.width,
child: NeonLinearProgressIndicator( child: const NeonLinearProgressIndicator(),
color: widget.iconColor,
),
); );
} }
@ -205,7 +201,7 @@ class _NeonCachedImageState extends State<NeonCachedImage> {
height: widget.size?.height, height: widget.size?.height,
width: widget.size?.width, width: widget.size?.width,
fit: widget.fit ?? BoxFit.contain, fit: widget.fit ?? BoxFit.contain,
colorFilter: widget.iconColor != null ? ColorFilter.mode(widget.iconColor!, BlendMode.srcIn) : null, colorFilter: widget.svgColorFilter,
); );
} }
} catch (_) { } catch (_) {
@ -256,7 +252,7 @@ class NeonApiImage extends StatelessWidget {
this.isSvgHint = false, this.isSvgHint = false,
this.size, this.size,
this.fit, this.fit,
this.iconColor, this.svgColorFilter,
this.errorBuilder, this.errorBuilder,
super.key, super.key,
}) : account = null; }) : account = null;
@ -273,7 +269,7 @@ class NeonApiImage extends StatelessWidget {
this.isSvgHint = false, this.isSvgHint = false,
this.size, this.size,
this.fit, this.fit,
this.iconColor, this.svgColorFilter,
this.errorBuilder, this.errorBuilder,
super.key, super.key,
}); });
@ -305,8 +301,8 @@ class NeonApiImage extends StatelessWidget {
/// {@macro NeonCachedImage.fit} /// {@macro NeonCachedImage.fit}
final BoxFit? fit; final BoxFit? fit;
/// {@macro NeonCachedImage.iconColor} /// {@macro NeonCachedImage.svgColorFilter}
final Color? iconColor; final ColorFilter? svgColorFilter;
/// {@macro NeonCachedImage.errorBuilder} /// {@macro NeonCachedImage.errorBuilder}
final ErrorWidgetBuilder? errorBuilder; final ErrorWidgetBuilder? errorBuilder;
@ -326,7 +322,7 @@ class NeonApiImage extends StatelessWidget {
isSvgHint: isSvgHint, isSvgHint: isSvgHint,
size: size, size: size,
fit: fit, fit: fit,
iconColor: iconColor, svgColorFilter: svgColorFilter,
errorBuilder: errorBuilder, errorBuilder: errorBuilder,
); );
} }

1
packages/neon/neon_news/lib/widgets/feed_icon.dart

@ -23,7 +23,6 @@ class NewsFeedIcon extends StatelessWidget {
? NeonCachedImage.url( ? NeonCachedImage.url(
url: faviconLink, url: faviconLink,
size: Size.square(size), size: Size.square(size),
iconColor: Theme.of(context).colorScheme.primary,
) )
: Icon( : Icon(
Icons.rss_feed, Icons.rss_feed,

2
packages/neon/neon_notifications/lib/pages/main.dart

@ -84,7 +84,7 @@ class _NotificationsMainPageState extends State<NotificationsMainPage> {
child: NeonCachedImage.url( child: NeonCachedImage.url(
url: notification.icon!, url: notification.icon!,
size: const Size.square(largeIconSize), size: const Size.square(largeIconSize),
iconColor: Theme.of(context).colorScheme.primary, svgColorFilter: ColorFilter.mode(Theme.of(context).colorScheme.primary, BlendMode.srcIn),
), ),
), ),
onTap: () async { onTap: () async {

Loading…
Cancel
Save