Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Fix seam above pinned album date headers

ashilkn6abfc520d610
diff --git a/mobile/apps/photos/changes/album-pinned-header-gap.md b/mobile/apps/photos/changes/album-pinned-header-gap.md
new file mode 100644
index 0000000000..6054399284
--- /dev/null
+++ b/mobile/apps/photos/changes/album-pinned-header-gap.md
@@ -0,0 +1 @@
+- Fixed a thin gap above the pinned date header in albums on some displays.
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
index 6f53bf5f12..cfa109db3e 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
@@ -1316,6 +1316,13 @@ class _PinnedGroupHeaderState extends State<PinnedGroupHeader>
child: Stack(
clipBehavior: Clip.none,
children: [
+ Positioned.fill(
+ // Cover fractional-pixel gaps at the app bar boundary.
+ top: widget.topOffset > 0
+ ? -1 / MediaQuery.devicePixelRatioOf(context)
+ : 0,
+ child: ColoredBox(color: backgroundColor),
+ ),
const Positioned.fill(
child: ClipRect(
clipper: _PinnedHeaderBottomShadowClipper(),
diff --git a/mobile/apps/photos/test/ui/viewer/gallery/collection_page_cover_test.dart b/mobile/apps/photos/test/ui/viewer/gallery/collection_page_cover_test.dart
index 733c343635..e9e10ceded 100644
--- a/mobile/apps/photos/test/ui/viewer/gallery/collection_page_cover_test.dart
+++ b/mobile/apps/photos/test/ui/viewer/gallery/collection_page_cover_test.dart
@@ -1,5 +1,6 @@
import "dart:convert";
import "dart:io";
+import "dart:ui" as ui;
import "package:dio/dio.dart";
import "package:ente_components/ente_components.dart";
@@ -7,6 +8,7 @@ import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:ente_strings/ente_strings.dart";
import "package:figma_squircle/figma_squircle.dart";
import "package:flutter/material.dart";
+import "package:flutter/rendering.dart";
import "package:flutter/services.dart";
import "package:flutter_secure_storage/flutter_secure_storage.dart";
import "package:flutter_test/flutter_test.dart";
@@ -41,6 +43,7 @@ import "package:photos/ui/components/bottom_action_bar/selection_action_sheet.da
import "package:photos/ui/viewer/actions/file_selection_overlay_bar.dart";
import "package:photos/ui/viewer/gallery/collection_page.dart";
import "package:photos/ui/viewer/gallery/component/album_cover_app_bar.dart";
+import "package:photos/ui/viewer/gallery/component/group/group_header_widget.dart";
import "package:photos/ui/viewer/gallery/gallery.dart";
import "package:photos/ui/viewer/gallery/gallery_app_bar_widget.dart";
import "package:photos/ui/viewer/gallery/state/gallery_boundaries_provider.dart";
@@ -144,6 +147,71 @@ void main() {
expect(find.text("Open album"), findsOneWidget);
});
+ testWidgets("paints the pinned date flush with the album app bar", (
+ tester,
+ ) async {
+ const pixelRatio = 2.8125;
+ tester.view.devicePixelRatio = pixelRatio;
+ tester.view.physicalSize = const Size(1080, 2340);
+ tester.view.padding = const FakeViewPadding(top: 95, bottom: 135);
+ addTearDown(tester.view.reset);
+ final files = List.generate(100, (index) => _file(index + 1));
+ await tester.runAsync(() => FilesDB.instance.insertMultiple(files));
+ final boundaryKey = GlobalKey();
+ await tester.pumpWidget(
+ RepaintBoundary(
+ key: boundaryKey,
+ child: MaterialApp(
+ theme: darkThemeData,
+ localizationsDelegates: StringsLocalizations.localizationsDelegates,
+ supportedLocales: StringsLocalizations.supportedLocales,
+ home: CollectionPage(
+ CollectionWithThumbnail(_collection(), files.last),
+ ),
+ ),
+ ),
+ );
+ await _expectCover(tester, files.last, count: files.length);
+ final pinned = tester.widget<PinnedGroupHeader>(
+ find.byType(PinnedGroupHeader),
+ );
+ pinned.scrollController.jumpTo(pinned.scrollOffsetBase + 80);
+ await tester.pumpAndSettle();
+ final header = find.byWidgetPredicate(
+ (widget) => widget is GroupHeaderWidget && widget.isPinnedHeader,
+ );
+ expect(header, findsOneWidget);
+ final top = tester.getTopLeft(header).dy * pixelRatio;
+ final background = GalleryAppBarWidget.backgroundColor(
+ tester.element(header),
+ );
+ final boundary =
+ boundaryKey.currentContext!.findRenderObject()!
+ as RenderRepaintBoundary;
+ final image = (await tester.runAsync(
+ () => boundary.toImage(pixelRatio: pixelRatio),
+ ))!;
+ addTearDown(image.dispose);
+ final pixels = (await tester.runAsync(
+ () => image.toByteData(format: ui.ImageByteFormat.rawRgba),
+ ))!;
+ final backgroundArgb = background.toARGB32();
+ for (var y = top.floor() - 1; y <= top.ceil(); y++) {
+ final offset = (y * image.width + 4) * 4;
+ expect(
+ pixels.buffer.asUint8List(offset, 3),
+ [
+ (backgroundArgb >> 16) & 0xff,
+ (backgroundArgb >> 8) & 0xff,
+ backgroundArgb & 0xff,
+ ],
+ reason:
+ "The album/date boundary must hide the photos at physical row $y",
+ );
+ }
+ await _disposeAlbum(tester);
+ });
+
testWidgets("uses a pending local photo and excludes ignored photos", (
tester,
) async {