mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
Improve thumbnail
This commit is contained in:
@@ -277,35 +277,38 @@ class _AnimatedImageState extends State<AnimatedImage>
|
|||||||
|
|
||||||
if (_imageInfo != null) {
|
if (_imageInfo != null) {
|
||||||
if (widget.part != null) {
|
if (widget.part != null) {
|
||||||
return CustomPaint(
|
result = CustomPaint(
|
||||||
|
isComplex: true,
|
||||||
painter: ImagePainter(
|
painter: ImagePainter(
|
||||||
image: _imageInfo!.image,
|
image: _imageInfo!.image,
|
||||||
part: widget.part!,
|
part: widget.part!,
|
||||||
|
fit: widget.fit ?? BoxFit.cover,
|
||||||
),
|
),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: widget.width,
|
width: widget.width,
|
||||||
height: widget.height,
|
height: widget.height,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
result = RawImage(
|
||||||
|
image: _imageInfo?.image,
|
||||||
|
width: widget.width,
|
||||||
|
height: widget.height,
|
||||||
|
debugImageLabel: _imageInfo?.debugLabel,
|
||||||
|
scale: _imageInfo?.scale ?? 1.0,
|
||||||
|
color: widget.color,
|
||||||
|
opacity: widget.opacity,
|
||||||
|
colorBlendMode: widget.colorBlendMode,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
alignment: widget.alignment,
|
||||||
|
repeat: widget.repeat,
|
||||||
|
centerSlice: widget.centerSlice,
|
||||||
|
matchTextDirection: widget.matchTextDirection,
|
||||||
|
invertColors: _invertColors,
|
||||||
|
isAntiAlias: widget.isAntiAlias,
|
||||||
|
filterQuality: widget.filterQuality,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
result = RawImage(
|
|
||||||
image: _imageInfo?.image,
|
|
||||||
width: widget.width,
|
|
||||||
height: widget.height,
|
|
||||||
debugImageLabel: _imageInfo?.debugLabel,
|
|
||||||
scale: _imageInfo?.scale ?? 1.0,
|
|
||||||
color: widget.color,
|
|
||||||
opacity: widget.opacity,
|
|
||||||
colorBlendMode: widget.colorBlendMode,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
alignment: widget.alignment,
|
|
||||||
repeat: widget.repeat,
|
|
||||||
centerSlice: widget.centerSlice,
|
|
||||||
matchTextDirection: widget.matchTextDirection,
|
|
||||||
invertColors: _invertColors,
|
|
||||||
isAntiAlias: widget.isAntiAlias,
|
|
||||||
filterQuality: widget.filterQuality,
|
|
||||||
);
|
|
||||||
} else if (_lastException != null) {
|
} else if (_lastException != null) {
|
||||||
result = const Center(
|
result = const Center(
|
||||||
child: Icon(Icons.error),
|
child: Icon(Icons.error),
|
||||||
@@ -362,10 +365,13 @@ class ImagePainter extends CustomPainter {
|
|||||||
|
|
||||||
final ImagePart part;
|
final ImagePart part;
|
||||||
|
|
||||||
|
final BoxFit fit;
|
||||||
|
|
||||||
/// Render a part of the image.
|
/// Render a part of the image.
|
||||||
const ImagePainter({
|
const ImagePainter({
|
||||||
required this.image,
|
required this.image,
|
||||||
this.part = const ImagePart(),
|
this.part = const ImagePart(),
|
||||||
|
this.fit = BoxFit.cover,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -377,7 +383,8 @@ class ImagePainter extends CustomPainter {
|
|||||||
part.y2 ?? image.height.toDouble(),
|
part.y2 ?? image.height.toDouble(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
final Rect dst = Offset.zero & size;
|
var fitted = applyBoxFit(fit, Size(src.width, src.height), size).destination;
|
||||||
|
var dst = Alignment.center.inscribe(fitted, Offset.zero & size);
|
||||||
canvas.drawImageRect(image, src, dst, Paint());
|
canvas.drawImageRect(image, src, dst, Paint());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1283,7 +1283,9 @@ class _ComicThumbnailsState extends State<_ComicThumbnails> {
|
|||||||
y2 = double.parse(r.split('-')[1]);
|
y2 = double.parse(r.split('-')[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {}
|
} catch (_) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
part = ImagePart(x1: x1, y1: y1, x2: x2, y2: y2);
|
part = ImagePart(x1: x1, y1: y1, x2: x2, y2: y2);
|
||||||
}
|
}
|
||||||
return Padding(
|
return Padding(
|
||||||
@@ -1308,19 +1310,16 @@ class _ComicThumbnailsState extends State<_ComicThumbnails> {
|
|||||||
),
|
),
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: double.infinity,
|
height: double.infinity,
|
||||||
child: ClipRRect(
|
clipBehavior: Clip.antiAlias,
|
||||||
borderRadius:
|
child: AnimatedImage(
|
||||||
const BorderRadius.all(Radius.circular(16)),
|
image: CachedImageProvider(
|
||||||
child: AnimatedImage(
|
url,
|
||||||
image: CachedImageProvider(
|
sourceKey: state.widget.sourceKey,
|
||||||
url,
|
|
||||||
sourceKey: state.widget.sourceKey,
|
|
||||||
),
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
width: double.infinity,
|
|
||||||
height: double.infinity,
|
|
||||||
part: part,
|
|
||||||
),
|
),
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
part: part,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -1336,7 +1335,7 @@ class _ComicThumbnailsState extends State<_ComicThumbnails> {
|
|||||||
),
|
),
|
||||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||||
maxCrossAxisExtent: 200,
|
maxCrossAxisExtent: 200,
|
||||||
childAspectRatio: 0.65,
|
childAspectRatio: 0.7,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (error != null)
|
if (error != null)
|
||||||
|
Reference in New Issue
Block a user