π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Trim empty state comments and tests
r4khulab9a05d10572
diff --git a/mobile/apps/photos/changes/onboarding-empty-states.md b/mobile/apps/photos/changes/onboarding-empty-states.mdindex 9730804a71..6c835b92da 100644--- a/mobile/apps/photos/changes/onboarding-empty-states.md+++ b/mobile/apps/photos/changes/onboarding-empty-states.md@@ -1 +1 @@-- Redesigned the empty Feed and Albums screens with simpler copy and a new illustration for received albums.+- Redesigned the empty Feed and Albums screens.diff --git a/mobile/apps/photos/lib/ui/tabs/albums/empty_states/empty_state_layout.dart b/mobile/apps/photos/lib/ui/tabs/albums/empty_states/empty_state_layout.dartindex f7f4fc8458..7d73e5784f 100644--- a/mobile/apps/photos/lib/ui/tabs/albums/empty_states/empty_state_layout.dart+++ b/mobile/apps/photos/lib/ui/tabs/albums/empty_states/empty_state_layout.dart@@ -2,7 +2,6 @@ import "package:ente_components/ente_components.dart";import "package:flutter/material.dart";import "package:photos/ui/home/home_bottom_nav_bar.dart";-// Figma: https://www.figma.com/design/BuBNPPytxlVnqfmCUW0mgz/ENTE-VISUAL-DESIGN?node-id=25356-304869class EmptyStateLayout extends StatelessWidget {const EmptyStateLayout({required this.assetPath,@@ -33,7 +32,6 @@ class EmptyStateLayout extends StatelessWidget {Widget build(BuildContext context) {final colors = context.componentColors;final bottomSafeArea = MediaQuery.paddingOf(context).bottom;- // Balances the nav clearance so the block centers where Figma places it.final padding = reservesBottomNavigationSpace? EdgeInsets.fromLTRB(Spacing.lg,diff --git a/mobile/apps/photos/test/ui/tabs/albums/empty_states_test.dart b/mobile/apps/photos/test/ui/tabs/albums/empty_states_test.dartindex 7078fe9809..143cac2f7a 100644--- a/mobile/apps/photos/test/ui/tabs/albums/empty_states_test.dart+++ b/mobile/apps/photos/test/ui/tabs/albums/empty_states_test.dart@@ -5,200 +5,57 @@ import "package:flutter_test/flutter_test.dart";import "package:photos/ente_theme_data.dart";import "package:photos/ui/home/home_bottom_nav_bar.dart";import "package:photos/ui/social/widgets/feed_empty_state.dart";-import "package:photos/ui/tabs/albums/empty_states/empty_state_layout.dart";-import "package:photos/ui/tabs/albums/empty_states/on_device_empty_state.dart";-import "package:photos/ui/tabs/albums/empty_states/on_ente_empty_state.dart";import "package:photos/ui/tabs/albums/empty_states/received_empty_state.dart";-import "package:photos/ui/tabs/albums/empty_states/shared_empty_state.dart";-const _screenSize = Size(402, 874);+const _size = Size(402, 480);const _bottomSafeArea = 34.0;void main() {- final cases = <(String, Widget, String, String, String, String?)>[+ for (final (name, state) in <(String, Widget)>[(- "Ente",- const OnEnteEmptyState(),- "assets/on_ente.png",- "Back up your memories",- "Access them on any device and share them with loved ones.",- "Select albums to backup",- ),- (- "Device without permission",- const OnDeviceEmptyState.permission(),- "assets/on_device.png",- "Allow access to your photos",- "Your photos get organized with face recognition, right on your device.",- "Allow access",- ),- (- "Device without albums",- const OnDeviceEmptyState.noFolders(),- "assets/on_device_empty.png",- "No albums on this device",- "Start snapping, your photos will show up here.",- null,- ),- (- "Shared",- const SharedEmptyState(),- "assets/shared.png",- "Share your memories",- "Loved ones can view, react and add comments, without an account.",- "Share an album",- ),- (- "Received",- const ReceivedEmptyState(),- "assets/received.png",- "Memories shared with you",- "Albums shared with you appear here, ready to view and save.",- "Share an album",- ),- (- "Feed",- const FeedEmptyState(),- "assets/feed.png",- "Share your memories",- "Loved ones can view, react and add comments, without an account.",- "Share an album",+ "Albums",+ const CustomScrollView(+ slivers: [SliverFillRemaining(child: ReceivedEmptyState())],+ ),),- ];-- for (final (name, state, asset, title, description, action) in cases) {- testWidgets("$name empty state shows its illustration, copy and action", (+ ("Feed", const FeedEmptyState()),+ ]) {+ testWidgets("$name empty state scrolls its action clear of the nav bar", (tester,) async {- await _pumpInHost(tester, state);-- expect(_assetImage(asset), findsOneWidget);- expect(find.text(title), findsOneWidget);- expect(find.text(description), findsOneWidget);- if (action == null) {- expect(find.byType(ButtonComponent), findsNothing);- } else {- expect(find.widgetWithText(ButtonComponent, action), findsOneWidget);- }- });- }-- testWidgets("centers content in the space above the bottom navigation", (- tester,- ) async {- await _pumpInHost(tester, const ReceivedEmptyState());-- final content = tester.getRect(_layoutColumn());- expect(- content.center.dy,- moreOrLessEquals((_screenSize.height - _bottomSafeArea - 52) / 2),- );- expect(content.center.dx, moreOrLessEquals(_screenSize.width / 2));- });-- testWidgets("centers content in the full height without navigation", (- tester,- ) async {- await _pump(- tester,- const FeedEmptyState(reservesBottomNavigationSpace: false),- );-- expect(- tester.getRect(_layoutColumn()).center.dy,- moreOrLessEquals((_screenSize.height - _bottomSafeArea) / 2),- );- });-- for (final (name, state, size, textScale) in <(String, Widget, Size, double)>[- ("Received", const ReceivedEmptyState(), const Size(402, 480), 2),- ("Received", const ReceivedEmptyState(), const Size(375, 500), 2),- ("Ente", const OnEnteEmptyState(), const Size(402, 400), 1.5),- ("Feed", const FeedEmptyState(), const Size(320, 480), 2),- ]) {- testWidgets(- "$name empty state at ${size.width.toInt()}x${size.height.toInt()} "- "with ${textScale}x text scrolls its action clear of the nav bar",- (tester) async {- await _pumpInHost(- tester,- state,- size: size,- textScaler: TextScaler.linear(textScale),- );-- expect(tester.takeException(), isNull);- await tester.drag(- find.byType(SingleChildScrollView),- const Offset(0, -2000),- );- await tester.pumpAndSettle();- final action = find.byType(ButtonComponent);- expect(action.hitTestable(), findsOneWidget);- expect(- tester.getRect(action).bottom,- lessThanOrEqualTo(- size.height - _bottomSafeArea - homeBottomNavigationBarHeight,+ tester.view.physicalSize = _size * tester.view.devicePixelRatio;+ addTearDown(tester.view.resetPhysicalSize);+ await tester.pumpWidget(+ MaterialApp(+ theme: lightThemeData,+ localizationsDelegates: StringsLocalizations.localizationsDelegates,+ supportedLocales: StringsLocalizations.supportedLocales,+ home: MediaQuery(+ data: const MediaQueryData(+ size: _size,+ padding: EdgeInsets.only(bottom: _bottomSafeArea),+ textScaler: TextScaler.linear(2),+ ),+ child: Scaffold(body: state),),- );- },- );- }-}--Finder _assetImage(String path) => find.byWidgetPredicate(- (widget) =>- widget is Image &&- widget.image is AssetImage &&- (widget.image as AssetImage).assetName == path,-);--Finder _layoutColumn() => find- .descendant(- of: find.byType(EmptyStateLayout),- matching: find.byType(Column),- )- .first;--Future<void> _pumpInHost(- WidgetTester tester,- Widget state, {- Size size = _screenSize,- TextScaler textScaler = TextScaler.noScaling,-}) {- return _pump(- tester,- state is! FeedEmptyState- ? CustomScrollView(slivers: [SliverFillRemaining(child: state)])- : state,- size: size,- textScaler: textScaler,- );-}--Future<void> _pump(- WidgetTester tester,- Widget child, {- Size size = _screenSize,- TextScaler textScaler = TextScaler.noScaling,-}) async {- tester.view.physicalSize = size * tester.view.devicePixelRatio;- addTearDown(tester.view.resetPhysicalSize);-- await tester.pumpWidget(- MaterialApp(- theme: lightThemeData,- localizationsDelegates: StringsLocalizations.localizationsDelegates,- supportedLocales: StringsLocalizations.supportedLocales,- home: MediaQuery(- data: MediaQueryData(- size: size,- padding: const EdgeInsets.only(bottom: _bottomSafeArea),- textScaler: textScaler,),- child: Scaffold(body: child),- ),- ),- );- await tester.pumpAndSettle();+ );+ await tester.pumpAndSettle();++ expect(tester.takeException(), isNull);+ await tester.drag(+ find.byType(SingleChildScrollView),+ const Offset(0, -2000),+ );+ await tester.pumpAndSettle();+ final action = find.byType(ButtonComponent);+ expect(action.hitTestable(), findsOneWidget);+ expect(+ tester.getRect(action).bottom,+ lessThanOrEqualTo(+ _size.height - _bottomSafeArea - homeBottomNavigationBarHeight,+ ),+ );+ });+ }}