fixes for thumbnail checkered background with box fit
This commit is contained in:
parent
b14558e451
commit
5e7c85597a
2 changed files with 40 additions and 36 deletions
|
@ -43,6 +43,7 @@ class DecoratedThumbnail extends StatelessWidget {
|
||||||
);
|
);
|
||||||
|
|
||||||
child = Stack(
|
child = Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
child,
|
child,
|
||||||
Positioned(
|
Positioned(
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import 'dart:math';
|
|
||||||
|
|
||||||
import 'package:aves/image_providers/uri_picture_provider.dart';
|
import 'package:aves/image_providers/uri_picture_provider.dart';
|
||||||
import 'package:aves/model/image_entry.dart';
|
import 'package:aves/model/image_entry.dart';
|
||||||
import 'package:aves/model/settings/entry_background.dart';
|
import 'package:aves/model/settings/entry_background.dart';
|
||||||
|
@ -23,42 +21,47 @@ class ThumbnailVectorImage extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final pictureProvider = UriPicture(
|
final child = Selector<Settings, EntryBackground>(
|
||||||
uri: entry.uri,
|
selector: (context, s) => s.vectorBackground,
|
||||||
mimeType: entry.mimeType,
|
builder: (context, background, child) {
|
||||||
);
|
const fit = BoxFit.contain;
|
||||||
|
if (background == EntryBackground.checkered) {
|
||||||
final child = Center(
|
return LayoutBuilder(
|
||||||
child: Selector<Settings, EntryBackground>(
|
builder: (context, constraints) {
|
||||||
selector: (context, s) => s.vectorBackground,
|
final availableSize = constraints.biggest;
|
||||||
builder: (context, background, child) {
|
final fitSize = applyBoxFit(fit, entry.displaySize, availableSize).destination;
|
||||||
if (background == EntryBackground.transparent) {
|
final offset = fitSize / 2 - availableSize / 2;
|
||||||
return SvgPicture(
|
final child = DecoratedBox(
|
||||||
pictureProvider,
|
decoration: CheckeredDecoration(checkSize: extent / 8, offset: offset),
|
||||||
width: extent,
|
child: SvgPicture(
|
||||||
height: extent,
|
UriPicture(
|
||||||
);
|
uri: entry.uri,
|
||||||
}
|
mimeType: entry.mimeType,
|
||||||
|
),
|
||||||
final longestSide = max(entry.width, entry.height);
|
width: fitSize.width,
|
||||||
final picture = SvgPicture(
|
height: fitSize.height,
|
||||||
pictureProvider,
|
fit: fit,
|
||||||
width: extent * (entry.width / longestSide),
|
),
|
||||||
height: extent * (entry.height / longestSide),
|
);
|
||||||
|
// the thumbnail is centered for correct decoration sizing
|
||||||
|
// when constraints are tight during hero animation
|
||||||
|
return constraints.isTight ? Center(child: child) : child;
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Decoration decoration;
|
final colorFilter = background.isColor ? ColorFilter.mode(background.color, BlendMode.dstOver) : null;
|
||||||
if (background == EntryBackground.checkered) {
|
return SvgPicture(
|
||||||
decoration = CheckeredDecoration(checkSize: extent / 8);
|
UriPicture(
|
||||||
} else if (background.isColor) {
|
uri: entry.uri,
|
||||||
decoration = BoxDecoration(color: background.color);
|
mimeType: entry.mimeType,
|
||||||
}
|
colorFilter: colorFilter,
|
||||||
return DecoratedBox(
|
),
|
||||||
decoration: decoration,
|
width: extent,
|
||||||
child: picture,
|
height: extent,
|
||||||
);
|
fit: fit,
|
||||||
},
|
);
|
||||||
),
|
},
|
||||||
);
|
);
|
||||||
return heroTag == null
|
return heroTag == null
|
||||||
? child
|
? child
|
||||||
|
|
Loading…
Reference in a new issue