Merge remote-tracking branch 'origin/dev' into contacts-full-warning

# Conflicts:
#	lib/connector/meshcore_connector.dart
#	lib/connector/meshcore_protocol.dart
#	lib/screens/contacts_screen.dart
This commit is contained in:
zjs81 committed 2026-09-27 12:16:35 -07:00
commit 8076a48816
237 files changed
+51365 -4993

No files matched your search

+116 -30
View File
@@ -34,6 +34,7 @@ import '../widgets/unread_badge.dart';
import '../helpers/snack_bar_builder.dart';
import 'channels_screen.dart';
import 'chat_screen.dart';
import 'contact_qr_scanner_screen.dart';
import 'discovery_screen.dart';
import 'map_screen.dart';
import 'repeater_hub_screen.dart';
@@ -185,6 +186,14 @@ class _ContactsScreenState extends State<ContactsScreen>
}
final hexString = pubKeyToHex(advertPacket);
Clipboard.setData(ClipboardData(text: "meshcore://$hexString"));
_pendingOperations.remove(ContactOperationType.export);
if (mounted) {
showDismissibleSnackBar(
context,
content: Text(context.l10n.contacts_contactAdvertCopied),
);
}
return;
}
// Generic OK/ERR acks carry no command correlation, so consume only
@@ -376,6 +385,21 @@ class _ContactsScreenState extends State<ContactsScreen>
),
onTap: () => _contactImport(),
),
PopupMenuItem(
child: Row(
children: [
const Icon(Icons.qr_code_scanner),
const SizedBox(width: 8),
Text(context.l10n.contacts_scanQrCode),
],
),
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ContactQrScannerScreen(),
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
child: Row(
@@ -488,6 +512,19 @@ class _ContactsScreenState extends State<ContactsScreen>
_contactImport();
},
),
ListTile(
leading: const Icon(Icons.qr_code_scanner),
title: Text(context.l10n.contacts_scanQrCode),
onTap: () {
Navigator.pop(sheetContext);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ContactQrScannerScreen(),
),
);
},
),
ListTile(
leading: const Icon(Icons.person_add_rounded),
title: Text(context.l10n.discoveredContacts_Title),
@@ -704,7 +741,7 @@ class _ContactsScreenState extends State<ContactsScreen>
return EmptyState(
icon: Icons.people_outline,
title: context.l10n.contacts_noContacts,
subtitle: context.l10n.contacts_contactsWillAppear,
subtitle: context.l10n.contacts_noContactsDiscoveredHint,
action: FilledButton.icon(
onPressed: () => Navigator.push(
context,
@@ -882,7 +919,7 @@ class _ContactsScreenState extends State<ContactsScreen>
],
),
),
if (connector.contactsFull)
if (connector.contactsStorageFull)
Container(
width: double.infinity,
color: Theme.of(context).colorScheme.errorContainer,
@@ -907,6 +944,20 @@ class _ContactsScreenState extends State<ContactsScreen>
],
),
),
ListTile(
dense: true,
leading: const Icon(Icons.person_add_rounded),
title: Text(
context.l10n.contacts_discoveredNearby(
connector.discoveredContacts.where((c) => !c.isActive).length,
),
),
trailing: const Icon(Icons.chevron_right),
onTap: () => Navigator.push(
context,
MaterialPageRoute(builder: (context) => const DiscoveryScreen()),
),
),
Expanded(
child: RefreshIndicator(
onRefresh: () => connector.getContacts(),
@@ -947,6 +998,7 @@ class _ContactsScreenState extends State<ContactsScreen>
onTap: () => _openChat(context, contact),
onLongPress: () =>
_showContactOptions(context, connector, contact),
onManage: _manageAction(context, contact),
);
},
),
@@ -1072,6 +1124,17 @@ class _ContactsScreenState extends State<ContactsScreen>
}
}
VoidCallback? _manageAction(BuildContext context, Contact contact) {
if (contact.type == advTypeRepeater) {
return () => _showRepeaterLogin(context, contact);
}
if (contact.type == advTypeRoom) {
return () =>
_showRoomLogin(context, contact, RoomLoginDestination.management);
}
return null;
}
void _handleQuickSwitch(int index, BuildContext context) {
if (index == 0) return;
switch (index) {
@@ -1530,7 +1593,7 @@ class _ContactsScreenState extends State<ContactsScreen>
color: Theme.of(context).colorScheme.error,
),
title: Text(
context.l10n.contacts_deleteContact,
context.l10n.contacts_removeFromContacts,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
onTap: () {
@@ -1560,27 +1623,46 @@ class _ContactsScreenState extends State<ContactsScreen>
MeshCoreConnector connector,
Contact contact,
) {
var keepHistory = false;
showDialog(
context: context,
builder: (dialogContext) => AlertDialog(
title: Text(context.l10n.contacts_deleteContact),
content: Text(context.l10n.contacts_removeConfirm(contact.name)),
actions: [
TextButton(
onPressed: () => Navigator.pop(dialogContext),
child: Text(context.l10n.common_cancel),
builder: (dialogContext) => StatefulBuilder(
builder: (dialogContext, setDialogState) => AlertDialog(
title: Text(context.l10n.contacts_removeFromContacts),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
context.l10n.contacts_removeFromContactsConfirm(contact.name),
),
CheckboxListTile(
contentPadding: EdgeInsets.zero,
controlAffinity: ListTileControlAffinity.leading,
value: keepHistory,
title: Text(context.l10n.contacts_keepChatHistory),
onChanged: (value) =>
setDialogState(() => keepHistory = value ?? false),
),
],
),
TextButton(
onPressed: () {
Navigator.pop(dialogContext);
connector.removeContact(contact);
},
child: Text(
context.l10n.common_delete,
style: TextStyle(color: Theme.of(context).colorScheme.error),
actions: [
TextButton(
onPressed: () => Navigator.pop(dialogContext),
child: Text(context.l10n.common_cancel),
),
),
],
TextButton(
onPressed: () {
Navigator.pop(dialogContext);
connector.removeContact(contact, keepMessages: keepHistory);
},
child: Text(
context.l10n.contacts_remove,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
),
],
),
),
);
}
@@ -1594,6 +1676,7 @@ class _ContactTile extends StatelessWidget {
final bool isFavorite;
final VoidCallback onTap;
final VoidCallback onLongPress;
final VoidCallback? onManage;
const _ContactTile({
required this.contact,
@@ -1603,6 +1686,7 @@ class _ContactTile extends StatelessWidget {
required this.isFavorite,
required this.onTap,
required this.onLongPress,
this.onManage,
});
/// Node-type avatar color per design language.
@@ -1639,9 +1723,6 @@ class _ContactTile extends StatelessWidget {
final scheme = Theme.of(context).colorScheme;
final emoji = firstEmoji(contact.name);
final isChat = contact.type == advTypeChat;
final pathLen = contact.pathBytesForDisplay.length;
final isDirect = contact.pathLength >= 0;
final hasPath = pathLen > 0 || contact.pathLength == 0;
return GestureDetector(
onSecondaryTapUp: PlatformInfo.isDesktop ? (_) => onLongPress() : null,
@@ -1729,13 +1810,6 @@ class _ContactTile extends StatelessWidget {
),
),
),
if (hasPath) ...[
const SizedBox(width: 6),
RouteChip(
isDirect: isDirect,
hops: isDirect ? contact.pathLength : null,
),
],
],
),
],
@@ -1774,6 +1848,15 @@ class _ContactTile extends StatelessWidget {
],
),
),
if (onManage != null)
IconButton(
icon: const Icon(Icons.admin_panel_settings_outlined),
tooltip: contact.type == advTypeRoom
? context.l10n.room_management
: context.l10n.contacts_manageRepeater,
visualDensity: VisualDensity.compact,
onPressed: onManage,
),
],
),
),
@@ -1813,6 +1896,7 @@ class _ContactTileEntrance extends StatelessWidget {
final bool isFavorite;
final VoidCallback onTap;
final VoidCallback onLongPress;
final VoidCallback? onManage;
const _ContactTileEntrance({
required this.index,
@@ -1823,6 +1907,7 @@ class _ContactTileEntrance extends StatelessWidget {
required this.isFavorite,
required this.onTap,
required this.onLongPress,
this.onManage,
});
@override
@@ -1837,6 +1922,7 @@ class _ContactTileEntrance extends StatelessWidget {
isFavorite: isFavorite,
onTap: onTap,
onLongPress: onLongPress,
onManage: onManage,
),
);
}