π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile][photos] Preserve selection scrolling across gallery transitions
r4khul313b03c3ec0b
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dartindex 189b804940..b4bb73fedd 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart@@ -744,7 +744,10 @@ class GalleryState extends State<Gallery> {_boundariesProvider?.bottomBoundaryNotifier.removeListener(_selectedFilesListener,);- _boundariesProvider?.setScrollController(null);+ if (_boundariesProvider?.scrollControllerNotifier.value ==+ _scrollController) {+ _boundariesProvider?.setScrollController(null);+ }_reloadEventSubscription?.cancel();_layoutChangeSubscription?.cancel();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.dartindex 8d31c94257..ae4ec98c21 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@@ -71,6 +71,53 @@ void main() {await localSettings.setInternalUserDisabled(false);});+ testWidgets("keeps the current gallery controller after an animated swap", (+ tester,+ ) async {+ final boundariesKey = GlobalKey<GalleryBoundariesProviderState>();+ late StateSetter replaceGallery;+ var generation = 0;+ await tester.pumpWidget(+ MaterialApp(+ theme: lightThemeData,+ localizationsDelegates: StringsLocalizations.localizationsDelegates,+ supportedLocales: StringsLocalizations.supportedLocales,+ home: GalleryBoundariesProvider(+ key: boundariesKey,+ child: GalleryFilesState(+ child: StatefulBuilder(+ builder: (context, setState) {+ replaceGallery = setState;+ return AnimatedSwitcher(+ duration: const Duration(milliseconds: 200),+ child: Gallery(+ key: ValueKey(generation),+ asyncLoader: (start, end, {limit, asc}) async =>+ FileLoadResult([_dummyFile("handoff")], false),+ tagPrefix: "handoff",+ enableFileGrouping: false,+ ),+ );+ },+ ),+ ),+ ),+ ),+ );+ await tester.pumpAndSettle();+ final controllers = boundariesKey.currentState!.scrollControllerNotifier;+ final previous = controllers.value;+ replaceGallery(() => generation++);+ await tester.pump();+ final current = controllers.value;+ expect(current, isNotNull);+ expect(current, isNot(same(previous)));+ await tester.pumpAndSettle();+ expect(controllers.value, same(current));+ await tester.pumpWidget(const SizedBox.shrink());+ await tester.pumpAndSettle();+ });+testWidgets("both layout menus notify galleries when only the strategy changes",(tester) async {