Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Rename gallery layout to justified

ashil-pilot1607ac73df22
diff --git a/mobile/apps/photos/lib/models/gallery/gallery_groups.dart b/mobile/apps/photos/lib/models/gallery/gallery_groups.dart
index d80ca7b2e8..f203247a17 100644
--- a/mobile/apps/photos/lib/models/gallery/gallery_groups.dart
+++ b/mobile/apps/photos/lib/models/gallery/gallery_groups.dart
@@ -9,8 +9,8 @@ import "package:photos/models/file/file.dart";
import "package:photos/models/gallery/fixed_extent_grid_row.dart";
import "package:photos/models/gallery/fixed_extent_section_layout.dart";
import "package:photos/models/gallery/gallery_layout_config.dart";
-import "package:photos/models/gallery/mosaic_grid_row.dart";
-import "package:photos/models/gallery/mosaic_layout.dart";
+import "package:photos/models/gallery/justified_grid_row.dart";
+import "package:photos/models/gallery/justified_layout.dart";
import "package:photos/models/gallery/section_layout.dart";
import "package:photos/models/selected_files.dart";
import "package:photos/service_locator.dart";
@@ -31,7 +31,7 @@ class GalleryGroups {
final _logger = Logger("GalleryGroups");
final bool showGallerySettingsCTA;
final GalleryLayoutType? layoutTypeOverride;
- final bool mosaicLayoutAvailable;
+ final bool justifiedLayoutAvailable;
final bool sortOrderAsc;
final double widthAvailable;
@@ -48,7 +48,7 @@ class GalleryGroups {
this.limitSelectionToOne = false,
this.showGallerySettingsCTA = false,
this.layoutTypeOverride,
- required this.mosaicLayoutAvailable,
+ required this.justifiedLayoutAvailable,
}) {
init();
if (!groupType.showGroupHeader()) {
@@ -130,7 +130,7 @@ class GalleryGroups {
final rowIndex = childIndex - section.bodyFirstIndex;
final fileIndex = switch (section) {
FixedExtentSectionLayout() => rowIndex * crossAxisCount,
- MosaicSectionLayout() => section.rows[rowIndex].firstIndex,
+ JustifiedSectionLayout() => section.rows[rowIndex].firstIndex,
_ => 0,
};
return files[fileIndex.clamp(0, files.length - 1)];
@@ -152,9 +152,9 @@ class GalleryGroups {
(fileIndex ~/ crossAxisCount) * section.mainAxisStride,
rowExtent: section.tileHeight,
),
- MosaicSectionLayout() => () {
+ JustifiedSectionLayout() => () {
final row =
- section.rows[_mosaicRowIndexForFile(section.rows, fileIndex)];
+ section.rows[_justifiedRowIndexForFile(section.rows, fileIndex)];
return (
headerExtent: section.headerExtent,
rowOffset: section.bodyMinOffset + row.minOffset,
@@ -198,7 +198,7 @@ class GalleryGroups {
return generatedIDLocation ?? uploadedFileIDLocation ?? localIDLocation;
}
- int _mosaicRowIndexForFile(List<MosaicRowLayout> rows, int fileIndex) {
+ int _justifiedRowIndexForFile(List<JustifiedRowLayout> rows, int fileIndex) {
var low = 0;
var high = rows.length - 1;
while (low <= high) {
@@ -265,13 +265,13 @@ class GalleryGroups {
crossAxisCount = localSettings.getPhotoGridSize();
layoutType = resolveGalleryLayoutType(
layoutTypeOverride ?? localSettings.getGalleryLayoutType(),
- mosaicLayoutAvailable: mosaicLayoutAvailable,
+ justifiedLayoutAvailable: justifiedLayoutAvailable,
);
_buildGroups();
_groupLayouts = switch (layoutType) {
GalleryLayoutType.grid => _computeFixedGroupLayouts(),
- GalleryLayoutType.mosaic => _computeMosaicGroupLayouts(),
+ GalleryLayoutType.justified => _computeJustifiedGroupLayouts(),
};
assert(groupIDs.length == _groupIdToFilesMap.length);
@@ -438,7 +438,7 @@ class GalleryGroups {
return groupLayouts;
}
- List<SectionLayout> _computeMosaicGroupLayouts() {
+ List<SectionLayout> _computeJustifiedGroupLayouts() {
final stopwatch = Stopwatch()..start();
final targetRowHeight =
(widthAvailable - (crossAxisCount - 1) * spacing) / crossAxisCount;
@@ -448,9 +448,9 @@ class GalleryGroups {
for (final groupID in _groupIdToFilesMap.keys) {
final filesInGroup = _groupIdToFilesMap[groupID]!;
- final rows = MosaicLayoutCalculator.computeRows(
+ final rows = JustifiedLayoutCalculator.computeRows(
aspectRatios: filesInGroup.map(
- (file) => MosaicLayoutCalculator.aspectRatioForDimensions(
+ (file) => JustifiedLayoutCalculator.aspectRatioForDimensions(
file.width,
file.height,
),
@@ -466,7 +466,7 @@ class GalleryGroups {
final bodyFirstIndex = firstIndex + 1;
groupLayouts.add(
- MosaicSectionLayout(
+ JustifiedSectionLayout(
firstIndex: firstIndex,
lastIndex: lastIndex,
minOffset: minOffset,
@@ -508,7 +508,7 @@ class GalleryGroups {
);
}
- return MosaicGridRow(
+ return JustifiedGridRow(
itemWidths: row.itemWidths,
height: row.height,
spacing: spacing,
@@ -526,7 +526,7 @@ class GalleryGroups {
}
_logger.info(
- "Built mosaic group layouts in ${stopwatch.elapsedMilliseconds} ms",
+ "Built justified group layouts in ${stopwatch.elapsedMilliseconds} ms",
);
stopwatch.stop();
return groupLayouts;
@@ -543,7 +543,7 @@ class GalleryGroups {
_createNewGroup(_copyFilesInRange(start, end), yearsInGroups);
start = end;
}
- } else if (layoutType == GalleryLayoutType.mosaic) {
+ } else if (layoutType == GalleryLayoutType.justified) {
if (allFiles.isNotEmpty) {
_createNewGroup(_copyFilesInRange(0, allFiles.length), yearsInGroups);
}
diff --git a/mobile/apps/photos/lib/models/gallery/gallery_layout_config.dart b/mobile/apps/photos/lib/models/gallery/gallery_layout_config.dart
index 3950050be3..ab96a7dfa2 100644
--- a/mobile/apps/photos/lib/models/gallery/gallery_layout_config.dart
+++ b/mobile/apps/photos/lib/models/gallery/gallery_layout_config.dart
@@ -3,14 +3,14 @@ import "package:photos/settings/local_settings.dart";
// FlagService treats debug builds as internal while still honoring the
// developer setting that disables internal-user features.
-bool get isMosaicLayoutAvailable => flagService.internalUser;
+bool get isJustifiedLayoutAvailable => flagService.internalUser;
GalleryLayoutType resolveGalleryLayoutType(
GalleryLayoutType preferredLayoutType, {
- bool? mosaicLayoutAvailable,
+ bool? justifiedLayoutAvailable,
}) {
- final isAvailable = mosaicLayoutAvailable ?? isMosaicLayoutAvailable;
- if (preferredLayoutType == GalleryLayoutType.mosaic && !isAvailable) {
+ final isAvailable = justifiedLayoutAvailable ?? isJustifiedLayoutAvailable;
+ if (preferredLayoutType == GalleryLayoutType.justified && !isAvailable) {
return GalleryLayoutType.grid;
}
return preferredLayoutType;
diff --git a/mobile/apps/photos/lib/models/gallery/mosaic_grid_row.dart b/mobile/apps/photos/lib/models/gallery/justified_grid_row.dart
similarity index 84%
rename from mobile/apps/photos/lib/models/gallery/mosaic_grid_row.dart
rename to mobile/apps/photos/lib/models/gallery/justified_grid_row.dart
index 8c9615ee32..1e1a285063 100644
--- a/mobile/apps/photos/lib/models/gallery/mosaic_grid_row.dart
+++ b/mobile/apps/photos/lib/models/gallery/justified_grid_row.dart
@@ -2,13 +2,13 @@ import "package:flutter/foundation.dart";
import "package:flutter/material.dart";
import "package:flutter/rendering.dart";
-class MosaicGridRow extends MultiChildRenderObjectWidget {
+class JustifiedGridRow extends MultiChildRenderObjectWidget {
final List<double> itemWidths;
final double height;
final double spacing;
final TextDirection textDirection;
- const MosaicGridRow({
+ const JustifiedGridRow({
super.key,
required this.itemWidths,
required this.height,
@@ -19,7 +19,7 @@ class MosaicGridRow extends MultiChildRenderObjectWidget {
@override
RenderObject createRenderObject(BuildContext context) {
- return RenderMosaicGridRow(
+ return RenderJustifiedGridRow(
itemWidths: itemWidths,
height: height,
spacing: spacing,
@@ -30,7 +30,7 @@ class MosaicGridRow extends MultiChildRenderObjectWidget {
@override
void updateRenderObject(
BuildContext context,
- RenderMosaicGridRow renderObject,
+ RenderJustifiedGridRow renderObject,
) {
renderObject
..itemWidths = itemWidths
@@ -49,13 +49,16 @@ class MosaicGridRow extends MultiChildRenderObjectWidget {
}
}
-class _MosaicGridRowParentData extends ContainerBoxParentData<RenderBox> {}
+class _JustifiedGridRowParentData extends ContainerBoxParentData<RenderBox> {}
-class RenderMosaicGridRow extends RenderBox
+class RenderJustifiedGridRow extends RenderBox
with
- ContainerRenderObjectMixin<RenderBox, _MosaicGridRowParentData>,
- RenderBoxContainerDefaultsMixin<RenderBox, _MosaicGridRowParentData> {
- RenderMosaicGridRow({
+ ContainerRenderObjectMixin<RenderBox, _JustifiedGridRowParentData>,
+ RenderBoxContainerDefaultsMixin<
+ RenderBox,
+ _JustifiedGridRowParentData
+ > {
+ RenderJustifiedGridRow({
List<RenderBox>? children,
required List<double> itemWidths,
required double height,
@@ -106,8 +109,8 @@ class RenderMosaicGridRow extends RenderBox
@override
void setupParentData(RenderBox child) {
- if (child.parentData is! _MosaicGridRowParentData) {
- child.parentData = _MosaicGridRowParentData();
+ if (child.parentData is! _JustifiedGridRowParentData) {
+ child.parentData = _JustifiedGridRowParentData();
}
}
@@ -131,7 +134,7 @@ class RenderMosaicGridRow extends RenderBox
void performLayout() {
assert(
childCount == itemWidths.length,
- "Each mosaic child must have one precomputed width",
+ "Each justified child must have one precomputed width",
);
final rowWidth = constraints.hasBoundedWidth
? constraints.maxWidth
@@ -148,7 +151,7 @@ class RenderMosaicGridRow extends RenderBox
BoxConstraints.tight(Size(childWidth, size.height)),
parentUsesSize: false,
);
- final childParentData = child.parentData! as _MosaicGridRowParentData;
+ final childParentData = child.parentData! as _JustifiedGridRowParentData;
if (flipMainAxis) offsetX -= childWidth;
childParentData.offset = Offset(offsetX, 0);
offsetX += flipMainAxis ? -(spacing) : childWidth + spacing;
diff --git a/mobile/apps/photos/lib/models/gallery/mosaic_layout.dart b/mobile/apps/photos/lib/models/gallery/justified_layout.dart
similarity index 94%
rename from mobile/apps/photos/lib/models/gallery/mosaic_layout.dart
rename to mobile/apps/photos/lib/models/gallery/justified_layout.dart
index 4b41bbdb17..7050ad50d9 100644
--- a/mobile/apps/photos/lib/models/gallery/mosaic_layout.dart
+++ b/mobile/apps/photos/lib/models/gallery/justified_layout.dart
@@ -3,14 +3,14 @@ import "dart:math" as math;
import "package:photos/models/gallery/section_layout.dart";
-class MosaicRowLayout {
+class JustifiedRowLayout {
final int firstIndex;
final int lastIndex;
final double minOffset;
final double height;
final List<double> itemWidths;
- const MosaicRowLayout({
+ const JustifiedRowLayout({
required this.firstIndex,
required this.lastIndex,
required this.minOffset,
@@ -21,10 +21,10 @@ class MosaicRowLayout {
double get maxOffset => minOffset + height;
}
-class MosaicSectionLayout extends SectionLayout {
- final List<MosaicRowLayout> rows;
+class JustifiedSectionLayout extends SectionLayout {
+ final List<JustifiedRowLayout> rows;
- const MosaicSectionLayout({
+ const JustifiedSectionLayout({
required super.firstIndex,
required super.lastIndex,
required super.minOffset,
@@ -92,14 +92,14 @@ class MosaicSectionLayout extends SectionLayout {
}
}
-class MosaicLayoutCalculator {
+class JustifiedLayoutCalculator {
static const double _minimumAspectRatio = 1 / 3;
static const double _maximumAspectRatio = 4.0;
static const double _maximumRowHeightFactor = 2.4;
// Logical pixels map to density-independent tap extents on both platforms.
static const double _minimumTappableExtent = 48.0;
- const MosaicLayoutCalculator._();
+ const JustifiedLayoutCalculator._();
static double aspectRatioForDimensions(int width, int height) {
if (width <= 0 || height <= 0) return 1;
@@ -108,7 +108,7 @@ class MosaicLayoutCalculator {
.toDouble();
}
- static List<MosaicRowLayout> computeRows({
+ static List<JustifiedRowLayout> computeRows({
required Iterable<double> aspectRatios,
required double availableWidth,
required double targetRowHeight,
@@ -125,7 +125,7 @@ class MosaicLayoutCalculator {
throw ArgumentError.value(spacing, "spacing");
}
- final rows = <MosaicRowLayout>[];
+ final rows = <JustifiedRowLayout>[];
final pendingRatios = <double>[];
final maximumRowHeight = targetRowHeight * _maximumRowHeightFactor;
var pendingRatioSum = 0.0;
@@ -162,7 +162,7 @@ class MosaicLayoutCalculator {
}
rows.add(
- MosaicRowLayout(
+ JustifiedRowLayout(
firstIndex: pendingFirstIndex,
lastIndex: pendingFirstIndex + pendingRatios.length - 1,
minOffset: rowOffset,
diff --git a/mobile/apps/photos/lib/settings/local_settings.dart b/mobile/apps/photos/lib/settings/local_settings.dart
index 647c7f8d86..5798fc64aa 100644
--- a/mobile/apps/photos/lib/settings/local_settings.dart
+++ b/mobile/apps/photos/lib/settings/local_settings.dart
@@ -14,7 +14,7 @@ enum AlbumSortDirection { ascending, descending }
enum AlbumViewType { grid, list }
-enum GalleryLayoutType { grid, mosaic }
+enum GalleryLayoutType { grid, justified }
enum PeopleSortKey { mostPhotos, name, lastUpdated }
@@ -267,7 +267,7 @@ class LocalSettings {
GalleryLayoutType getGalleryLayoutType() {
return switch (_prefs.getString(kGalleryLayoutType)) {
- "mosaic" => GalleryLayoutType.mosaic,
+ "justified" => GalleryLayoutType.justified,
_ => GalleryLayoutType.grid,
};
}
diff --git a/mobile/apps/photos/lib/ui/settings/gallery_settings_screen.dart b/mobile/apps/photos/lib/ui/settings/gallery_settings_screen.dart
index 6ca11eddb0..09e1648363 100644
--- a/mobile/apps/photos/lib/ui/settings/gallery_settings_screen.dart
+++ b/mobile/apps/photos/lib/ui/settings/gallery_settings_screen.dart
@@ -43,7 +43,7 @@ class _GallerySettingsScreenState extends State<GallerySettingsScreen> {
return SettingsPageScaffold(
title: l10n.gallery,
children: [
- if (isMosaicLayoutAvailable) ...[
+ if (isJustifiedLayoutAvailable) ...[
SettingsItem(
title: l10n.layout,
trailing: _trailingLabel(
@@ -104,12 +104,12 @@ class _GallerySettingsScreenState extends State<GallerySettingsScreen> {
String _layoutTypeLabel(BuildContext context, GalleryLayoutType layoutType) {
return switch (layoutType) {
GalleryLayoutType.grid => context.strings.grid,
- GalleryLayoutType.mosaic => context.strings.layoutMasonry,
+ GalleryLayoutType.justified => context.strings.layoutJustified,
};
}
Future<void> _showLayoutTypeSheet(BuildContext context) async {
- if (!isMosaicLayoutAvailable) return;
+ if (!isJustifiedLayoutAvailable) return;
final l10n = context.strings;
await showBottomSheetComponent<void>(
context: context,
@@ -141,7 +141,8 @@ class _GallerySettingsScreenState extends State<GallerySettingsScreen> {
}
Future<void> _setLayoutType(GalleryLayoutType layoutType) async {
- if (layoutType == GalleryLayoutType.mosaic && !isMosaicLayoutAvailable) {
+ if (layoutType == GalleryLayoutType.justified &&
+ !isJustifiedLayoutAvailable) {
return;
}
if (localSettings.getGalleryLayoutType() == layoutType) return;
diff --git a/mobile/apps/photos/lib/ui/settings/search/settings_search_registry.dart b/mobile/apps/photos/lib/ui/settings/search/settings_search_registry.dart
index 2b5121f8aa..efdc68686a 100644
--- a/mobile/apps/photos/lib/ui/settings/search/settings_search_registry.dart
+++ b/mobile/apps/photos/lib/ui/settings/search/settings_search_registry.dart
@@ -28,7 +28,7 @@ class SettingsSearchRegistry {
final hasLoggedIn = Configuration.instance.isLoggedIn();
final isLocalGallery = isLocalGalleryMode;
final showThemeControls = Platform.isAndroid || kDebugMode;
- final showMosaicLayout = isMosaicLayoutAvailable;
+ final showJustifiedLayout = isJustifiedLayoutAvailable;
final items = <SettingsSearchItem>[];
if (hasLoggedIn && !isLocalGallery) {
@@ -321,13 +321,12 @@ class SettingsSearchRegistry {
"grid size",
"group by",
"layout",
- if (showMosaicLayout) "masonry",
- if (showMosaicLayout) "mosaic",
+ if (showJustifiedLayout) "justified",
],
),
);
- if (showMosaicLayout) {
+ if (showJustifiedLayout) {
items.add(
SettingsSearchItem(
title: l10n.layout,
@@ -337,7 +336,7 @@ class SettingsSearchRegistry {
routeBuilder: (_) =>
const GallerySettingsScreen(fromGalleryLayoutSettingsCTA: false),
isSubPage: true,
- keywords: ["layout", "grid", "masonry", "mosaic", "justified"],
+ keywords: ["layout", "grid", "justified"],
),
);
}
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/component/gallery_file_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/component/gallery_file_widget.dart
index f70dea8382..13335ac82d 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/component/gallery_file_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/component/gallery_file_widget.dart
@@ -126,7 +126,7 @@ class _GalleryFileWidgetState extends State<GalleryFileWidget> {
serverLoadDeferDuration: galleryThumbnailServerLoadDeferDuration,
shouldShowLivePhotoOverlay: true,
// Recreate the loader when the effective tier changes, such as when
- // switching between Grid and Mosaic layouts.
+ // switching between Grid and Justified layouts.
key: ValueKey((heroTag, effectiveThumbnailSize)),
thumbnailSize: effectiveThumbnailSize,
useRequestedThumbnailSizeForLocalCache: widget.thumbnailSize != null,
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
index 5bddb960af..2f5e9bc523 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
@@ -395,7 +395,7 @@ class GalleryState extends State<Gallery> {
limitSelectionToOne: widget.limitSelectionToOne,
showGallerySettingsCTA: widget.showGallerySettingsCTA,
layoutTypeOverride: widget.layoutTypeOverride,
- mosaicLayoutAvailable: isMosaicLayoutAvailable,
+ justifiedLayoutAvailable: isJustifiedLayoutAvailable,
);
galleryGroups = groups;
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/layout_settings.dart b/mobile/apps/photos/lib/ui/viewer/gallery/layout_settings.dart
index 827dd6802f..3ea59a765a 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/layout_settings.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/layout_settings.dart
@@ -22,7 +22,7 @@ class GalleryLayoutSettings extends StatefulWidget {
class _GalleryLayoutSettingsState extends State<GalleryLayoutSettings> {
late bool isDayLayout;
late bool isMonthLayout;
- late bool isMosaicLayout;
+ late bool isJustifiedLayout;
@override
void initState() {
@@ -42,7 +42,7 @@ class _GalleryLayoutSettingsState extends State<GalleryLayoutSettings> {
layoutType == GalleryLayoutType.grid &&
localSettings.getGalleryGroupType() == GroupType.month &&
localSettings.getPhotoGridSize() == 5;
- isMosaicLayout = layoutType == GalleryLayoutType.mosaic;
+ isJustifiedLayout = layoutType == GalleryLayoutType.justified;
}
void _reloadWithLatestSetting() {
@@ -77,22 +77,22 @@ class _GalleryLayoutSettingsState extends State<GalleryLayoutSettings> {
showOnlyLoadingState: true,
onTap: () => _applyLayout(GroupType.month, 5),
),
- if (isMosaicLayoutAvailable)
+ if (isJustifiedLayoutAvailable)
MenuComponent(
- title: context.strings.layoutMasonry,
+ title: context.strings.layoutJustified,
leading: const Icon(Icons.view_quilt_outlined),
- trailing: isMosaicLayout
+ trailing: isJustifiedLayout
? Icon(Icons.check, color: colors.primary)
: null,
showOnlyLoadingState: true,
- onTap: _applyMosaicLayout,
+ onTap: _applyJustifiedLayout,
),
MenuComponent(
title: context.strings.custom,
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
- if (!isDayLayout && !isMonthLayout && !isMosaicLayout) ...[
+ if (!isDayLayout && !isMonthLayout && !isJustifiedLayout) ...[
Icon(Icons.check, color: colors.primary),
const SizedBox(width: 8),
],
@@ -132,10 +132,10 @@ class _GalleryLayoutSettingsState extends State<GalleryLayoutSettings> {
Navigator.pop(context);
}
- Future<void> _applyMosaicLayout() async {
- if (!isMosaicLayoutAvailable) return;
- if (localSettings.getGalleryLayoutType() != GalleryLayoutType.mosaic) {
- await localSettings.setGalleryLayoutType(GalleryLayoutType.mosaic);
+ Future<void> _applyJustifiedLayout() async {
+ if (!isJustifiedLayoutAvailable) return;
+ if (localSettings.getGalleryLayoutType() != GalleryLayoutType.justified) {
+ await localSettings.setGalleryLayoutType(GalleryLayoutType.justified);
Bus.instance.fire(GalleryLayoutChangedEvent());
}
diff --git a/mobile/apps/photos/test/models/gallery_groups_mosaic_test.dart b/mobile/apps/photos/test/models/gallery_groups_justified_test.dart
similarity index 69%
rename from mobile/apps/photos/test/models/gallery_groups_mosaic_test.dart
rename to mobile/apps/photos/test/models/gallery_groups_justified_test.dart
index 8b781b6689..8725d7b3a4 100644
--- a/mobile/apps/photos/test/models/gallery_groups_mosaic_test.dart
+++ b/mobile/apps/photos/test/models/gallery_groups_justified_test.dart
@@ -9,8 +9,8 @@ import "package:photos/models/file/file.dart";
import "package:photos/models/file/file_type.dart";
import "package:photos/models/gallery/fixed_extent_section_layout.dart";
import "package:photos/models/gallery/gallery_groups.dart";
-import "package:photos/models/gallery/mosaic_grid_row.dart";
-import "package:photos/models/gallery/mosaic_layout.dart";
+import "package:photos/models/gallery/justified_grid_row.dart";
+import "package:photos/models/gallery/justified_layout.dart";
import "package:photos/models/metadata/file_magic.dart";
import "package:photos/service_locator.dart";
import "package:photos/settings/local_settings.dart";
@@ -45,11 +45,11 @@ void main() {
});
setUp(() async {
- await localSettings.setGalleryLayoutType(GalleryLayoutType.mosaic);
+ await localSettings.setGalleryLayoutType(GalleryLayoutType.justified);
await localSettings.setPhotoGridSize(4);
});
- test("day grouping creates independent, contiguous mosaic sections", () {
+ test("day grouping creates independent, contiguous justified sections", () {
for (final sortOrderAsc in [false, true]) {
final days = sortOrderAsc ? [17, 18, 19] : [19, 18, 17];
final expectedGroups = <List<EnteFile>>[];
@@ -90,22 +90,25 @@ void main() {
final groupID = groups.groupIDs[groupIndex];
final section = groups.groupLayouts[groupIndex];
- expect(section, isA<MosaicSectionLayout>());
- final mosaicSection = section as MosaicSectionLayout;
+ expect(section, isA<JustifiedSectionLayout>());
+ final justifiedSection = section as JustifiedSectionLayout;
expect(groups.groupIDToFilesMap[groupID], orderedEquals(expectedFiles));
- expect(mosaicSection.firstIndex, expectedFirstChildIndex);
- expect(mosaicSection.minOffset, closeTo(expectedSectionOffset, 1e-9));
- expect(mosaicSection.headerExtent, 48);
- _expectRowsCoverFiles(mosaicSection, expectedFiles.length);
+ expect(justifiedSection.firstIndex, expectedFirstChildIndex);
expect(
- groups.getFileAtScrollOffset(mosaicSection.minOffset),
+ justifiedSection.minOffset,
+ closeTo(expectedSectionOffset, 1e-9),
+ );
+ expect(justifiedSection.headerExtent, 48);
+ _expectRowsCoverFiles(justifiedSection, expectedFiles.length);
+ expect(
+ groups.getFileAtScrollOffset(justifiedSection.minOffset),
same(expectedFiles.first),
reason: "a shared section boundary belongs to the next section",
);
if (groupIndex > 0) {
expect(
groups.groupLayouts[groupIndex - 1].maxOffset,
- mosaicSection.minOffset,
+ justifiedSection.minOffset,
);
}
@@ -115,64 +118,67 @@ void main() {
expect(groups.getFileAtScrollOffset(fileOffset!), same(file));
expect(
groups.getOffsetOfGroupContainingFile(file),
- closeTo(mosaicSection.minOffset, 1e-9),
+ closeTo(justifiedSection.minOffset, 1e-9),
);
}
- expectedFirstChildIndex = mosaicSection.lastIndex + 1;
- expectedSectionOffset = mosaicSection.maxOffset;
+ expectedFirstChildIndex = justifiedSection.lastIndex + 1;
+ expectedSectionOffset = justifiedSection.maxOffset;
}
}
});
- test("headerless mosaic remains one continuous group past grid chunks", () {
- const fileCount = 100;
- final files = List<EnteFile>.generate(
- fileCount,
- (index) => _file(
- index: index,
- creationTime: DateTime(2026, 8, 19).microsecondsSinceEpoch,
- width: 3,
- height: 2,
- ),
- growable: false,
- );
+ test(
+ "headerless justified remains one continuous group past grid chunks",
+ () {
+ const fileCount = 100;
+ final files = List<EnteFile>.generate(
+ fileCount,
+ (index) => _file(
+ index: index,
+ creationTime: DateTime(2026, 8, 19).microsecondsSinceEpoch,
+ width: 3,
+ height: 2,
+ ),
+ growable: false,
+ );
- final groups = _galleryGroups(
- files: files,
- groupType: GroupType.none,
- groupHeaderExtent: GalleryGroups.spacing,
- );
+ final groups = _galleryGroups(
+ files: files,
+ groupType: GroupType.none,
+ groupHeaderExtent: GalleryGroups.spacing,
+ );
- expect(groups.groupIDs, hasLength(1));
- expect(groups.groupLayouts, hasLength(1));
- expect(groups.groupIDToFilesMap.values.single, orderedEquals(files));
- expect(groups.allFilesWithDummies, hasLength(fileCount));
- for (var index = 0; index < fileCount; index++) {
- expect(groups.allFilesWithDummies[index], same(files[index]));
- expect(groups.allFilesWithDummies[index], isNot(isA<DummyFile>()));
- }
+ expect(groups.groupIDs, hasLength(1));
+ expect(groups.groupLayouts, hasLength(1));
+ expect(groups.groupIDToFilesMap.values.single, orderedEquals(files));
+ expect(groups.allFilesWithDummies, hasLength(fileCount));
+ for (var index = 0; index < fileCount; index++) {
+ expect(groups.allFilesWithDummies[index], same(files[index]));
+ expect(groups.allFilesWithDummies[index], isNot(isA<DummyFile>()));
+ }
- final section = groups.groupLayouts.single as MosaicSectionLayout;
- expect(section.headerExtent, GalleryGroups.spacing);
- expect(section.bodyMinOffset, GalleryGroups.spacing);
- _expectRowsCoverFiles(section, fileCount);
+ final section = groups.groupLayouts.single as JustifiedSectionLayout;
+ expect(section.headerExtent, GalleryGroups.spacing);
+ expect(section.bodyMinOffset, GalleryGroups.spacing);
+ _expectRowsCoverFiles(section, fileCount);
- final rowAcrossLegacyBoundary = section.rows.singleWhere(
- (row) => row.firstIndex <= 39 && row.lastIndex >= 40,
- );
- expect(rowAcrossLegacyBoundary.firstIndex, 39);
- expect(rowAcrossLegacyBoundary.lastIndex, 41);
+ final rowAcrossLegacyBoundary = section.rows.singleWhere(
+ (row) => row.firstIndex <= 39 && row.lastIndex >= 40,
+ );
+ expect(rowAcrossLegacyBoundary.firstIndex, 39);
+ expect(rowAcrossLegacyBoundary.lastIndex, 41);
- for (final index in [75, fileCount - 1]) {
- final fileOffset = groups.getOffsetOfFile(files[index]);
- expect(fileOffset, isNotNull);
- expect(groups.getFileAtScrollOffset(fileOffset!), same(files[index]));
- }
- expect(groups.getFileAtScrollOffset(section.maxOffset), same(files.last));
- });
+ for (final index in [75, fileCount - 1]) {
+ final fileOffset = groups.getOffsetOfFile(files[index]);
+ expect(fileOffset, isNotNull);
+ expect(groups.getFileAtScrollOffset(fileOffset!), same(files[index]));
+ }
+ expect(groups.getFileAtScrollOffset(section.maxOffset), same(files.last));
+ },
+ );
- testWidgets("mosaic rows request large thumbnails for every tile", (
+ testWidgets("justified rows request large thumbnails for every tile", (
tester,
) async {
final files = List<EnteFile>.generate(
@@ -190,18 +196,18 @@ void main() {
groupType: GroupType.none,
groupHeaderExtent: GalleryGroups.spacing,
);
- final section = groups.groupLayouts.single as MosaicSectionLayout;
+ final section = groups.groupLayouts.single as JustifiedSectionLayout;
await tester.pumpWidget(
const MaterialApp(
- home: SizedBox(key: ValueKey("mosaic-builder-context")),
+ home: SizedBox(key: ValueKey("justified-builder-context")),
),
);
final context = tester.element(
- find.byKey(const ValueKey("mosaic-builder-context")),
+ find.byKey(const ValueKey("justified-builder-context")),
);
final rowWidget =
- section.builder(context, section.bodyFirstIndex) as MosaicGridRow;
+ section.builder(context, section.bodyFirstIndex) as JustifiedGridRow;
final galleryTiles = rowWidget.children.map(
(child) => (child as RepaintBoundary).child! as GalleryFileWidget,
);
@@ -280,7 +286,7 @@ GalleryGroups _galleryGroups({
groupHeaderExtent: groupHeaderExtent,
showSelectAll: false,
layoutTypeOverride: layoutTypeOverride,
- mosaicLayoutAvailable: true,
+ justifiedLayoutAvailable: true,
);
}
@@ -297,7 +303,7 @@ EnteFile _file({
..pubMagicMetadata = PubMagicMetadata(w: width, h: height);
}
-void _expectRowsCoverFiles(MosaicSectionLayout section, int fileCount) {
+void _expectRowsCoverFiles(JustifiedSectionLayout section, int fileCount) {
expect(section.rows, isNotEmpty);
var expectedFirstFileIndex = 0;
var expectedRowOffset = 0.0;
diff --git a/mobile/apps/photos/test/models/mosaic_grid_row_test.dart b/mobile/apps/photos/test/models/justified_grid_row_test.dart
similarity index 90%
rename from mobile/apps/photos/test/models/mosaic_grid_row_test.dart
rename to mobile/apps/photos/test/models/justified_grid_row_test.dart
index 75af24320a..e4fbc527f7 100644
--- a/mobile/apps/photos/test/models/mosaic_grid_row_test.dart
+++ b/mobile/apps/photos/test/models/justified_grid_row_test.dart
@@ -1,10 +1,10 @@
import "package:flutter/material.dart";
import "package:flutter_test/flutter_test.dart";
-import "package:photos/models/gallery/mosaic_grid_row.dart";
+import "package:photos/models/gallery/justified_grid_row.dart";
void main() {
testWidgets(
- "MosaicGridRow gives children their precomputed sizes and offsets",
+ "JustifiedGridRow gives children their precomputed sizes and offsets",
(tester) async {
const rowKey = ValueKey("row");
const firstKey = ValueKey("first");
@@ -18,7 +18,7 @@ void main() {
alignment: Alignment.topLeft,
child: SizedBox(
width: 300,
- child: MosaicGridRow(
+ child: JustifiedGridRow(
key: rowKey,
itemWidths: [60, 90, 146],
height: 80,
diff --git a/mobile/apps/photos/test/models/mosaic_layout_test.dart b/mobile/apps/photos/test/models/justified_layout_test.dart
similarity index 81%
rename from mobile/apps/photos/test/models/mosaic_layout_test.dart
rename to mobile/apps/photos/test/models/justified_layout_test.dart
index 59ac27e45a..b59fb1ef34 100644
--- a/mobile/apps/photos/test/models/mosaic_layout_test.dart
+++ b/mobile/apps/photos/test/models/justified_layout_test.dart
@@ -1,27 +1,27 @@
import "package:flutter/widgets.dart";
import "package:flutter_test/flutter_test.dart";
-import "package:photos/models/gallery/mosaic_layout.dart";
+import "package:photos/models/gallery/justified_layout.dart";
void main() {
- group("MosaicLayoutCalculator", () {
+ group("JustifiedLayoutCalculator", () {
test("uses a square fallback for missing or invalid dimensions", () {
- expect(MosaicLayoutCalculator.aspectRatioForDimensions(0, 0), 1);
- expect(MosaicLayoutCalculator.aspectRatioForDimensions(0, 100), 1);
- expect(MosaicLayoutCalculator.aspectRatioForDimensions(100, 0), 1);
- expect(MosaicLayoutCalculator.aspectRatioForDimensions(-100, 50), 1);
- expect(MosaicLayoutCalculator.aspectRatioForDimensions(100, -50), 1);
+ expect(JustifiedLayoutCalculator.aspectRatioForDimensions(0, 0), 1);
+ expect(JustifiedLayoutCalculator.aspectRatioForDimensions(0, 100), 1);
+ expect(JustifiedLayoutCalculator.aspectRatioForDimensions(100, 0), 1);
+ expect(JustifiedLayoutCalculator.aspectRatioForDimensions(-100, 50), 1);
+ expect(JustifiedLayoutCalculator.aspectRatioForDimensions(100, -50), 1);
});
test("preserves normal ratios and clamps extreme dimensions", () {
- expect(MosaicLayoutCalculator.aspectRatioForDimensions(4, 3), 4 / 3);
- expect(MosaicLayoutCalculator.aspectRatioForDimensions(1, 100), 1 / 3);
- expect(MosaicLayoutCalculator.aspectRatioForDimensions(100, 1), 4);
+ expect(JustifiedLayoutCalculator.aspectRatioForDimensions(4, 3), 4 / 3);
+ expect(JustifiedLayoutCalculator.aspectRatioForDimensions(1, 100), 1 / 3);
+ expect(JustifiedLayoutCalculator.aspectRatioForDimensions(100, 1), 4);
});
test("justified rows conserve the full available width", () {
const availableWidth = 400.0;
const spacing = 2.0;
- final rows = MosaicLayoutCalculator.computeRows(
+ final rows = JustifiedLayoutCalculator.computeRows(
aspectRatios: const [1, 1, 1, 1],
availableWidth: availableWidth,
targetRowHeight: 100,
@@ -41,7 +41,7 @@ void main() {
const availableWidth = 400.0;
const targetRowHeight = 100.0;
const spacing = 2.0;
- final rows = MosaicLayoutCalculator.computeRows(
+ final rows = JustifiedLayoutCalculator.computeRows(
aspectRatios: const [1, 1],
availableWidth: availableWidth,
targetRowHeight: targetRowHeight,
@@ -60,7 +60,7 @@ void main() {
test("a sparse portrait final row remains ragged and tappable", () {
const availableWidth = 400.0;
const targetRowHeight = 100.0;
- final rows = MosaicLayoutCalculator.computeRows(
+ final rows = JustifiedLayoutCalculator.computeRows(
aspectRatios: const [0.25],
availableWidth: availableWidth,
targetRowHeight: targetRowHeight,
@@ -78,7 +78,7 @@ void main() {
test("keeps a tappable portrait with the following panorama", () {
const availableWidth = 393.0;
const spacing = 2.0;
- final rows = MosaicLayoutCalculator.computeRows(
+ final rows = JustifiedLayoutCalculator.computeRows(
aspectRatios: const [0.85, 4.0],
availableWidth: availableWidth,
targetRowHeight: 130,
@@ -102,7 +102,7 @@ void main() {
[0.25, 4.0],
[4.0, 0.25],
]) {
- final rows = MosaicLayoutCalculator.computeRows(
+ final rows = JustifiedLayoutCalculator.computeRows(
aspectRatios: ratios,
availableWidth: 430,
targetRowHeight: 106,
@@ -120,7 +120,7 @@ void main() {
});
test("does not make a justified row shorter than the tap target", () {
- final rows = MosaicLayoutCalculator.computeRows(
+ final rows = JustifiedLayoutCalculator.computeRows(
aspectRatios: const [4.0, 4.0],
availableWidth: 360,
targetRowHeight: 80,
@@ -135,7 +135,7 @@ void main() {
});
test("accepts a justified row exactly at the tap target", () {
- final rows = MosaicLayoutCalculator.computeRows(
+ final rows = JustifiedLayoutCalculator.computeRows(
aspectRatios: const [1.0, 4.0],
availableWidth: 242,
targetRowHeight: 100,
@@ -148,7 +148,7 @@ void main() {
});
test("raises a sparse row to the minimum tappable height", () {
- final rows = MosaicLayoutCalculator.computeRows(
+ final rows = JustifiedLayoutCalculator.computeRows(
aspectRatios: const [4.0],
availableWidth: 400,
targetRowHeight: 30,
@@ -161,23 +161,23 @@ void main() {
});
});
- group("MosaicSectionLayout", () {
+ group("JustifiedSectionLayout", () {
const rows = [
- MosaicRowLayout(
+ JustifiedRowLayout(
firstIndex: 0,
lastIndex: 1,
minOffset: 0,
height: 10,
itemWidths: [40, 40],
),
- MosaicRowLayout(
+ JustifiedRowLayout(
firstIndex: 2,
lastIndex: 2,
minOffset: 12,
height: 20,
itemWidths: [80],
),
- MosaicRowLayout(
+ JustifiedRowLayout(
firstIndex: 3,
lastIndex: 4,
minOffset: 34,
@@ -185,7 +185,7 @@ void main() {
itemWidths: [30, 50],
),
];
- final section = MosaicSectionLayout(
+ final section = JustifiedSectionLayout(
firstIndex: 10,
lastIndex: 13,
minOffset: 100,
diff --git a/mobile/apps/photos/test/settings/local_settings_gallery_layout_test.dart b/mobile/apps/photos/test/settings/local_settings_gallery_layout_test.dart
index e6148f2d37..f49ad876a3 100644
--- a/mobile/apps/photos/test/settings/local_settings_gallery_layout_test.dart
+++ b/mobile/apps/photos/test/settings/local_settings_gallery_layout_test.dart
@@ -12,17 +12,17 @@ void main() {
expect(settings.getGalleryLayoutType(), GalleryLayoutType.grid);
});
- test("gallery layout persists mosaic", () async {
+ test("gallery layout persists justified", () async {
SharedPreferences.setMockInitialValues({});
final preferences = await SharedPreferences.getInstance();
final settings = LocalSettings(preferences);
- await settings.setGalleryLayoutType(GalleryLayoutType.mosaic);
+ await settings.setGalleryLayoutType(GalleryLayoutType.justified);
- expect(settings.getGalleryLayoutType(), GalleryLayoutType.mosaic);
+ expect(settings.getGalleryLayoutType(), GalleryLayoutType.justified);
expect(
preferences.getString(LocalSettings.kGalleryLayoutType),
- GalleryLayoutType.mosaic.name,
+ "justified",
);
});
}
diff --git a/mobile/apps/photos/test/ui/viewer/gallery/component/gallery_file_widget_test.dart b/mobile/apps/photos/test/ui/viewer/gallery/component/gallery_file_widget_test.dart
index cfefe18a02..9c1c19c446 100644
--- a/mobile/apps/photos/test/ui/viewer/gallery/component/gallery_file_widget_test.dart
+++ b/mobile/apps/photos/test/ui/viewer/gallery/component/gallery_file_widget_test.dart
@@ -165,7 +165,7 @@ void main() {
});
testWidgets(
- "a requested large mosaic thumbnail bypasses the cached small tier",
+ "a requested large justified thumbnail bypasses the cached small tier",
(tester) async {
final file = EnteFile()
..generatedID = 2
@@ -179,7 +179,7 @@ void main() {
);
addTearDown(() => ThumbnailInMemoryLruCache.clearCache(file));
- Widget buildGalleryTile({required bool mosaic}) {
+ Widget buildGalleryTile({required bool justified}) {
return MaterialApp(
home: GalleryContextState(
sortOrderAsc: false,
@@ -190,11 +190,11 @@ void main() {
file: file,
selectedFiles: null,
limitSelectionToOne: true,
- tag: mosaic ? "mosaic_" : "grid_",
+ tag: justified ? "justified_" : "grid_",
// A dense-grid size that preserves the legacy large-render /
- // small-local-cache behavior when no mosaic override exists.
+ // small-local-cache behavior when no justified override exists.
photoGridSize: photoGridSizeDefault - 1,
- thumbnailSize: mosaic ? thumbnailLargeSize : null,
+ thumbnailSize: justified ? thumbnailLargeSize : null,
currentUserID: null,
),
),
@@ -202,12 +202,12 @@ void main() {
);
}
- await tester.pumpWidget(buildGalleryTile(mosaic: true));
- final mosaicThumbnail = tester.widget<ThumbnailWidget>(
+ await tester.pumpWidget(buildGalleryTile(justified: true));
+ final justifiedThumbnail = tester.widget<ThumbnailWidget>(
find.byType(ThumbnailWidget),
);
- expect(mosaicThumbnail.thumbnailSize, thumbnailLargeSize);
- expect(mosaicThumbnail.useRequestedThumbnailSizeForLocalCache, isTrue);
+ expect(justifiedThumbnail.thumbnailSize, thumbnailLargeSize);
+ expect(justifiedThumbnail.useRequestedThumbnailSizeForLocalCache, isTrue);
expect(
find.descendant(
of: find.byType(ThumbnailWidget),
@@ -216,7 +216,7 @@ void main() {
findsNothing,
);
- await tester.pumpWidget(buildGalleryTile(mosaic: false));
+ await tester.pumpWidget(buildGalleryTile(justified: false));
await tester.pump();
final gridThumbnail = tester.widget<ThumbnailWidget>(
find.byType(ThumbnailWidget),
diff --git a/mobile/apps/photos/test/ui/viewer/gallery/component/sectioned_sliver_list_test.dart b/mobile/apps/photos/test/ui/viewer/gallery/component/sectioned_sliver_list_test.dart
index 73136c3ffd..4ef2a647ce 100644
--- a/mobile/apps/photos/test/ui/viewer/gallery/component/sectioned_sliver_list_test.dart
+++ b/mobile/apps/photos/test/ui/viewer/gallery/component/sectioned_sliver_list_test.dart
@@ -1,11 +1,11 @@
import "package:flutter/material.dart";
import "package:flutter_test/flutter_test.dart";
-import "package:photos/models/gallery/mosaic_layout.dart";
+import "package:photos/models/gallery/justified_layout.dart";
import "package:photos/ui/viewer/gallery/component/sectioned_sliver_list.dart";
void main() {
testWidgets(
- "a deep mosaic jump builds only the nearby viewport and cache rows",
+ "a deep justified jump builds only the nearby viewport and cache rows",
(tester) async {
const rowCount = 100000;
const rowHeight = 50.0;
@@ -15,9 +15,9 @@ void main() {
const deepRowIndex = 80000;
const deepChildIndex = deepRowIndex + 1;
final builtIndices = <int>[];
- final rows = List<MosaicRowLayout>.generate(
+ final rows = List<JustifiedRowLayout>.generate(
rowCount,
- (index) => MosaicRowLayout(
+ (index) => JustifiedRowLayout(
firstIndex: index,
lastIndex: index,
minOffset: index * rowStride,
@@ -26,7 +26,7 @@ void main() {
),
growable: false,
);
- final section = MosaicSectionLayout(
+ final section = JustifiedSectionLayout(
firstIndex: 0,
lastIndex: rowCount,
minOffset: 0,
diff --git a/mobile/apps/photos/test/ui/viewer/gallery/gallery_layout_changed_event_test.dart b/mobile/apps/photos/test/ui/viewer/gallery/gallery_layout_changed_event_test.dart
index 69d71e2801..d444124ff7 100644
--- a/mobile/apps/photos/test/ui/viewer/gallery/gallery_layout_changed_event_test.dart
+++ b/mobile/apps/photos/test/ui/viewer/gallery/gallery_layout_changed_event_test.dart
@@ -152,7 +152,7 @@ void main() {
await localSettings.setGalleryLayoutType(GalleryLayoutType.grid);
await localSettings.setPhotoGridSize(2);
final galleryKey = GlobalKey<GalleryState>();
- final files = List<EnteFile>.generate(1000, _mosaicTestFile);
+ final files = List<EnteFile>.generate(1000, _justifiedTestFile);
await tester.pumpWidget(
MaterialApp(
@@ -198,7 +198,7 @@ void main() {
);
await Future.wait([
- localSettings.setGalleryLayoutType(GalleryLayoutType.mosaic),
+ localSettings.setGalleryLayoutType(GalleryLayoutType.justified),
localSettings.setPhotoGridSize(6),
]);
Bus.instance.fire(GalleryLayoutChangedEvent());
@@ -206,9 +206,9 @@ void main() {
await tester.pump();
await tester.pump();
- final mosaicGroups = galleryKey.currentState!.galleryGroups!;
- expect(mosaicGroups.layoutType, GalleryLayoutType.mosaic);
- final newGeometry = mosaicGroups.getGeometryOfFile(anchorFile)!;
+ final justifiedGroups = galleryKey.currentState!.galleryGroups!;
+ expect(justifiedGroups.layoutType, GalleryLayoutType.justified);
+ final newGeometry = justifiedGroups.getGeometryOfFile(anchorFile)!;
expect(newGeometry.rowExtent, lessThan(oldGeometry.rowExtent));
final expectedAnchorOffset =
newGeometry.rowOffset + newGeometry.rowExtent * rowProgress;
@@ -243,7 +243,7 @@ DummyFile _dummyFile(String groupID) {
..creationTime = DateTime(2026, 8, 19).microsecondsSinceEpoch;
}
-DummyFile _mosaicTestFile(int index) {
+DummyFile _justifiedTestFile(int index) {
final dimensions = switch (index % 4) {
0 => (w: 1600, h: 900),
1 => (w: 900, h: 1600),
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
index af19834278..5346387440 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
@@ -2094,6 +2094,7 @@
"lastYearsTrip": "Last year's trip",
"layout": "Layout",
"layoutGrouped": "Grouped",
+ "layoutJustified": "Justified",
"layoutMasonry": "Masonry",
"layoutTrip": "Trip",
"leave": "Leave",