#755 mosaic layout: clamp ratio to 32/9
This commit is contained in:
parent
ef68ee49b9
commit
541d26ca16
4 changed files with 33 additions and 12 deletions
|
@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## <a id="unreleased"></a>[Unreleased]
|
## <a id="unreleased"></a>[Unreleased]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- mosaic layout: clamp ratio to 32/9
|
||||||
|
|
||||||
## <a id="v1.9.6"></a>[v1.9.6] - 2023-09-25
|
## <a id="v1.9.6"></a>[v1.9.6] - 2023-09-25
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -19,7 +19,9 @@ class MosaicSectionLayoutBuilder<T> extends SectionLayoutBuilder<T> {
|
||||||
late double rowHeightMax;
|
late double rowHeightMax;
|
||||||
final CoverRatioResolver<T> coverRatioResolver;
|
final CoverRatioResolver<T> coverRatioResolver;
|
||||||
|
|
||||||
static const heightMaxFactor = 2.4;
|
static const double heightMaxFactor = 2.4;
|
||||||
|
static const double minThumbnailAspectRatio = 9 / 32;
|
||||||
|
static const double maxThumbnailAspectRatio = 32 / 9;
|
||||||
|
|
||||||
MosaicSectionLayoutBuilder({
|
MosaicSectionLayoutBuilder({
|
||||||
required super.sections,
|
required super.sections,
|
||||||
|
@ -76,7 +78,7 @@ class MosaicSectionLayoutBuilder<T> extends SectionLayoutBuilder<T> {
|
||||||
targetExtent: tileWidth,
|
targetExtent: tileWidth,
|
||||||
spacing: spacing,
|
spacing: spacing,
|
||||||
bottom: bottom,
|
bottom: bottom,
|
||||||
coverRatioResolver: coverRatioResolver,
|
coverRatioResolver: (item) => coverRatioResolver(item).clamp(minThumbnailAspectRatio, maxThumbnailAspectRatio),
|
||||||
);
|
);
|
||||||
final rowCount = rows.length;
|
final rowCount = rows.length;
|
||||||
final sectionChildCount = 1 + rowCount;
|
final sectionChildCount = 1 + rowCount;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:aves/model/entry/entry.dart';
|
import 'package:aves/model/entry/entry.dart';
|
||||||
import 'package:aves/widgets/common/fx/borders.dart';
|
import 'package:aves/widgets/common/fx/borders.dart';
|
||||||
import 'package:aves/widgets/common/grid/overlay.dart';
|
import 'package:aves/widgets/common/grid/overlay.dart';
|
||||||
|
import 'package:aves/widgets/common/grid/sections/mosaic/section_layout_builder.dart';
|
||||||
import 'package:aves/widgets/common/thumbnail/image.dart';
|
import 'package:aves/widgets/common/thumbnail/image.dart';
|
||||||
import 'package:aves/widgets/common/thumbnail/notifications.dart';
|
import 'package:aves/widgets/common/thumbnail/notifications.dart';
|
||||||
import 'package:aves/widgets/common/thumbnail/overlay.dart';
|
import 'package:aves/widgets/common/thumbnail/overlay.dart';
|
||||||
|
@ -30,8 +31,17 @@ class DecoratedThumbnail extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final thumbnailWidth = isMosaic ? tileExtent * entry.displayAspectRatio : tileExtent;
|
final double thumbnailHeight = tileExtent;
|
||||||
final thumbnailHeight = tileExtent;
|
final double thumbnailWidth;
|
||||||
|
if (isMosaic) {
|
||||||
|
thumbnailWidth = thumbnailHeight *
|
||||||
|
entry.displayAspectRatio.clamp(
|
||||||
|
MosaicSectionLayoutBuilder.minThumbnailAspectRatio,
|
||||||
|
MosaicSectionLayoutBuilder.maxThumbnailAspectRatio,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
thumbnailWidth = tileExtent;
|
||||||
|
}
|
||||||
|
|
||||||
Widget child = ThumbnailImage(
|
Widget child = ThumbnailImage(
|
||||||
entry: entry,
|
entry: entry,
|
||||||
|
|
|
@ -11,6 +11,7 @@ import 'package:aves/services/common/services.dart';
|
||||||
import 'package:aves/widgets/common/basic/insets.dart';
|
import 'package:aves/widgets/common/basic/insets.dart';
|
||||||
import 'package:aves/widgets/common/fx/checkered_decoration.dart';
|
import 'package:aves/widgets/common/fx/checkered_decoration.dart';
|
||||||
import 'package:aves/widgets/common/fx/transition_image.dart';
|
import 'package:aves/widgets/common/fx/transition_image.dart';
|
||||||
|
import 'package:aves/widgets/common/grid/sections/mosaic/section_layout_builder.dart';
|
||||||
import 'package:aves/widgets/common/providers/media_query_data_provider.dart';
|
import 'package:aves/widgets/common/providers/media_query_data_provider.dart';
|
||||||
import 'package:aves/widgets/common/thumbnail/error.dart';
|
import 'package:aves/widgets/common/thumbnail/error.dart';
|
||||||
import 'package:aves_model/aves_model.dart';
|
import 'package:aves_model/aves_model.dart';
|
||||||
|
@ -197,16 +198,20 @@ class _ThumbnailImageState extends State<ThumbnailImage> {
|
||||||
// use `RawImage` instead of `Image`, using `ImageInfo` to check dimensions
|
// use `RawImage` instead of `Image`, using `ImageInfo` to check dimensions
|
||||||
// and have more control when chaining image providers
|
// and have more control when chaining image providers
|
||||||
|
|
||||||
final thumbnailWidth = isMosaic ? extent * entry.displayAspectRatio : extent;
|
|
||||||
final thumbnailHeight = extent;
|
final thumbnailHeight = extent;
|
||||||
|
final double thumbnailWidth;
|
||||||
|
if (isMosaic) {
|
||||||
|
thumbnailWidth = thumbnailHeight *
|
||||||
|
entry.displayAspectRatio.clamp(
|
||||||
|
MosaicSectionLayoutBuilder.minThumbnailAspectRatio,
|
||||||
|
MosaicSectionLayoutBuilder.maxThumbnailAspectRatio,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
thumbnailWidth = extent;
|
||||||
|
}
|
||||||
final canHaveAlpha = entry.canHaveAlpha;
|
final canHaveAlpha = entry.canHaveAlpha;
|
||||||
|
|
||||||
final fit = widget.fit ??
|
final fit = widget.fit ?? (entry.isSvg ? BoxFit.contain : BoxFit.cover);
|
||||||
(entry.isSvg
|
|
||||||
? BoxFit.contain
|
|
||||||
: isMosaic
|
|
||||||
? BoxFit.contain
|
|
||||||
: BoxFit.cover);
|
|
||||||
final imageInfo = _lastImageInfo;
|
final imageInfo = _lastImageInfo;
|
||||||
Widget image = imageInfo == null
|
Widget image = imageInfo == null
|
||||||
? Container(
|
? Container(
|
||||||
|
@ -266,7 +271,7 @@ class _ThumbnailImageState extends State<ThumbnailImage> {
|
||||||
Widget child = TransitionImage(
|
Widget child = TransitionImage(
|
||||||
image: entry.bestCachedThumbnail,
|
image: entry.bestCachedThumbnail,
|
||||||
animation: animation,
|
animation: animation,
|
||||||
thumbnailFit: isMosaic ? BoxFit.contain : BoxFit.cover,
|
thumbnailFit: BoxFit.cover,
|
||||||
viewerFit: BoxFit.contain,
|
viewerFit: BoxFit.contain,
|
||||||
background: backgroundColor,
|
background: backgroundColor,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue