π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add save to person button to old suggestions flow
laurenspriem08b92cc56053
diff --git a/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart b/mobile/lib/ui/viewer/people/person_cluster_suggestion.dartindex e16d54d274..c7638b6223 100644--- a/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart+++ b/mobile/lib/ui/viewer/people/person_cluster_suggestion.dart@@ -21,6 +21,7 @@ import "package:photos/ui/components/models/button_type.dart";import "package:photos/ui/viewer/people/cluster_page.dart";import "package:photos/ui/viewer/people/file_face_widget.dart";import "package:photos/ui/viewer/people/person_clusters_page.dart";+import "package:photos/ui/viewer/people/save_or_edit_person.dart";import "package:photos/utils/face/face_thumbnail_cache.dart";class SuggestionUserFeedback {@@ -190,36 +191,60 @@ class _PersonClustersState extends State<PersonReviewClusterSuggestion> {right: 12.0,bottom: 48,),- child: Row(- children: <Widget>[- Expanded(- child: ButtonWidget(- buttonType: ButtonType.tertiaryCritical,- icon: Icons.close,- labelText: context.l10n.no,- buttonSize: ButtonSize.large,- onTap: () async => {- await _handleUserClusterChoice(- clusterID,- false,- numberOfDifferentSuggestions,+ child: Column(+ children: [+ Row(+ children: <Widget>[+ Expanded(+ child: ButtonWidget(+ buttonType: ButtonType.tertiaryCritical,+ icon: Icons.close,+ labelText: context.l10n.no,+ buttonSize: ButtonSize.large,+ onTap: () async => {+ await _handleUserClusterChoice(+ clusterID,+ false,+ numberOfDifferentSuggestions,+ ),+ },),- },- ),- ),- const SizedBox(width: 12.0),- Expanded(- child: ButtonWidget(- buttonType: ButtonType.primary,- labelText: context.l10n.yes,- buttonSize: ButtonSize.large,- onTap: () async => {- await _handleUserClusterChoice(- clusterID,- true,- numberOfDifferentSuggestions,+ ),+ const SizedBox(width: 12.0),+ Expanded(+ child: ButtonWidget(+ buttonType: ButtonType.primary,+ labelText: context.l10n.yes,+ buttonSize: ButtonSize.large,+ onTap: () async => {+ await _handleUserClusterChoice(+ clusterID,+ true,+ numberOfDifferentSuggestions,+ ),+ },),- },+ ),+ ],+ ),+ const SizedBox(height: 12),+ GestureDetector(+ onTap: canGiveFeedback+ ? () => _saveAsAnotherPerson()+ : null,+ child: Padding(+ padding: const EdgeInsets.symmetric(+ vertical: 8,+ horizontal: 16,+ ),+ child: Text(+ S.of(context).saveAsAnotherPerson,+ style: getEnteTextTheme(context).mini.copyWith(+ color:+ getEnteColorScheme(context).textMuted,+ decoration: TextDecoration.underline,+ ),+ ),),),],@@ -307,6 +332,48 @@ class _PersonClustersState extends State<PersonReviewClusterSuggestion> {});}+ Future<void> _saveAsAnotherPerson() async {+ if (!canGiveFeedback ||+ allSuggestions.isEmpty ||+ currentSuggestionIndex >= allSuggestions.length) return;++ try {+ final currentSuggestion = allSuggestions[currentSuggestionIndex];+ final clusterID = currentSuggestion.clusterIDToMerge;+ final someFile = currentSuggestion.filesInCluster.first;++ final result = await Navigator.of(context).push(+ MaterialPageRoute(+ builder: (context) => SaveOrEditPerson(+ clusterID,+ file: someFile,+ isEditing: false,+ ),+ ),+ );+ if (result == null || result == false) {+ return;+ }+ if (mounted) {+ setState(() => currentSuggestionIndex++);+ }+ final numberOfSuggestions = allSuggestions.length;+ if (currentSuggestionIndex >= numberOfSuggestions) {+ setState(() {+ currentSuggestionIndex = 0;+ futureBuilderKeySuggestions = UniqueKey();+ futureBuilderKeyFaceThumbnails = UniqueKey();+ _fetchClusterSuggestions();+ });+ } else {+ futureBuilderKeyFaceThumbnails = UniqueKey();+ setState(() {});+ }+ } catch (e, s) {+ _logger.severe("Error saving as another person", e, s);+ }+ }+// Method to fetch cluster suggestionsvoid _fetchClusterSuggestions() {debugPrint("Fetching suggestions for ${widget.person.data.name}");