fix: migrate filter menus to type-safe generics and harden popup dismissal

- Move ContactSortOption/ContactTypeFilter enums to dedicated
  contact_filter_types.dart (re-exported from contact_search.dart)
- Migrate ContactsFilterMenu and DiscoveryContactsFilterMenu to use
  sealed class action types with SortFilterMenu<T> generics, replacing
  int action constants and switch statements
- Guard _closeDropdownAndRun with ModalRoute.isCurrent check to prevent
  accidental dismissal of parent routes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
zjs81
2026-03-14 17:59:48 -07:00
parent 86e9b7fe01
commit 566e3aadf8
4 changed files with 66 additions and 78 deletions
+5 -2
View File
@@ -454,8 +454,11 @@ class _ContactsScreenState extends State<ContactsScreen>
}
}
void _closeDropdownAndRun(BuildContext context, VoidCallback action) {
Navigator.of(context).pop();
void _closeDropdownAndRun(BuildContext popupContext, VoidCallback action) {
final route = ModalRoute.of(popupContext);
if (route != null && route.isCurrent) {
Navigator.of(popupContext).pop();
}
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted) return;
action();