Merge upstream/dev (22 commits) [upstream-sync]
Conflicts resolved by hand, our fork changes carried over: - MainActivity.kt: keep the unread widget hooks next to upstream's scroll capture (attach and detach both). - app_settings_screen.dart: upstream wrapped the list in MeshSettingsTileTheme; image-message and translation sections stay gated on kOnDeviceMl (ML-free build). - channel_chat_screen.dart: upstream split build() into methods; took theirs and re-applied the terminal-theme list padding. - chat_composer.dart: both imports (terminal_theme, radio_guard). - mesh_nav_tile.dart: upstream's meshTileTitleStyle, with the smaller terminal-theme title kept. flutter analyze clean, flutter test 1522 passed (CI image, local). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
185d2aca53
210 files changed
+52066
-5541
No files matched your search
+236
-202
@@ -4,6 +4,7 @@ import 'dart:math' as math;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:meshcore_open/screens/path_trace_map.dart';
|
||||
import 'package:meshcore_open/screens/manual_path_trace_screen.dart';
|
||||
import 'package:meshcore_open/services/notification_service.dart';
|
||||
import 'package:meshcore_open/utils/app_logger.dart';
|
||||
import 'package:meshcore_open/utils/platform_info.dart';
|
||||
@@ -21,8 +22,8 @@ import '../theme/mesh_theme.dart';
|
||||
import '../theme/terminal_theme.dart';
|
||||
import '../utils/contact_search.dart';
|
||||
import '../storage/contact_group_store.dart';
|
||||
import '../utils/dialog_utils.dart';
|
||||
import '../utils/disconnect_navigation_mixin.dart';
|
||||
import '../widgets/connect_sheet.dart';
|
||||
import '../utils/radio_guard.dart';
|
||||
import '../utils/emoji_utils.dart';
|
||||
import '../utils/route_transitions.dart';
|
||||
import '../widgets/contact_visuals.dart';
|
||||
@@ -34,6 +35,7 @@ import '../widgets/repeater_login_dialog.dart';
|
||||
import '../widgets/room_login_dialog.dart';
|
||||
import '../widgets/sync_progress_overlay.dart';
|
||||
import '../widgets/unread_badge.dart';
|
||||
import '../helpers/contact_share_message.dart';
|
||||
import '../helpers/snack_bar_builder.dart';
|
||||
import 'channels_screen.dart';
|
||||
import 'chat_screen.dart';
|
||||
@@ -69,8 +71,7 @@ class ContactsScreen extends StatefulWidget {
|
||||
State<ContactsScreen> createState() => _ContactsScreenState();
|
||||
}
|
||||
|
||||
class _ContactsScreenState extends State<ContactsScreen>
|
||||
with DisconnectNavigationMixin {
|
||||
class _ContactsScreenState extends State<ContactsScreen> {
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
final ContactGroupStore _groupStore = ContactGroupStore();
|
||||
MeshCoreConnector? _scopeSyncConnector;
|
||||
@@ -204,7 +205,7 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
}
|
||||
|
||||
Future<void> _loadGroups() async {
|
||||
final selfPublicKeyHex = context.read<MeshCoreConnector>().selfPublicKeyHex;
|
||||
final selfPublicKeyHex = context.read<MeshCoreConnector>().storageKeyHex;
|
||||
if (selfPublicKeyHex.isEmpty) {
|
||||
return;
|
||||
}
|
||||
@@ -219,7 +220,7 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
}
|
||||
|
||||
Future<void> _saveGroups() async {
|
||||
final selfPublicKeyHex = context.read<MeshCoreConnector>().selfPublicKeyHex;
|
||||
final selfPublicKeyHex = context.read<MeshCoreConnector>().storageKeyHex;
|
||||
if (selfPublicKeyHex.isEmpty) {
|
||||
return;
|
||||
}
|
||||
@@ -228,11 +229,11 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
}
|
||||
|
||||
bool _hasGroupStoreScope(MeshCoreConnector connector) {
|
||||
return connector.selfPublicKeyHex.isNotEmpty;
|
||||
return connector.storageKeyHex.isNotEmpty;
|
||||
}
|
||||
|
||||
void _syncGroupScopeIfNeeded(MeshCoreConnector connector) {
|
||||
final selfPublicKeyHex = connector.selfPublicKeyHex;
|
||||
final selfPublicKeyHex = connector.storageKeyHex;
|
||||
if (selfPublicKeyHex.isEmpty ||
|
||||
selfPublicKeyHex == _loadedGroupScopeKeyHex) {
|
||||
return;
|
||||
@@ -356,6 +357,12 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
return;
|
||||
}
|
||||
final text = clipboardData.text!.trim();
|
||||
// A contact shared in chat (`<PUBKEY:TYPE:NAME>`) copied from the bubble.
|
||||
final share = findContactShare(text);
|
||||
if (share != null && !text.startsWith('meshcore://')) {
|
||||
await _importContactShare(connector, share);
|
||||
return;
|
||||
}
|
||||
if (!text.startsWith('meshcore://')) {
|
||||
if (mounted) {
|
||||
showDismissibleSnackBar(
|
||||
@@ -393,15 +400,37 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _importContactShare(
|
||||
MeshCoreConnector connector,
|
||||
ContactShare share,
|
||||
) async {
|
||||
if (!mounted) return;
|
||||
final l10n = context.l10n;
|
||||
if (share.publicKeyHex == connector.selfPublicKeyHex) {
|
||||
showDismissibleSnackBar(context, content: Text(l10n.contactShare_isYou));
|
||||
return;
|
||||
}
|
||||
var ok = true;
|
||||
try {
|
||||
await connector.addContactFromCard(share.toScannedContact());
|
||||
} catch (e) {
|
||||
appLogger.warn('Contact share import failed: $e', tag: 'ContactsScreen');
|
||||
ok = false;
|
||||
}
|
||||
if (!mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(
|
||||
ok ? l10n.contacts_contactImported : l10n.contacts_contactImportFailed,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final connector = context.watch<MeshCoreConnector>();
|
||||
|
||||
// Auto-navigate back to scanner if disconnected
|
||||
if (!checkConnectionAndNavigate(connector)) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
final readOnly = isRadioReadOnly(connector);
|
||||
final allowBack = !connector.isConnected;
|
||||
return PopScope(
|
||||
canPop: allowBack,
|
||||
@@ -415,12 +444,9 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
tooltip: context.l10n.contacts_moreOptions,
|
||||
itemBuilder: (context) => <PopupMenuEntry<dynamic>>[
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.person_add_rounded),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.discoveredContacts_Title),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.person_add_rounded,
|
||||
label: context.l10n.discoveredContacts_Title,
|
||||
),
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
@@ -430,22 +456,18 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.paste),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.contacts_addContactFromClipboard),
|
||||
],
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.paste,
|
||||
label: context.l10n.contacts_addContactFromClipboard,
|
||||
),
|
||||
onTap: () => _contactImport(),
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.qr_code_scanner),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.contacts_scanQrCode),
|
||||
],
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.qr_code_scanner,
|
||||
label: context.l10n.contacts_scanQrCode,
|
||||
),
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
@@ -456,56 +478,43 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
),
|
||||
const PopupMenuDivider(),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.connect_without_contact),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.contacts_zeroHopAdvert),
|
||||
],
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.connect_without_contact,
|
||||
label: context.l10n.contacts_zeroHopAdvert,
|
||||
),
|
||||
onTap: () => _sendSelfAdvert(connector, flood: false),
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.cell_tower),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.contacts_floodAdvert),
|
||||
],
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.cell_tower,
|
||||
label: context.l10n.contacts_floodAdvert,
|
||||
),
|
||||
onTap: () => _sendSelfAdvert(connector, flood: true),
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.copy),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.contacts_copyAdvertToClipboard),
|
||||
],
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.copy,
|
||||
label: context.l10n.contacts_copyAdvertToClipboard,
|
||||
),
|
||||
onTap: () => _contactExport(Uint8List.fromList([])),
|
||||
),
|
||||
const PopupMenuDivider(),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.logout,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.common_disconnect),
|
||||
],
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.radar,
|
||||
label: context.l10n.manualTrace_menuItem,
|
||||
),
|
||||
onTap: () => _disconnect(context, connector),
|
||||
onTap: () => ManualPathTraceScreen.open(context),
|
||||
),
|
||||
const PopupMenuDivider(),
|
||||
connectionMenuItem(this.context, context),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const ThemedIcon(ThemeIconSlot.settings),
|
||||
const SizedBox(width: 8),
|
||||
Text(context.l10n.settings_title),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
leading: const ThemedIcon(ThemeIconSlot.settings, size: 20),
|
||||
label: context.l10n.settings_title,
|
||||
),
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
@@ -525,10 +534,12 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
Expanded(child: _buildContactsBody(context, connector)),
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => _showAddContactSheet(context),
|
||||
child: const Icon(Icons.person_add),
|
||||
),
|
||||
floatingActionButton: readOnly
|
||||
? null
|
||||
: FloatingActionButton(
|
||||
onPressed: () => _showAddContactSheet(context),
|
||||
child: const Icon(Icons.person_add),
|
||||
),
|
||||
bottomNavigationBar: SafeArea(
|
||||
top: false,
|
||||
child: QuickSwitchBar(
|
||||
@@ -594,13 +605,6 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _disconnect(
|
||||
BuildContext context,
|
||||
MeshCoreConnector connector,
|
||||
) async {
|
||||
await showDisconnectDialog(context, connector);
|
||||
}
|
||||
|
||||
ContactGroup? _selectedGroupForName(String selectedGroupName) {
|
||||
if (selectedGroupName == contactsAllGroupsValue) return null;
|
||||
for (final group in _groups) {
|
||||
@@ -781,17 +785,9 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
const PopupMenuDivider(),
|
||||
PopupMenuItem<String>(
|
||||
value: _manageGroupsValue,
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.group_add),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
menuContext.l10n.contacts_manageGroups,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.group_add,
|
||||
label: menuContext.l10n.contacts_manageGroups,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -1069,7 +1065,11 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
),
|
||||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () => connector.getContacts(),
|
||||
// Offline there is no radio to refresh from.
|
||||
onRefresh: () async {
|
||||
if (isRadioReadOnly(connector)) return;
|
||||
await connector.getContacts();
|
||||
},
|
||||
child: filteredAndSorted.isEmpty
|
||||
? LayoutBuilder(
|
||||
builder: (context, constraints) => ListView(
|
||||
@@ -1244,9 +1244,12 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
// Check if this is a repeater
|
||||
if (contact.type == advTypeRepeater) {
|
||||
_showRepeaterLogin(context, contact);
|
||||
} else if (contact.type == advTypeRoom) {
|
||||
} else if (contact.type == advTypeRoom &&
|
||||
!isRadioReadOnly(context.read<MeshCoreConnector>())) {
|
||||
_showRoomLogin(context, contact, RoomLoginDestination.chat);
|
||||
} else {
|
||||
// Offline a room opens straight onto its saved history, read-only:
|
||||
// logging in needs the radio.
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final unread = connector.getUnreadCountForContactKey(
|
||||
contact.publicKeyHex,
|
||||
@@ -1293,6 +1296,7 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
}
|
||||
|
||||
void _showRepeaterLogin(BuildContext context, Contact repeater) {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => RepeaterLoginDialog(
|
||||
@@ -1319,6 +1323,7 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
Contact room,
|
||||
RoomLoginDestination destination,
|
||||
) {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => RoomLoginDialog(
|
||||
@@ -1579,6 +1584,9 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
final isRepeater = contact.type == advTypeRepeater;
|
||||
final isRoom = contact.type == advTypeRoom;
|
||||
final isFavorite = contact.isFavorite;
|
||||
// Everything here except the header talks to the radio.
|
||||
final readOnly = isRadioReadOnly(connector);
|
||||
Color? tint(Color color) => readOnly ? null : color;
|
||||
|
||||
showMeshSheet(
|
||||
context,
|
||||
@@ -1593,7 +1601,8 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
),
|
||||
if (isRepeater) ...[
|
||||
ListTile(
|
||||
leading: Icon(Icons.radar, color: MeshPalette.signal),
|
||||
enabled: !readOnly,
|
||||
leading: Icon(Icons.radar, color: tint(MeshPalette.signal)),
|
||||
title: Text(context.l10n.contacts_ping),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
@@ -1617,7 +1626,11 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.cell_tower, color: MeshPalette.warn),
|
||||
enabled: !readOnly,
|
||||
leading: Icon(
|
||||
Icons.cell_tower,
|
||||
color: tint(MeshPalette.warn),
|
||||
),
|
||||
title: Text(context.l10n.contacts_manageRepeater),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
@@ -1626,7 +1639,8 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
),
|
||||
] else if (isRoom) ...[
|
||||
ListTile(
|
||||
leading: Icon(Icons.radar, color: MeshPalette.signal),
|
||||
enabled: !readOnly,
|
||||
leading: Icon(Icons.radar, color: tint(MeshPalette.signal)),
|
||||
title: Text(context.l10n.contacts_pathTrace),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
@@ -1652,7 +1666,11 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.meeting_room, color: MeshPalette.blue),
|
||||
enabled: !readOnly,
|
||||
leading: Icon(
|
||||
Icons.meeting_room,
|
||||
color: tint(MeshPalette.blue),
|
||||
),
|
||||
title: Text(context.l10n.contacts_roomLogin),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
@@ -1660,9 +1678,10 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: Icon(
|
||||
Icons.room_preferences,
|
||||
color: MeshPalette.warn,
|
||||
color: tint(MeshPalette.warn),
|
||||
),
|
||||
title: Text(context.l10n.room_management),
|
||||
onTap: () {
|
||||
@@ -1677,7 +1696,8 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
] else ...[
|
||||
if (contact.pathLength > 0)
|
||||
ListTile(
|
||||
leading: Icon(Icons.radar, color: MeshPalette.signal),
|
||||
enabled: !readOnly,
|
||||
leading: Icon(Icons.radar, color: tint(MeshPalette.signal)),
|
||||
title: Text(context.l10n.contacts_chatTraceRoute),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
@@ -1702,9 +1722,10 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
),
|
||||
],
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: Icon(
|
||||
isFavorite ? Icons.star : Icons.star_border,
|
||||
color: MeshPalette.warn,
|
||||
color: tint(MeshPalette.warn),
|
||||
),
|
||||
title: Text(
|
||||
isFavorite
|
||||
@@ -1720,6 +1741,7 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: const Icon(Icons.copy),
|
||||
title: Text(context.l10n.contacts_ShareContact),
|
||||
onTap: () {
|
||||
@@ -1728,6 +1750,7 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: const Icon(Icons.connect_without_contact),
|
||||
title: Text(context.l10n.contacts_ShareContactZeroHop),
|
||||
onTap: () {
|
||||
@@ -1736,17 +1759,20 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
enabled: !readOnly,
|
||||
leading: Icon(
|
||||
Icons.delete,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
color: tint(Theme.of(context).colorScheme.error),
|
||||
),
|
||||
title: Text(
|
||||
context.l10n.contacts_removeFromContacts,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
style: TextStyle(
|
||||
color: tint(Theme.of(context).colorScheme.error),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
_confirmDelete(context, connector, contact);
|
||||
confirmRemoveContact(context, connector, contact);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
@@ -1766,81 +1792,84 @@ class _ContactsScreenState extends State<ContactsScreen>
|
||||
.toInt();
|
||||
return Uint8List.fromList(contact.publicKey.sublist(0, width));
|
||||
}
|
||||
}
|
||||
|
||||
void _confirmDelete(
|
||||
BuildContext context,
|
||||
MeshCoreConnector connector,
|
||||
Contact contact,
|
||||
) {
|
||||
var keepHistory = false;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (dialogContext) => StatefulBuilder(
|
||||
builder: (dialogContext, setDialogState) => AlertDialog(
|
||||
scrollable: true,
|
||||
title: Text(context.l10n.contacts_removeFromContacts),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
/// Asks before removing a contact from the radio. [onRemoved] runs once it
|
||||
/// was removed.
|
||||
void confirmRemoveContact(
|
||||
BuildContext context,
|
||||
MeshCoreConnector connector,
|
||||
Contact contact, {
|
||||
VoidCallback? onRemoved,
|
||||
}) {
|
||||
var keepHistory = false;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (dialogContext) => StatefulBuilder(
|
||||
builder: (dialogContext, setDialogState) => AlertDialog(
|
||||
scrollable: true,
|
||||
title: Text(context.l10n.contacts_removeFromContacts),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(context.l10n.contacts_removeFromContactsConfirm(contact.name)),
|
||||
if (connector.autoAddsContactType(contact.type)) ...[
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
context.l10n.contacts_removeFromContactsConfirm(contact.name),
|
||||
),
|
||||
if (connector.autoAddsContactType(contact.type)) ...[
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
context.l10n.contacts_removeAutoAddNote,
|
||||
style: TextStyle(
|
||||
color: Theme.of(dialogContext).colorScheme.error,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
context.l10n.contacts_removeAutoAddNote,
|
||||
style: TextStyle(
|
||||
color: Theme.of(dialogContext).colorScheme.error,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
],
|
||||
CheckboxListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
value: keepHistory,
|
||||
title: Text(context.l10n.contacts_keepChatHistory),
|
||||
onChanged: (value) =>
|
||||
setDialogState(() => keepHistory = value ?? false),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: Text(context.l10n.common_cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(dialogContext);
|
||||
try {
|
||||
await connector.removeContact(
|
||||
contact,
|
||||
keepMessages: keepHistory,
|
||||
);
|
||||
} catch (e) {
|
||||
appLogger.warn(
|
||||
'Remove contact failed: $e',
|
||||
tag: 'ContactsScreen',
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(context.l10n.contacts_removeFailed),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
context.l10n.contacts_remove,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
),
|
||||
CheckboxListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
value: keepHistory,
|
||||
title: Text(context.l10n.contacts_keepChatHistory),
|
||||
onChanged: (value) =>
|
||||
setDialogState(() => keepHistory = value ?? false),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: Text(context.l10n.common_cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(dialogContext);
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
try {
|
||||
await connector.removeContact(
|
||||
contact,
|
||||
keepMessages: keepHistory,
|
||||
);
|
||||
onRemoved?.call();
|
||||
} catch (e) {
|
||||
appLogger.warn(
|
||||
'Remove contact failed: $e',
|
||||
tag: 'ContactsScreen',
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(context.l10n.contacts_removeFailed),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
context.l10n.contacts_remove,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class _ContactTile extends StatelessWidget {
|
||||
@@ -1958,44 +1987,49 @@ class _ContactTile extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
// Key prefix + path + last seen
|
||||
Row(
|
||||
// Key prefix + path, then last seen: on the same line when
|
||||
// both fit (time at the end), otherwise the time drops to
|
||||
// its own line instead of being cut off in long locales.
|
||||
Wrap(
|
||||
alignment: WrapAlignment.spaceBetween,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
spacing: 8,
|
||||
runSpacing: 2,
|
||||
children: [
|
||||
_KeyPrefixBadge(
|
||||
prefix: contact.publicKeyPrefixHex(pathHashByteWidth),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_KeyPrefixBadge(
|
||||
prefix: contact.publicKeyPrefixHex(
|
||||
pathHashByteWidth,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: Text(
|
||||
contact.pathLabel(
|
||||
context.l10n,
|
||||
pathHashByteWidth: pathHashByteWidth,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
contact.pathLabel(
|
||||
context.l10n,
|
||||
pathHashByteWidth: pathHashByteWidth,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
// Fills its share and right-aligns, so the time sits at
|
||||
// the row's end on wide screens too.
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
formatContactLastSeen(context.l10n, lastSeen),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.end,
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 12.5,
|
||||
color: unreadCount > 0
|
||||
? scheme.primary
|
||||
: scheme.onSurfaceVariant,
|
||||
),
|
||||
Text(
|
||||
formatContactLastSeen(context.l10n, lastSeen),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: MeshTheme.mono(
|
||||
fontSize: 12.5,
|
||||
color: unreadCount > 0
|
||||
? scheme.primary
|
||||
: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user