π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Polish contact linking and empty states
Neeraj Gupta8c21ca178af8
diff --git a/mobile/apps/photos/lib/l10n/intl_en.arb b/mobile/apps/photos/lib/l10n/intl_en.arbindex 828e53d4ba..1852b5cbfe 100644--- a/mobile/apps/photos/lib/l10n/intl_en.arb+++ b/mobile/apps/photos/lib/l10n/intl_en.arb@@ -2399,7 +2399,8 @@"description": "Caption for the 'Link email' title. It should be a continuation of the 'Link email' title. Just like how 'Link email' + 'for faster sharing' forms a proper sentence in English, the combination of these two strings should also be a proper sentence in other languages."},"selectPerson": "Select person",- "selectPersonToLinkToThisContact": "Select a person to link to this contact",+ "selectPersonToLinkToThisContact": "Select a person to autofill this contact",+ "searchAllPeople": "Search all people","selectPersonToLink": "Select person to link","linkPersonToEmail": "Link person to {email}","@linkPersonToEmail": {diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/contact_person_picker_page.dart b/mobile/apps/photos/lib/ui/viewer/search/result/contact_person_picker_page.dartindex 36a648f504..480e1e5e49 100644--- a/mobile/apps/photos/lib/ui/viewer/search/result/contact_person_picker_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/result/contact_person_picker_page.dart@@ -1,9 +1,9 @@+import "package:collection/collection.dart";import "package:ente_components/ente_components.dart";import "package:flutter/material.dart";import "package:hugeicons/hugeicons.dart";import "package:photos/generated/l10n.dart";import "package:photos/models/ml/face/person.dart";-import "package:photos/ui/notification/toast.dart";import "package:photos/ui/viewer/people/face_thumbnail_squircle.dart";import "package:photos/ui/viewer/people/person_face_widget.dart";import "package:photos/utils/person_contact_linking_util.dart";@@ -22,7 +22,7 @@ class ContactPersonPickerPickPhoto extends ContactPersonPickerResult {const ContactPersonPickerPickPhoto();}-class ContactPersonPickerPage extends StatelessWidget {+class ContactPersonPickerPage extends StatefulWidget {const ContactPersonPickerPage({required this.contactUserId,required this.contactEmail,@@ -36,10 +36,39 @@ class ContactPersonPickerPage extends StatelessWidget {static const _horizontalPadding = 16.0;static const _gridGap = 10.0;+ @override+ State<ContactPersonPickerPage> createState() =>+ _ContactPersonPickerPageState();+}++class _ContactPersonPickerPageState extends State<ContactPersonPickerPage> {+ String _searchQuery = "";+ bool _sortAscending = true;+@overrideWidget build(BuildContext context) {final colors = context.componentColors;final l10n = AppLocalizations.of(context);+ final persons =+ widget.persons+ .where(+ (person) => !isLinkedToDifferentContact(+ person,+ contactUserId: widget.contactUserId,+ email: widget.contactEmail,+ ),+ )+ .where(+ (person) => person.data.name.toLowerCase().contains(_searchQuery),+ )+ .toList()+ ..sort((first, second) {+ final comparison = compareAsciiLowerCaseNatural(+ first.data.name,+ second.data.name,+ );+ return _sortAscending ? comparison : -comparison;+ });return Scaffold(backgroundColor: colors.backgroundBase,@@ -57,17 +86,89 @@ class ContactPersonPickerPage extends StatelessWidget {},),],- slivers: [_buildGrid(persons)],+ slivers: [+ SliverPadding(+ padding: const EdgeInsets.fromLTRB(+ ContactPersonPickerPage._horizontalPadding,+ 0,+ ContactPersonPickerPage._horizontalPadding,+ Spacing.xl,+ ),+ sliver: SliverToBoxAdapter(child: _buildSearchRow(context)),+ ),+ _buildGrid(persons),+ ],),);}+ Widget _buildSearchRow(BuildContext context) {+ final colors = context.componentColors;+ final l10n = AppLocalizations.of(context);+ return Row(+ children: [+ Expanded(+ child: TextInputComponent(+ hintText: l10n.searchAllPeople,+ prefix: HugeIcon(+ icon: HugeIcons.strokeRoundedSearch01,+ size: IconSizes.small,+ color: colors.textLight,+ ),+ autocorrect: false,+ textInputAction: TextInputAction.search,+ onChanged: (value) {+ setState(() => _searchQuery = value.trim().toLowerCase());+ },+ ),+ ),+ const SizedBox(width: Spacing.xl),+ Builder(+ builder: (buttonContext) => IconButtonComponent(+ tooltip: l10n.sort,+ variant: IconButtonComponentVariant.primary,+ shouldSurfaceExecutionStates: false,+ icon: const HugeIcon(icon: HugeIcons.strokeRoundedFilterHorizontal),+ onTap: () => _showSortMenu(buttonContext),+ ),+ ),+ ],+ );+ }++ Future<void> _showSortMenu(BuildContext context) async {+ final l10n = AppLocalizations.of(context);+ final selected = await showEntePopupMenu<bool>(+ context: context,+ options: [+ EntePopupMenuOption(+ value: true,+ label: l10n.name,+ secondaryLabel: l10n.sortAToZ,+ isActive: _sortAscending,+ activeTrailingWidget: const Icon(Icons.check_rounded),+ ),+ EntePopupMenuOption(+ value: false,+ label: l10n.name,+ secondaryLabel: l10n.sortZToA,+ isActive: !_sortAscending,+ activeTrailingWidget: const Icon(Icons.check_rounded),+ showDivider: false,+ ),+ ],+ );+ if (selected != null && mounted) {+ setState(() => _sortAscending = selected);+ }+ }+Widget _buildGrid(List<PersonEntity> persons) {return SliverPadding(padding: const EdgeInsets.fromLTRB(- _horizontalPadding,+ ContactPersonPickerPage._horizontalPadding,0,- _horizontalPadding,+ ContactPersonPickerPage._horizontalPadding,48,),sliver: SliverLayoutBuilder(@@ -75,14 +176,14 @@ class ContactPersonPickerPage extends StatelessWidget {const crossAxisCount = 3;final tileSize =(constraints.crossAxisExtent -- (_gridGap * (crossAxisCount - 1))) /+ (ContactPersonPickerPage._gridGap * (crossAxisCount - 1))) /crossAxisCount;return SliverGrid(gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: crossAxisCount,mainAxisSpacing: 20,- crossAxisSpacing: _gridGap,- childAspectRatio: tileSize / (tileSize + 30),+ crossAxisSpacing: ContactPersonPickerPage._gridGap,+ childAspectRatio: tileSize / (tileSize + 28),),delegate: SliverChildBuilderDelegate(childCount: persons.length,@@ -90,8 +191,6 @@ class ContactPersonPickerPage extends StatelessWidget {key: ValueKey(persons[index].remoteID),person: persons[index],size: tileSize,- contactUserId: contactUserId,- contactEmail: contactEmail,),),);@@ -102,18 +201,10 @@ class ContactPersonPickerPage extends StatelessWidget {}class _PersonTile extends StatelessWidget {- const _PersonTile({- super.key,- required this.person,- required this.size,- required this.contactUserId,- required this.contactEmail,- });+ const _PersonTile({super.key, required this.person, required this.size});final PersonEntity person;final double size;- final int contactUserId;- final String contactEmail;@overrideWidget build(BuildContext context) {@@ -122,23 +213,11 @@ class _PersonTile extends StatelessWidget {return GestureDetector(behavior: HitTestBehavior.opaque,- onTap: () {- if (isLinkedToDifferentContact(- person,- contactUserId: contactUserId,- email: contactEmail,- )) {- showShortToast(- context,- AppLocalizations.of(context).personAlreadyLinkedToAnotherContact,- );- return;- }- Navigator.of(context).pop(ContactPersonPickerSelected(person));- },+ onTap: () =>+ Navigator.of(context).pop(ContactPersonPickerSelected(person)),child: Column(mainAxisSize: MainAxisSize.min,- crossAxisAlignment: CrossAxisAlignment.center,+ crossAxisAlignment: CrossAxisAlignment.start,children: [SizedBox.square(dimension: size,@@ -154,15 +233,14 @@ class _PersonTile extends StatelessWidget {),),),- const SizedBox(height: 6),- Text(- person.data.name,- maxLines: 1,- textAlign: TextAlign.center,- overflow: TextOverflow.ellipsis,- style: TextStyles.body.copyWith(- color: colors.textBase,- height: 20 / 14,+ const SizedBox(height: Spacing.sm),+ SizedBox(+ width: double.infinity,+ child: Text(+ person.data.name,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: TextStyles.body.copyWith(color: colors.textBase),),),],diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/contact_result_page.dart b/mobile/apps/photos/lib/ui/viewer/search/result/contact_result_page.dartindex 35a962db90..77a7d7249a 100644--- a/mobile/apps/photos/lib/ui/viewer/search/result/contact_result_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/result/contact_result_page.dart@@ -501,15 +501,18 @@ class _UnsavedContactHeader extends StatelessWidget {final l10n = AppLocalizations.of(context);return Padding(padding: const EdgeInsets.fromLTRB(16, 24, 16, 8),- child: MenuComponent(- title: l10n.addANameAndPhoto,- titleColor: colorScheme.textBase,- leading: _AddContactMenuIcon(colorScheme: colorScheme),- trailing: Icon(- Icons.chevron_right_rounded,- color: colorScheme.textMuted,+ child: SizedBox(+ height: 60,+ child: MenuComponent(+ title: l10n.addANameAndPhoto,+ titleColor: colorScheme.textBase,+ leading: _AddContactMenuIcon(colorScheme: colorScheme),+ trailing: Icon(+ Icons.chevron_right_rounded,+ color: colorScheme.textMuted,+ ),+ onTap: onTap,),- onTap: onTap,),);}@@ -548,38 +551,32 @@ class _UnsavedContactEmptyState extends StatelessWidget {final colorScheme = getEnteColorScheme(context);final textTheme = getEnteTextTheme(context);final l10n = AppLocalizations.of(context);- return Center(- child: Padding(- padding: const EdgeInsets.symmetric(horizontal: 36),- child: Column(- mainAxisAlignment: MainAxisAlignment.center,- children: [- Image.asset(- "assets/ducky_share.png",- height: 180,- errorBuilder: (context, error, stackTrace) {- return const SizedBox(height: 180);- },- ),- const SizedBox(height: 12),- Text(- l10n.nothingToSeeHere,- style: textTheme.largeBold.copyWith(- fontSize: 18,- height: 24 / 18,- ),- ),- const SizedBox(height: 4),- Text(- l10n.photosSharedByWillAppearHere(email: email),- textAlign: TextAlign.center,- style: textTheme.mini.copyWith(- color: colorScheme.textMuted,- height: 16 / 12,- ),+ return Padding(+ padding: const EdgeInsets.fromLTRB(36, 32, 36, 0),+ child: Column(+ children: [+ Image.asset(+ "assets/ducky_share.png",+ height: 180,+ errorBuilder: (context, error, stackTrace) {+ return const SizedBox(height: 180);+ },+ ),+ const SizedBox(height: 12),+ Text(+ l10n.nothingToSeeHere,+ style: textTheme.largeBold.copyWith(fontSize: 18, height: 24 / 18),+ ),+ const SizedBox(height: 4),+ Text(+ l10n.photosSharedByWillAppearHere(email: email),+ textAlign: TextAlign.center,+ style: textTheme.mini.copyWith(+ color: colorScheme.textMuted,+ height: 16 / 12,),- ],- ),+ ),+ ],),);}diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/edit_contact_page.dart b/mobile/apps/photos/lib/ui/viewer/search/result/edit_contact_page.dartindex 7f6d458636..12aa882995 100644--- a/mobile/apps/photos/lib/ui/viewer/search/result/edit_contact_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/result/edit_contact_page.dart@@ -1,6 +1,5 @@import "dart:typed_data";-import "package:collection/collection.dart";import "package:ente_components/ente_components.dart";import "package:ente_contacts/contacts.dart" as contacts;import "package:ente_pure_utils/ente_pure_utils.dart";@@ -11,9 +10,12 @@ import "package:photos/core/event_bus.dart";import "package:photos/events/people_changed_event.dart";import "package:photos/generated/l10n.dart";import "package:photos/models/ml/face/person.dart";+import "package:photos/models/search/search_constants.dart";import "package:photos/module/download/thumbnail.dart";+import "package:photos/services/machine_learning/face_ml/face_filtering/face_filtering_constants.dart";import "package:photos/services/machine_learning/face_ml/person/person_service.dart";import "package:photos/services/photos_contacts_service.dart";+import "package:photos/services/search_service.dart";import "package:photos/theme/ente_theme.dart";import "package:photos/ui/common/loading_widget.dart";import "package:photos/ui/components/action_sheet_widget.dart";@@ -329,7 +331,17 @@ class _EditContactPageState extends State<EditContactPage> {}List<PersonEntity> persons;try {- persons = await PersonService.instance.getPersons();+ final faceResults = await SearchService.instance.getAllFace(+ null,+ minClusterSize: kMinimumClusterSizeAllFaces,+ );+ final personIdsWithFiles = faceResults+ .map((result) => result.params[kPersonParamID])+ .whereType<String>()+ .toSet();+ persons = (await PersonService.instance.getPersons())+ .where((person) => personIdsWithFiles.contains(person.remoteID))+ .toList();} catch (e, s) {_logger.warning("Failed to load people before editing contact photo",@@ -342,19 +354,7 @@ class _EditContactPageState extends State<EditContactPage> {if (!mounted) {return;}- final visiblePersons =- persons.where((person) => !person.data.isIgnored).toList()- ..sort((first, second) {- final nameComparison = compareAsciiLowerCaseNatural(- first.data.name,- second.data.name,- );- if (nameComparison != 0) {- return nameComparison;- }- return first.remoteID.compareTo(second.remoteID);- });- if (visiblePersons.isEmpty) {+ if (persons.isEmpty) {await _pickContactPhoto();return;}@@ -364,7 +364,7 @@ class _EditContactPageState extends State<EditContactPage> {ContactPersonPickerPage(contactUserId: widget.contactUserId,contactEmail: widget.email,- persons: visiblePersons,+ persons: persons,),);if (!mounted || result == null) {@@ -393,8 +393,8 @@ class _EditContactPageState extends State<EditContactPage> {}Future<void> _draftSelectedPerson(PersonEntity person) async {- final success = await _loadPersonPhotoDraft(person, showError: true);- if (!success || !mounted) {+ await _loadPersonPhotoDraft(person, showError: true);+ if (!mounted) {return;}_nameController.text = person.data.name;@@ -407,7 +407,7 @@ class _EditContactPageState extends State<EditContactPage> {});}- Future<bool> _loadPersonPhotoDraft(+ Future<void> _loadPersonPhotoDraft(PersonEntity person, {required bool showError,}) async {@@ -422,7 +422,7 @@ class _EditContactPageState extends State<EditContactPage> {_logger.warning("Failed to build contact photo from person", e, s);}if (!mounted || loadGeneration != _photoLoadGeneration) {- return false;+ return;}if (photoBytes == null) {setState(() {@@ -434,14 +434,13 @@ class _EditContactPageState extends State<EditContactPage> {AppLocalizations.of(context).couldNotLoadSelectedPhoto,);}- return false;+ return;}setState(() {_draftPhotoBytes = photoBytes;_isLoadingPhoto = false;_photoDirty = true;});- return true;}Future<void> _pickContactPhoto() async {