π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Tighten contact UI and name sync
Neeraj Gupta130e5ca84635
diff --git a/mobile/apps/photos/lib/services/machine_learning/face_ml/person/person_service.dart b/mobile/apps/photos/lib/services/machine_learning/face_ml/person/person_service.dartindex 997b30cab4..ae863381eb 100644--- a/mobile/apps/photos/lib/services/machine_learning/face_ml/person/person_service.dart+++ b/mobile/apps/photos/lib/services/machine_learning/face_ml/person/person_service.dart@@ -641,12 +641,6 @@ class PersonService {}) async {final person = (await getPerson(id))!;final trimmedName = name?.trim();- if (syncLinkedContactName &&- trimmedName != null &&- trimmedName.isNotEmpty &&- trimmedName != person.data.name.trim()) {- await _updateLinkedContactNameBeforePerson(person, trimmedName);- }var updatedData = person.data.copyWith(name: name,avatarFaceId: avatarFaceId,@@ -664,6 +658,12 @@ class PersonService {updatedData = updatedData.copyWith(userID: userID as int?);}final updatedPerson = person.copyWith(data: updatedData);+ if (syncLinkedContactName &&+ trimmedName != null &&+ trimmedName.isNotEmpty &&+ trimmedName != person.data.name.trim()) {+ await _updateLinkedContactNameBeforePerson(updatedPerson, trimmedName);+ }await updatePerson(updatedPerson);await refreshPersonCache();if (hideFromMemories != null &&diff --git a/mobile/apps/photos/lib/ui/viewer/people/save_or_edit_person.dart b/mobile/apps/photos/lib/ui/viewer/people/save_or_edit_person.dartindex 12029c8d8f..195d96122a 100644--- a/mobile/apps/photos/lib/ui/viewer/people/save_or_edit_person.dart+++ b/mobile/apps/photos/lib/ui/viewer/people/save_or_edit_person.dart@@ -1,6 +1,7 @@import 'dart:async';import "dart:math" as math;+import "package:ente_components/ente_components.dart";import "package:ente_pure_utils/ente_pure_utils.dart";import "package:flutter/material.dart";import "package:flutter_animate/flutter_animate.dart";@@ -545,10 +546,8 @@ class _SaveOrEditPersonState extends State<SaveOrEditPerson> {required PersonEntity person,required String clusterId,}) {- return showModalBottomSheet<bool>(+ return showBottomSheetComponent<bool>(context: context,- isScrollControlled: true,- backgroundColor: Colors.transparent,builder: (context) =>_MergePersonConfirmationSheet(person: person, clusterId: clusterId),);@@ -859,68 +858,47 @@ class _MergePersonConfirmationSheet extends StatelessWidget {Widget build(BuildContext context) {final l10n = AppLocalizations.of(context);final textTheme = getEnteTextTheme(context);- final colorScheme = getEnteColorScheme(context);- return Container(- decoration: BoxDecoration(- color: colorScheme.backgroundElevated2,- borderRadius: const BorderRadius.only(- topLeft: Radius.circular(20),- topRight: Radius.circular(20),- ),- border: Border.all(- color: colorScheme.strokeMuted.withValues(alpha: 0.2),- ),- ),- child: SafeArea(- top: false,- child: Stack(- children: [- Padding(- padding: const EdgeInsets.fromLTRB(24, 56, 24, 24),- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- _MergeFacePair(- clusterId: clusterId,- personId: person.remoteID,- ),- const SizedBox(height: 24),- Text(- l10n.mergeWithPersonTitle(name: person.data.name),- style: textTheme.largeBold.copyWith(- fontSize: 20,- height: 20 / 20,- letterSpacing: -0.4,- ),- textAlign: TextAlign.center,- ),- const SizedBox(height: 11),- Text(- l10n.mergeWithPersonDescription(name: person.data.name),- style: textTheme.smallMuted.copyWith(- height: 20 / 14,- fontWeight: FontWeight.w500,- ),- textAlign: TextAlign.center,- ),- const SizedBox(height: 32),- _MergeSheetActionButton(- label: l10n.merge,- onTap: () => Navigator.of(context).pop(true),- ),- ],- ),+ return BottomSheetComponent(+ closeResult: false,+ content: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ _MergeFacePair(clusterId: clusterId, personId: person.remoteID),+ const SizedBox(height: Spacing.xl),+ Text(+ l10n.mergeWithPersonTitle(name: person.data.name),+ style: textTheme.largeBold.copyWith(+ fontSize: 20,+ height: 20 / 20,+ letterSpacing: -0.4,),- Positioned(- top: 16,- right: 16,- child: _MergeSheetCloseButton(- onTap: () => Navigator.of(context).pop(false),- ),+ textAlign: TextAlign.center,+ ),+ const SizedBox(height: 11),+ Text(+ l10n.mergeWithPersonDescription(name: person.data.name),+ style: textTheme.smallMuted.copyWith(+ height: 20 / 14,+ fontWeight: FontWeight.w500,),- ],+ textAlign: TextAlign.center,+ ),+ ],+ ),+ actions: [+ ButtonComponent(+ label: l10n.merge,+ shouldSurfaceExecutionStates: false,+ onTap: () => Navigator.of(context).pop(true),),+ ],+ crossAxisAlignment: CrossAxisAlignment.stretch,+ padding: const EdgeInsets.fromLTRB(+ Spacing.xl,+ Spacing.lg,+ Spacing.xl,+ Spacing.xl,),);}@@ -1007,67 +985,6 @@ class _MergeFaceThumbnail extends StatelessWidget {}}-class _MergeSheetActionButton extends StatelessWidget {- final String label;- final VoidCallback onTap;-- const _MergeSheetActionButton({required this.label, required this.onTap});-- @override- Widget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);- final borderRadius = BorderRadius.circular(14);-- return SizedBox(- height: 52,- width: double.infinity,- child: Material(- color: colorScheme.primary500,- borderRadius: borderRadius,- child: InkWell(- borderRadius: borderRadius,- onTap: onTap,- child: Center(- child: Text(- label,- style: textTheme.smallBold.copyWith(- color: Colors.white,- height: 20 / 14,- ),- ),- ),- ),- ),- );- }-}--class _MergeSheetCloseButton extends StatelessWidget {- final VoidCallback onTap;-- const _MergeSheetCloseButton({required this.onTap});-- @override- Widget build(BuildContext context) {- final colorScheme = getEnteColorScheme(context);- const double size = 40;-- return GestureDetector(- onTap: onTap,- child: Container(- width: size,- height: size,- decoration: BoxDecoration(- color: colorScheme.fillFaint,- shape: BoxShape.circle,- ),- child: Icon(Icons.close, size: 20, color: colorScheme.textBase),- ),- );- }-}-class _EmailSection extends StatefulWidget {final String? personID;final String? email;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 fa87f777f1..44548551d5 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@@ -43,9 +43,21 @@ class ContactPersonPickerPage extends StatelessWidget {return Scaffold(backgroundColor: colors.backgroundBase,- body: CustomScrollView(+ body: AppBarComponent(+ title: l10n.selectPerson,+ subtitle: l10n.selectPersonToLinkToThisContact,+ actions: [+ IconButtonComponent(+ variant: IconButtonComponentVariant.primary,+ shouldSurfaceExecutionStates: false,+ tooltip: l10n.setAContactPhoto,+ icon: const HugeIcon(icon: HugeIcons.strokeRoundedImageAdd02),+ onTap: () {+ Navigator.of(context).pop(const ContactPersonPickerPickPhoto());+ },+ ),+ ],slivers: [- SliverToBoxAdapter(child: _buildHeader(context, l10n)),if (persons.isEmpty)SliverFillRemaining(hasScrollBody: false,@@ -63,54 +75,6 @@ class ContactPersonPickerPage extends StatelessWidget {);}- Widget _buildHeader(BuildContext context, AppLocalizations l10n) {- final colors = context.componentColors;- final topPadding = MediaQuery.paddingOf(context).top;-- return Padding(- padding: EdgeInsets.fromLTRB(- _horizontalPadding,- topPadding + 24,- _horizontalPadding,- 20,- ),- child: Row(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Expanded(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- l10n.selectPerson,- style: TextStyles.h1Bold.copyWith(- color: colors.textBase,- height: 1.12,- ),- ),- const SizedBox(height: 8),- Text(- l10n.selectPersonToLinkToThisContact,- style: TextStyles.body.copyWith(color: colors.textLight),- ),- ],- ),- ),- const SizedBox(width: Spacing.md),- IconButtonComponent(- variant: IconButtonComponentVariant.primary,- shouldSurfaceExecutionStates: false,- tooltip: l10n.setAContactPhoto,- icon: const HugeIcon(icon: HugeIcons.strokeRoundedImageAdd02),- onTap: () {- Navigator.of(context).pop(const ContactPersonPickerPickPhoto());- },- ),- ],- ),- );- }-Widget _buildGrid(List<PersonEntity> persons) {return SliverPadding(padding: const EdgeInsets.fromLTRB(diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/contact_photo_picker_sheet.dart b/mobile/apps/photos/lib/ui/viewer/search/result/contact_photo_picker_sheet.dartindex e4ef315446..9ac4e90d7e 100644--- a/mobile/apps/photos/lib/ui/viewer/search/result/contact_photo_picker_sheet.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/result/contact_photo_picker_sheet.dart@@ -66,135 +66,71 @@ class _ContactPhotoPickerSheetState extends State<_ContactPhotoPickerSheet> {@overrideWidget build(BuildContext context) {final l10n = AppLocalizations.of(context);- final colors = context.componentColors;final screenHeight = MediaQuery.sizeOf(context).height;final sheetHeight = math.min(screenHeight * 0.78, screenHeight - 80);- return Container(+ return SizedBox(height: sheetHeight,- clipBehavior: Clip.antiAlias,- decoration: BoxDecoration(- color: colors.backgroundBase,- borderRadius: const BorderRadius.vertical(- top: Radius.circular(Radii.bottomSheet),- ),- border: Border.all(color: colors.strokeDark),- ),- child: SafeArea(- top: false,- child: Column(- children: [- _ContactPhotoSheetHeader(title: l10n.setAContactPhoto),- Expanded(- child: GalleryFilesState(- child: Gallery(- asyncLoader:- (creationStartTime, creationEndTime, {limit, asc}) async {- final files = await SearchService.instance- .getAllFilesForContactPhotoPicker();- return FileLoadResult(files, false);- },- tagPrefix: "pick_contact_photo_gallery",- selectedFiles: _selectedFiles,- limitSelectionToOne: true,- showSelectAll: false,- disablePinnedGroupHeader: true,- disableVerticalPaddingForScrollbar: true,- ),- ),+ child: BottomSheetComponent(+ title: l10n.setAContactPhoto,+ content: Expanded(+ child: GalleryFilesState(+ child: Gallery(+ asyncLoader:+ (creationStartTime, creationEndTime, {limit, asc}) async {+ final files = await SearchService.instance+ .getAllFilesForContactPhotoPicker();+ return FileLoadResult(files, false);+ },+ tagPrefix: "pick_contact_photo_gallery",+ selectedFiles: _selectedFiles,+ limitSelectionToOne: true,+ showSelectAll: false,+ disablePinnedGroupHeader: true,+ disableVerticalPaddingForScrollbar: true,),- Padding(- padding: const EdgeInsets.fromLTRB(- Spacing.xl,- Spacing.lg,- Spacing.xl,- Spacing.xl,- ),- child: ListenableBuilder(- listenable: _selectedFiles,- builder: (context, _) {- final isFileSelected = _selectedFiles.files.isNotEmpty;- return Column(- mainAxisSize: MainAxisSize.min,- children: [- ButtonComponent(- label: l10n.setSelectedPhoto,- isDisabled: !isFileSelected,- shouldSurfaceExecutionStates: false,- onTap: isFileSelected- ? () {- Navigator.pop(- context,- ContactPhotoPickerFile(- _selectedFiles.files.first,- ),- );- }- : null,- ),- if (widget.canRemovePhoto) ...[- const SizedBox(height: Spacing.md),- ButtonComponent(- label: l10n.removeContactPhoto,- variant: ButtonComponentVariant.secondary,- shouldSurfaceExecutionStates: false,- onTap: () {+ ),+ ),+ actions: [+ ListenableBuilder(+ listenable: _selectedFiles,+ builder: (context, _) {+ final isFileSelected = _selectedFiles.files.isNotEmpty;+ return Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ ButtonComponent(+ label: l10n.setSelectedPhoto,+ isDisabled: !isFileSelected,+ shouldSurfaceExecutionStates: false,+ onTap: isFileSelected+ ? () {Navigator.pop(context,- const ContactPhotoPickerRemove(),+ ContactPhotoPickerFile(+ _selectedFiles.files.first,+ ),);- },- ),- ],- ],- );- },- ),- ),- ],- ),- ),- );- }-}--class _ContactPhotoSheetHeader extends StatelessWidget {- const _ContactPhotoSheetHeader({required this.title});-- final String title;-- @override- Widget build(BuildContext context) {- final colors = context.componentColors;- return Padding(- padding: const EdgeInsets.fromLTRB(- Spacing.xl,- Spacing.xl,- Spacing.xl,- Spacing.lg,- ),- child: Row(- children: [- Expanded(- child: Text(- title,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: TextStyles.h1.copyWith(color: colors.textBase),- ),- ),- GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () => Navigator.pop(context),- child: Container(- width: 36,- height: 36,- decoration: BoxDecoration(- color: colors.fillLight,- shape: BoxShape.circle,- ),- child: Icon(Icons.close, color: colors.textLightest, size: 20),- ),+ }+ : null,+ ),+ if (widget.canRemovePhoto) ...[+ const SizedBox(height: Spacing.md),+ ButtonComponent(+ label: l10n.removeContactPhoto,+ variant: ButtonComponentVariant.secondary,+ shouldSurfaceExecutionStates: false,+ onTap: () {+ Navigator.pop(+ context,+ const ContactPhotoPickerRemove(),+ );+ },+ ),+ ],+ ],+ );+ },),],),