💚 End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Set row count to two when selecting Flex
ashil-pilot170cd424e2e7
diff --git a/mobile/apps/photos/changes/optimize-internal-flex.md b/mobile/apps/photos/changes/optimize-internal-flex.mdindex edb404c764..7ed348eae7 100644--- a/mobile/apps/photos/changes/optimize-internal-flex.md+++ b/mobile/apps/photos/changes/optimize-internal-flex.md@@ -1 +1,2 @@- Improved gallery layout calculation speed for the internal Justified · Flex option, especially on wider screens.+- Selecting the internal Flex layout now sets the row count to 2.diff --git a/mobile/apps/photos/lib/ui/settings/gallery_settings_screen.dart b/mobile/apps/photos/lib/ui/settings/gallery_settings_screen.dartindex 0b076c1fb0..9b5862251a 100644--- a/mobile/apps/photos/lib/ui/settings/gallery_settings_screen.dart+++ b/mobile/apps/photos/lib/ui/settings/gallery_settings_screen.dart@@ -174,19 +174,25 @@ class _GallerySettingsScreenState extends State<GallerySettingsScreen> {!isJustifiedLayoutAvailable) {return;}+ final resetGridSize =+ strategy == JustifiedLayoutStrategy.flex &&+ localSettings.getPhotoGridSize() != 2;if (localSettings.getGalleryLayoutType() == layoutType &&(strategy == null ||- localSettings.getJustifiedLayoutStrategy() == strategy)) {+ localSettings.getJustifiedLayoutStrategy() == strategy) &&+ !resetGridSize) {return;}await Future.wait([localSettings.setGalleryLayoutType(layoutType),if (strategy != null) localSettings.setJustifiedLayoutStrategy(strategy),+ if (resetGridSize) localSettings.setPhotoGridSize(2),]);if (mounted) {setState(() {_layoutType = layoutType;if (strategy != null) _justifiedStrategy = strategy;+ _photoGridSize = localSettings.getPhotoGridSize();});}Bus.instance.fire(GalleryLayoutChangedEvent());diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/layout_settings.dart b/mobile/apps/photos/lib/ui/viewer/gallery/layout_settings.dartindex 08f28de81d..2b304705b2 100644--- a/mobile/apps/photos/lib/ui/viewer/gallery/layout_settings.dart+++ b/mobile/apps/photos/lib/ui/viewer/gallery/layout_settings.dart@@ -140,11 +140,16 @@ class _GalleryLayoutSettingsState extends State<GalleryLayoutSettings> {Future<void> _applyJustifiedLayout(JustifiedLayoutStrategy strategy) async {if (!isJustifiedLayoutAvailable) return;+ final resetGridSize =+ strategy == JustifiedLayoutStrategy.flex &&+ localSettings.getPhotoGridSize() != 2;if (localSettings.getGalleryLayoutType() != GalleryLayoutType.justified ||- localSettings.getJustifiedLayoutStrategy() != strategy) {+ localSettings.getJustifiedLayoutStrategy() != strategy ||+ resetGridSize) {await Future.wait([localSettings.setGalleryLayoutType(GalleryLayoutType.justified),localSettings.setJustifiedLayoutStrategy(strategy),+ if (resetGridSize) localSettings.setPhotoGridSize(2),]);Bus.instance.fire(GalleryLayoutChangedEvent());}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 d5a3a3630f..b3f8cd9040 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@@ -105,18 +105,22 @@ void main() {});testWidgets(- "both layout menus notify galleries when only the strategy changes",+ "selecting or reselecting Flex in either menu sets grid size 2 and notifies galleries",(tester) async {var events = 0;final subscription = Bus.instance.on<GalleryLayoutChangedEvent>().listen((_) => events++,);addTearDown(subscription.cancel);- for (final quickMenu in [true, false]) {+ for (final (quickMenu, initialStrategy) in [+ (true, JustifiedLayoutStrategy.comfortLarge),+ (false, JustifiedLayoutStrategy.comfortLarge),+ (true, JustifiedLayoutStrategy.flex),+ (false, JustifiedLayoutStrategy.flex),+ ]) {await localSettings.setGalleryLayoutType(GalleryLayoutType.justified);- await localSettings.setJustifiedLayoutStrategy(- JustifiedLayoutStrategy.comfortLarge,- );+ await localSettings.setJustifiedLayoutStrategy(initialStrategy);+ await localSettings.setPhotoGridSize(4);events = 0;await tester.pumpWidget(MaterialApp(@@ -149,7 +153,7 @@ void main() {}expect(find.text("Justified · Comfort"), findsNothing);expect(find.text("Justified · Flex Full Rows"), findsNothing);- await tester.tap(find.text("Justified · Flex (i)"));+ await tester.tap(find.text("Justified · Flex (i)").hitTestable());await tester.pumpAndSettle();expect(localSettings.getGalleryLayoutType(),@@ -159,7 +163,18 @@ void main() {localSettings.getJustifiedLayoutStrategy(),JustifiedLayoutStrategy.flex,);+ expect(localSettings.getPhotoGridSize(), 2);expect(events, 1);+ if (!quickMenu) {+ expect(find.text("2"), findsOneWidget);+ await tester.tap(find.text("Layout (i)"));+ await tester.pumpAndSettle();+ await tester.tap(find.text("Grid"));+ await tester.pumpAndSettle();+ expect(localSettings.getGalleryLayoutType(), GalleryLayoutType.grid);+ expect(localSettings.getPhotoGridSize(), 2);+ expect(events, 2);+ }await tester.pumpWidget(const SizedBox.shrink());await tester.pumpAndSettle();}