#94 paint color background during thumbnail hero
This commit is contained in:
parent
e3f5e1aaff
commit
51c92fe6ed
2 changed files with 11 additions and 1 deletions
|
@ -13,6 +13,7 @@ class TransitionImage extends StatefulWidget {
|
||||||
final double? width, height;
|
final double? width, height;
|
||||||
final ValueListenable<double> animation;
|
final ValueListenable<double> animation;
|
||||||
final bool gaplessPlayback = false;
|
final bool gaplessPlayback = false;
|
||||||
|
final Color? background;
|
||||||
|
|
||||||
const TransitionImage({
|
const TransitionImage({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
@ -20,6 +21,7 @@ class TransitionImage extends StatefulWidget {
|
||||||
required this.animation,
|
required this.animation,
|
||||||
this.width,
|
this.width,
|
||||||
this.height,
|
this.height,
|
||||||
|
this.background,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -136,10 +138,10 @@ class _TransitionImageState extends State<TransitionImage> {
|
||||||
valueListenable: widget.animation,
|
valueListenable: widget.animation,
|
||||||
builder: (context, t, child) => CustomPaint(
|
builder: (context, t, child) => CustomPaint(
|
||||||
painter: _TransitionImagePainter(
|
painter: _TransitionImagePainter(
|
||||||
// AssetImage(name).resolve(configuration)
|
|
||||||
image: _imageInfo?.image,
|
image: _imageInfo?.image,
|
||||||
scale: _imageInfo?.scale ?? 1.0,
|
scale: _imageInfo?.scale ?? 1.0,
|
||||||
t: t,
|
t: t,
|
||||||
|
background: widget.background,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -150,11 +152,13 @@ class _TransitionImagePainter extends CustomPainter {
|
||||||
final ui.Image? image;
|
final ui.Image? image;
|
||||||
final double scale;
|
final double scale;
|
||||||
final double t;
|
final double t;
|
||||||
|
final Color? background;
|
||||||
|
|
||||||
const _TransitionImagePainter({
|
const _TransitionImagePainter({
|
||||||
required this.image,
|
required this.image,
|
||||||
required this.scale,
|
required this.scale,
|
||||||
required this.t,
|
required this.t,
|
||||||
|
this.background,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -185,6 +189,9 @@ class _TransitionImagePainter extends CustomPainter {
|
||||||
sourceSize,
|
sourceSize,
|
||||||
Offset.zero & inputSize,
|
Offset.zero & inputSize,
|
||||||
);
|
);
|
||||||
|
if (background != null) {
|
||||||
|
canvas.drawRect(destinationRect, Paint()..color = background!);
|
||||||
|
}
|
||||||
canvas.drawImageRect(image!, sourceRect, destinationRect, paint);
|
canvas.drawImageRect(image!, sourceRect, destinationRect, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,12 +232,15 @@ class _ThumbnailImageState extends State<ThumbnailImage> {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (animate && widget.heroTag != null) {
|
if (animate && widget.heroTag != null) {
|
||||||
|
final background = settings.imageBackground;
|
||||||
|
final backgroundColor = background.isColor? background.color : null;
|
||||||
image = Hero(
|
image = Hero(
|
||||||
tag: widget.heroTag!,
|
tag: widget.heroTag!,
|
||||||
flightShuttleBuilder: (flight, animation, direction, fromHero, toHero) {
|
flightShuttleBuilder: (flight, animation, direction, fromHero, toHero) {
|
||||||
return TransitionImage(
|
return TransitionImage(
|
||||||
image: entry.bestCachedThumbnail,
|
image: entry.bestCachedThumbnail,
|
||||||
animation: animation,
|
animation: animation,
|
||||||
|
background: backgroundColor,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
transitionOnUserGestures: true,
|
transitionOnUserGestures: true,
|
||||||
|
|
Loading…
Reference in a new issue