Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

sort option in more places

laurenspriemcbff7e6418d0
diff --git a/mobile/apps/photos/lib/ui/viewer/people/add_files_to_person_page.dart b/mobile/apps/photos/lib/ui/viewer/people/add_files_to_person_page.dart
index b163a2e42c..a2ca60ad3b 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/add_files_to_person_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/add_files_to_person_page.dart
@@ -1,19 +1,29 @@
+import "dart:async";
+
import "package:flutter/material.dart";
import "package:logging/logging.dart";
+import "package:photos/core/event_bus.dart";
+import "package:photos/events/people_sort_order_change_event.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/models/file/file.dart";
import "package:photos/models/search/generic_search_result.dart";
import "package:photos/models/search/search_constants.dart";
+import "package:photos/service_locator.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/search_service.dart";
+import "package:photos/theme/colors.dart";
import "package:photos/theme/ente_theme.dart";
+import "package:photos/theme/text_style.dart";
import "package:photos/ui/common/loading_widget.dart";
+import "package:photos/ui/components/buttons/icon_button_widget.dart";
import "package:photos/ui/components/searchable_appbar.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/dialog_util.dart";
+import "package:photos/utils/local_settings.dart";
+import "package:photos/utils/people_sort_util.dart";
class AddFilesToPersonPage extends StatefulWidget {
final List<EnteFile> files;
@@ -82,11 +92,23 @@ class AddFilesToPersonPage extends StatefulWidget {
class _AddFilesToPersonPageState extends State<AddFilesToPersonPage> {
late Future<List<GenericSearchResult>> _personsFuture;
String _searchQuery = "";
+ late PeopleSortKey _sortKey;
+ bool _nameSortAscending = true;
+ bool _updatedSortAscending = false;
+ bool _photosSortAscending = false;
+
+ static const double _sortMenuItemHeight = 52;
+ static const double _sortMenuCornerRadius = 12;
@override
void initState() {
super.initState();
assert(widget.files.isNotEmpty);
+ final settings = localSettings;
+ _sortKey = settings.peopleSortKey();
+ _nameSortAscending = settings.peopleNameSortAscending;
+ _updatedSortAscending = settings.peopleUpdatedSortAscending;
+ _photosSortAscending = settings.peoplePhotosSortAscending;
_personsFuture = widget.initialPersons != null
? Future.value(widget.initialPersons!)
: AddFilesToPersonPage.loadNamedPersons();
@@ -118,9 +140,62 @@ class _AddFilesToPersonPageState extends State<AddFilesToPersonPage> {
}
}
+ bool _isSortAscending(PeopleSortKey key) {
+ switch (key) {
+ case PeopleSortKey.name:
+ return _nameSortAscending;
+ case PeopleSortKey.lastUpdated:
+ return _updatedSortAscending;
+ case PeopleSortKey.mostPhotos:
+ return _photosSortAscending;
+ }
+ }
+
+ bool _toggleSortDirection(PeopleSortKey key) {
+ switch (key) {
+ case PeopleSortKey.name:
+ _nameSortAscending = !_nameSortAscending;
+ return true;
+ case PeopleSortKey.lastUpdated:
+ _updatedSortAscending = !_updatedSortAscending;
+ return true;
+ case PeopleSortKey.mostPhotos:
+ _photosSortAscending = !_photosSortAscending;
+ return true;
+ }
+ }
+
+ bool _canToggleSortDirection(PeopleSortKey key) {
+ return key == PeopleSortKey.name ||
+ key == PeopleSortKey.lastUpdated ||
+ key == PeopleSortKey.mostPhotos;
+ }
+
+ void _sortFaces(List<GenericSearchResult> faces) {
+ sortPeopleFaces(
+ faces,
+ PeopleSortConfig(
+ sortKey: _sortKey,
+ nameSortAscending: _nameSortAscending,
+ updatedSortAscending: _updatedSortAscending,
+ photosSortAscending: _photosSortAscending,
+ ),
+ );
+ }
+
+ Future<void> _persistSortPreferences() async {
+ await localSettings.setPeopleSortKey(_sortKey);
+ await localSettings.setPeopleNameSortAscending(_nameSortAscending);
+ await localSettings.setPeopleUpdatedSortAscending(_updatedSortAscending);
+ await localSettings.setPeoplePhotosSortAscending(_photosSortAscending);
+ Bus.instance.fire(PeopleSortOrderChangeEvent());
+ }
+
@override
Widget build(BuildContext context) {
- final smallFontSize = getEnteTextTheme(context).small.fontSize!;
+ final textTheme = getEnteTextTheme(context);
+ final colorScheme = getEnteColorScheme(context);
+ final smallFontSize = textTheme.small.fontSize!;
final textScaleFactor =
MediaQuery.textScalerOf(context).scale(smallFontSize) / smallFontSize;
final textHeight = 24 * textScaleFactor;
@@ -143,6 +218,12 @@ class _AddFilesToPersonPageState extends State<AddFilesToPersonPage> {
horizontalEdgePadding,
12,
),
+ actions: [
+ Padding(
+ padding: const EdgeInsets.only(right: horizontalEdgePadding),
+ child: _buildSortMenu(context, textTheme, colorScheme),
+ ),
+ ],
),
];
if (snapshot.connectionState == ConnectionState.waiting) {
@@ -167,7 +248,9 @@ class _AddFilesToPersonPageState extends State<AddFilesToPersonPage> {
}
final persons = snapshot.data ?? [];
- final results = _filterPersons(persons);
+ final sortedPersons = [...persons];
+ _sortFaces(sortedPersons);
+ final results = _filterPersons(sortedPersons);
if (results.isEmpty) {
slivers.add(
SliverFillRemaining(
@@ -206,7 +289,12 @@ class _AddFilesToPersonPageState extends State<AddFilesToPersonPage> {
childCount: results.length,
(context, index) {
final person = results[index];
+ final personId = person.params[kPersonParamID] as String?;
+ final personKey = personId != null && personId.isNotEmpty
+ ? personId
+ : person.name();
return _ManualPersonGridTile(
+ key: ValueKey(personKey),
result: person,
size: itemSize,
labelHeight: textHeight,
@@ -223,6 +311,166 @@ class _AddFilesToPersonPageState extends State<AddFilesToPersonPage> {
);
}
+ Widget _buildSortMenu(
+ BuildContext context,
+ EnteTextTheme textTheme,
+ EnteColorScheme colorScheme,
+ ) {
+ return Theme(
+ data: Theme.of(context).copyWith(
+ highlightColor: Colors.transparent,
+ splashColor: Colors.transparent,
+ ),
+ child: GestureDetector(
+ onTapDown: (TapDownDetails details) async {
+ final l10n = AppLocalizations.of(context);
+ const sortKeys = PeopleSortKey.values;
+ final PeopleSortKey? selectedKey = await showMenu<PeopleSortKey>(
+ color: colorScheme.backgroundElevated,
+ context: context,
+ elevation: 0,
+ shape: RoundedRectangleBorder(
+ side: BorderSide(
+ width: 0.5,
+ color: colorScheme.strokeFaint,
+ ),
+ borderRadius: BorderRadius.circular(_sortMenuCornerRadius),
+ ),
+ position: RelativeRect.fromLTRB(
+ details.globalPosition.dx,
+ details.globalPosition.dy,
+ details.globalPosition.dx,
+ details.globalPosition.dy + 50,
+ ),
+ items: List.generate(sortKeys.length, (index) {
+ final key = sortKeys[index];
+ return _buildSortMenuItem(
+ key,
+ index == sortKeys.length - 1,
+ textTheme,
+ colorScheme,
+ l10n,
+ );
+ }),
+ );
+ if (!mounted || selectedKey == null) {
+ return;
+ }
+ if (selectedKey == _sortKey &&
+ !_canToggleSortDirection(selectedKey)) {
+ return;
+ }
+ setState(() {
+ if (selectedKey == _sortKey) {
+ _toggleSortDirection(selectedKey);
+ } else {
+ _sortKey = selectedKey;
+ }
+ });
+ unawaited(_persistSortPreferences());
+ },
+ child: IconButtonWidget(
+ icon: Icons.sort_rounded,
+ iconButtonType: IconButtonType.secondary,
+ iconColor: colorScheme.textMuted,
+ ),
+ ),
+ );
+ }
+
+ PopupMenuItem<PeopleSortKey> _buildSortMenuItem(
+ PeopleSortKey key,
+ bool isLast,
+ EnteTextTheme textTheme,
+ EnteColorScheme colorScheme,
+ AppLocalizations l10n,
+ ) {
+ String label;
+ switch (key) {
+ case PeopleSortKey.mostPhotos:
+ label = l10n.photos;
+ break;
+ case PeopleSortKey.name:
+ label = l10n.name;
+ break;
+ case PeopleSortKey.lastUpdated:
+ label = l10n.updated;
+ break;
+ }
+
+ String detail;
+ switch (key) {
+ case PeopleSortKey.mostPhotos:
+ detail = l10n.count;
+ break;
+ case PeopleSortKey.name:
+ detail = _isSortAscending(key) ? "A-Z" : "Z-A";
+ break;
+ case PeopleSortKey.lastUpdated:
+ detail =
+ _isSortAscending(key) ? l10n.sortOldestFirst : l10n.sortNewestFirst;
+ break;
+ }
+
+ final bool isSelected = _sortKey == key;
+ final bool isAscending = _isSortAscending(key);
+ final IconData directionIcon = key == PeopleSortKey.name
+ ? (isAscending ? Icons.arrow_downward : Icons.arrow_upward)
+ : (isAscending ? Icons.arrow_upward : Icons.arrow_downward);
+
+ return PopupMenuItem<PeopleSortKey>(
+ value: key,
+ padding: EdgeInsets.zero,
+ height: _sortMenuItemHeight,
+ child: Container(
+ width: double.infinity,
+ height: _sortMenuItemHeight,
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ decoration: BoxDecoration(
+ border: isLast
+ ? null
+ : Border(
+ bottom: BorderSide(
+ width: 0.5,
+ color: colorScheme.strokeFaint,
+ ),
+ ),
+ ),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ Text(
+ label,
+ style: textTheme.mini,
+ ),
+ if (isSelected) ...[
+ const SizedBox(width: 8),
+ Container(
+ width: 4,
+ height: 4,
+ decoration: BoxDecoration(
+ color: colorScheme.textMuted.withValues(alpha: 0.6),
+ shape: BoxShape.circle,
+ ),
+ ),
+ const SizedBox(width: 6),
+ Text(
+ detail,
+ style: textTheme.miniMuted,
+ ),
+ const SizedBox(width: 4),
+ Icon(
+ directionIcon,
+ size: 16,
+ color: colorScheme.textMuted,
+ ),
+ ],
+ ],
+ ),
+ ),
+ );
+ }
+
Future<void> _onPersonSelected(GenericSearchResult result) async {
final personId = result.params[kPersonParamID] as String?;
if (personId == null || personId.isEmpty) {
@@ -274,6 +522,7 @@ class _ManualPersonGridTile extends StatelessWidget {
final VoidCallback onTap;
const _ManualPersonGridTile({
+ super.key,
required this.result,
required this.size,
required this.labelHeight,
diff --git a/mobile/apps/photos/lib/ui/viewer/people/person_selection_action_widgets.dart b/mobile/apps/photos/lib/ui/viewer/people/person_selection_action_widgets.dart
index d90b03580a..fe1376b398 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/person_selection_action_widgets.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/person_selection_action_widgets.dart
@@ -5,14 +5,23 @@ import "package:logging/logging.dart";
import "package:photos/core/configuration.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/events/people_changed_event.dart";
+import "package:photos/events/people_sort_order_change_event.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/l10n/l10n.dart";
import "package:photos/models/ml/face/person.dart";
+import "package:photos/models/search/generic_search_result.dart";
+import "package:photos/models/search/search_constants.dart";
import "package:photos/models/typedefs.dart";
+import "package:photos/service_locator.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/search_service.dart";
+import "package:photos/theme/colors.dart";
import "package:photos/theme/ente_theme.dart";
+import "package:photos/theme/text_style.dart";
import "package:photos/ui/common/loading_widget.dart";
import "package:photos/ui/components/buttons/button_widget.dart";
+import "package:photos/ui/components/buttons/icon_button_widget.dart";
import "package:photos/ui/components/dialog_widget.dart";
import "package:photos/ui/components/models/button_type.dart";
import "package:photos/ui/components/searchable_appbar.dart";
@@ -20,6 +29,8 @@ 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/dialog_util.dart";
+import "package:photos/utils/local_settings.dart";
+import "package:photos/utils/people_sort_util.dart";
import "package:photos/utils/person_contact_linking_util.dart";
class LinkContactToPersonSelectionPage extends StatefulWidget {
@@ -36,34 +47,74 @@ class LinkContactToPersonSelectionPage extends StatefulWidget {
class _LinkContactToPersonSelectionPageState
extends State<LinkContactToPersonSelectionPage> {
- late Future<List<PersonEntity>> _personEntities;
+ late Future<List<_PersonSelectionEntry>> _personEntries;
String _searchQuery = "";
final _logger = Logger('LinkContactToPersonSelectionPage');
+ late PeopleSortKey _sortKey;
+ bool _nameSortAscending = true;
+ bool _updatedSortAscending = false;
+ bool _photosSortAscending = false;
+
+ static const double _sortMenuItemHeight = 52;
+ static const double _sortMenuCornerRadius = 12;
@override
void initState() {
super.initState();
- _personEntities = PersonService.instance.getPersons().then((persons) async {
- final List<PersonEntity> result = [];
- for (final person in persons) {
- if ((person.data.email != null && person.data.email!.isNotEmpty) ||
- (person.data.isIgnored)) {
- continue;
- }
- result.add(person);
+ final settings = localSettings;
+ _sortKey = settings.peopleSortKey();
+ _nameSortAscending = settings.peopleNameSortAscending;
+ _updatedSortAscending = settings.peopleUpdatedSortAscending;
+ _photosSortAscending = settings.peoplePhotosSortAscending;
+ _personEntries = _loadPersonEntries();
+ }
+
+ Future<List<_PersonSelectionEntry>> _loadPersonEntries() async {
+ final persons = await PersonService.instance.getPersons();
+ final results = await SearchService.instance
+ .getAllFace(null, minClusterSize: kMinimumClusterSizeAllFaces);
+ final resultsById = <String, GenericSearchResult>{};
+ for (final result in results) {
+ final personId = result.params[kPersonParamID] as String?;
+ if (personId == null || personId.isEmpty) {
+ continue;
}
- return result;
- });
+ resultsById[personId] = result;
+ }
+
+ final entries = <_PersonSelectionEntry>[];
+ for (final person in persons) {
+ if ((person.data.email != null && person.data.email!.isNotEmpty) ||
+ person.data.isIgnored) {
+ continue;
+ }
+ final searchResult = resultsById[person.remoteID];
+ if (searchResult == null) {
+ continue;
+ }
+ entries.add(
+ _PersonSelectionEntry(
+ personEntity: person,
+ searchResult: searchResult,
+ ),
+ );
+ }
+ return entries;
}
- List<PersonEntity> _filterPersons(List<PersonEntity> persons) {
+ List<_PersonSelectionEntry> _filterPersons(
+ List<_PersonSelectionEntry> persons,
+ ) {
final query = _searchQuery.trim().toLowerCase();
if (query.isEmpty) {
return persons;
}
return persons
- .where((person) => person.data.name.toLowerCase().contains(query))
+ .where(
+ (person) =>
+ person.personEntity.data.name.toLowerCase().contains(query),
+ )
.toList();
}
@@ -81,17 +132,98 @@ class _LinkContactToPersonSelectionPageState
}
}
+ bool _isSortAscending(PeopleSortKey key) {
+ switch (key) {
+ case PeopleSortKey.name:
+ return _nameSortAscending;
+ case PeopleSortKey.lastUpdated:
+ return _updatedSortAscending;
+ case PeopleSortKey.mostPhotos:
+ return _photosSortAscending;
+ }
+ }
+
+ bool _toggleSortDirection(PeopleSortKey key) {
+ switch (key) {
+ case PeopleSortKey.name:
+ _nameSortAscending = !_nameSortAscending;
+ return true;
+ case PeopleSortKey.lastUpdated:
+ _updatedSortAscending = !_updatedSortAscending;
+ return true;
+ case PeopleSortKey.mostPhotos:
+ _photosSortAscending = !_photosSortAscending;
+ return true;
+ }
+ }
+
+ bool _canToggleSortDirection(PeopleSortKey key) {
+ return key == PeopleSortKey.name ||
+ key == PeopleSortKey.lastUpdated ||
+ key == PeopleSortKey.mostPhotos;
+ }
+
+ void _sortFaces(List<GenericSearchResult> faces) {
+ sortPeopleFaces(
+ faces,
+ PeopleSortConfig(
+ sortKey: _sortKey,
+ nameSortAscending: _nameSortAscending,
+ updatedSortAscending: _updatedSortAscending,
+ photosSortAscending: _photosSortAscending,
+ ),
+ );
+ }
+
+ Future<void> _persistSortPreferences() async {
+ await localSettings.setPeopleSortKey(_sortKey);
+ await localSettings.setPeopleNameSortAscending(_nameSortAscending);
+ await localSettings.setPeopleUpdatedSortAscending(_updatedSortAscending);
+ await localSettings.setPeoplePhotosSortAscending(_photosSortAscending);
+ Bus.instance.fire(PeopleSortOrderChangeEvent());
+ }
+
+ List<_PersonSelectionEntry> _sortEntries(
+ List<_PersonSelectionEntry> entries,
+ ) {
+ if (entries.isEmpty) {
+ return entries;
+ }
+ final results = entries.map((entry) => entry.searchResult).toList();
+ _sortFaces(results);
+ final entryById = <String, _PersonSelectionEntry>{};
+ for (final entry in entries) {
+ final personId = entry.searchResult.params[kPersonParamID] as String?;
+ if (personId == null || personId.isEmpty) {
+ continue;
+ }
+ entryById[personId] = entry;
+ }
+ return results
+ .map((result) {
+ final personId = result.params[kPersonParamID] as String?;
+ if (personId == null) {
+ return null;
+ }
+ return entryById[personId];
+ })
+ .whereType<_PersonSelectionEntry>()
+ .toList();
+ }
+
@override
Widget build(BuildContext context) {
_logger.info("Building LinkContactToPersonSelectionPage");
- final smallFontSize = getEnteTextTheme(context).small.fontSize!;
+ final textTheme = getEnteTextTheme(context);
+ final colorScheme = getEnteColorScheme(context);
+ final smallFontSize = textTheme.small.fontSize!;
final textScaleFactor =
MediaQuery.textScalerOf(context).scale(smallFontSize) / smallFontSize;
const horizontalEdgePadding = 20.0;
const gridPadding = 16.0;
return Scaffold(
- body: FutureBuilder<List<PersonEntity>>(
- future: _personEntities,
+ body: FutureBuilder<List<_PersonSelectionEntry>>(
+ future: _personEntries,
builder: (context, snapshot) {
final slivers = <Widget>[
SearchableAppBar(
@@ -101,6 +233,12 @@ class _LinkContactToPersonSelectionPageState
centerTitle: false,
searchIconPadding:
const EdgeInsets.fromLTRB(12, 12, horizontalEdgePadding, 12),
+ actions: [
+ Padding(
+ padding: const EdgeInsets.only(right: horizontalEdgePadding),
+ child: _buildSortMenu(context, textTheme, colorScheme),
+ ),
+ ],
),
];
if (snapshot.connectionState == ConnectionState.waiting) {
@@ -134,7 +272,8 @@ class _LinkContactToPersonSelectionPageState
return CustomScrollView(slivers: slivers);
}
- final results = _filterPersons(snapshot.data!);
+ final sortedEntries = _sortEntries(snapshot.data!);
+ final results = _filterPersons(sortedEntries);
if (results.isEmpty) {
slivers.add(
SliverFillRemaining(
@@ -174,12 +313,13 @@ class _LinkContactToPersonSelectionPageState
childCount: results.length,
(context, index) {
return _RoundedPersonFaceWidget(
+ key: ValueKey(results[index].personEntity.remoteID),
onTap: () async {
try {
final updatedPerson = await linkPersonToContact(
context,
emailToLink: widget.emailToLink!,
- personEntity: results[index],
+ personEntity: results[index].personEntity,
);
if (updatedPerson != null) {
@@ -194,7 +334,7 @@ class _LinkContactToPersonSelectionPageState
}
},
itemSize: itemSize,
- personEntity: results[index],
+ personEntity: results[index].personEntity,
);
},
),
@@ -208,6 +348,166 @@ class _LinkContactToPersonSelectionPageState
);
}
+ Widget _buildSortMenu(
+ BuildContext context,
+ EnteTextTheme textTheme,
+ EnteColorScheme colorScheme,
+ ) {
+ return Theme(
+ data: Theme.of(context).copyWith(
+ highlightColor: Colors.transparent,
+ splashColor: Colors.transparent,
+ ),
+ child: GestureDetector(
+ onTapDown: (TapDownDetails details) async {
+ final l10n = AppLocalizations.of(context);
+ const sortKeys = PeopleSortKey.values;
+ final PeopleSortKey? selectedKey = await showMenu<PeopleSortKey>(
+ color: colorScheme.backgroundElevated,
+ context: context,
+ elevation: 0,
+ shape: RoundedRectangleBorder(
+ side: BorderSide(
+ width: 0.5,
+ color: colorScheme.strokeFaint,
+ ),
+ borderRadius: BorderRadius.circular(_sortMenuCornerRadius),
+ ),
+ position: RelativeRect.fromLTRB(
+ details.globalPosition.dx,
+ details.globalPosition.dy,
+ details.globalPosition.dx,
+ details.globalPosition.dy + 50,
+ ),
+ items: List.generate(sortKeys.length, (index) {
+ final key = sortKeys[index];
+ return _buildSortMenuItem(
+ key,
+ index == sortKeys.length - 1,
+ textTheme,
+ colorScheme,
+ l10n,
+ );
+ }),
+ );
+ if (!mounted || selectedKey == null) {
+ return;
+ }
+ if (selectedKey == _sortKey &&
+ !_canToggleSortDirection(selectedKey)) {
+ return;
+ }
+ setState(() {
+ if (selectedKey == _sortKey) {
+ _toggleSortDirection(selectedKey);
+ } else {
+ _sortKey = selectedKey;
+ }
+ });
+ unawaited(_persistSortPreferences());
+ },
+ child: IconButtonWidget(
+ icon: Icons.sort_rounded,
+ iconButtonType: IconButtonType.secondary,
+ iconColor: colorScheme.textMuted,
+ ),
+ ),
+ );
+ }
+
+ PopupMenuItem<PeopleSortKey> _buildSortMenuItem(
+ PeopleSortKey key,
+ bool isLast,
+ EnteTextTheme textTheme,
+ EnteColorScheme colorScheme,
+ AppLocalizations l10n,
+ ) {
+ String label;
+ switch (key) {
+ case PeopleSortKey.mostPhotos:
+ label = l10n.photos;
+ break;
+ case PeopleSortKey.name:
+ label = l10n.name;
+ break;
+ case PeopleSortKey.lastUpdated:
+ label = l10n.updated;
+ break;
+ }
+
+ String detail;
+ switch (key) {
+ case PeopleSortKey.mostPhotos:
+ detail = l10n.count;
+ break;
+ case PeopleSortKey.name:
+ detail = _isSortAscending(key) ? "A-Z" : "Z-A";
+ break;
+ case PeopleSortKey.lastUpdated:
+ detail =
+ _isSortAscending(key) ? l10n.sortOldestFirst : l10n.sortNewestFirst;
+ break;
+ }
+
+ final bool isSelected = _sortKey == key;
+ final bool isAscending = _isSortAscending(key);
+ final IconData directionIcon = key == PeopleSortKey.name
+ ? (isAscending ? Icons.arrow_downward : Icons.arrow_upward)
+ : (isAscending ? Icons.arrow_upward : Icons.arrow_downward);
+
+ return PopupMenuItem<PeopleSortKey>(
+ value: key,
+ padding: EdgeInsets.zero,
+ height: _sortMenuItemHeight,
+ child: Container(
+ width: double.infinity,
+ height: _sortMenuItemHeight,
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ decoration: BoxDecoration(
+ border: isLast
+ ? null
+ : Border(
+ bottom: BorderSide(
+ width: 0.5,
+ color: colorScheme.strokeFaint,
+ ),
+ ),
+ ),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ Text(
+ label,
+ style: textTheme.mini,
+ ),
+ if (isSelected) ...[
+ const SizedBox(width: 8),
+ Container(
+ width: 4,
+ height: 4,
+ decoration: BoxDecoration(
+ color: colorScheme.textMuted.withValues(alpha: 0.6),
+ shape: BoxShape.circle,
+ ),
+ ),
+ const SizedBox(width: 6),
+ Text(
+ detail,
+ style: textTheme.miniMuted,
+ ),
+ const SizedBox(width: 4),
+ Icon(
+ directionIcon,
+ size: 16,
+ color: colorScheme.textMuted,
+ ),
+ ],
+ ],
+ ),
+ ),
+ );
+ }
+
Future<PersonEntity?> linkPersonToContact(
BuildContext context, {
required String emailToLink,
@@ -267,6 +567,16 @@ class _LinkContactToPersonSelectionPageState
}
}
+class _PersonSelectionEntry {
+ final PersonEntity personEntity;
+ final GenericSearchResult searchResult;
+
+ const _PersonSelectionEntry({
+ required this.personEntity,
+ required this.searchResult,
+ });
+}
+
class ReassignMeSelectionPage extends StatefulWidget {
final String currentMeId;
const ReassignMeSelectionPage({
@@ -434,6 +744,7 @@ class _RoundedPersonFaceWidget extends StatelessWidget {
final PersonEntity personEntity;
const _RoundedPersonFaceWidget({
+ super.key,
required this.onTap,
required this.itemSize,
required this.personEntity,