Routing - Auto routing picks routes by Thompson sampling over faded delivery stats (24 h half-life, capped evidence), weighted by what the radio currently hears; retries prefer a different route; last attempt floods. - Route failures are held until a message's fate is known, so an offline contact no longer wrecks its route history; failing routes are only deleted after a week without a delivery. - Direct (zero-hop) path is a rotation candidate (#643) and a new Direct mode in the routing sheet; history routes are used for repeater logins. - Remove the route-weight sliders the new chooser no longer uses. Chats - Bulk selection in channel chats (spam / not spam / delete / copy) and in the Filtered messages list. - Tapping a search result jumps to the message. - Swipe-to-reply ignores vertical scrolls. - Active conversation follows route lifecycle, so covered chats count unread again. Notifications - Tapping a notification opens its conversation. - Per-conversation coalescing and one alert per queued-message sync. - Monochrome status-bar icon; background service stops when the app is swiped away; stale notifications cleared on radio or slot change. Other - Online map: opaque links and painted dots for dense areas to avoid an Impeller GPU crash; expandable hop list on path maps. - Contact share: clipboard import of shared contacts, "Add again". - Android: enableEdgeToEdge and scrolling-screenshot support. - Translations for all new strings; fix mistranslated routing labels.
215 lines
6.5 KiB
Dart
215 lines
6.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../connector/meshcore_connector.dart';
|
|
import '../helpers/contact_share_message.dart';
|
|
import '../helpers/snack_bar_builder.dart';
|
|
import '../l10n/app_localizations.dart';
|
|
import '../l10n/l10n.dart';
|
|
import '../theme/mesh_theme.dart';
|
|
import 'mesh_ui.dart';
|
|
|
|
String contactShareTypeLabel(AppLocalizations l10n, int type) {
|
|
switch (type) {
|
|
case 2:
|
|
return l10n.contact_typeRepeater;
|
|
case 3:
|
|
return l10n.contact_typeRoom;
|
|
case 4:
|
|
return l10n.contact_typeSensor;
|
|
default:
|
|
return l10n.contact_typeChat;
|
|
}
|
|
}
|
|
|
|
/// Card shown in chat bubbles for a `<PUBKEY:TYPE:NAME>` contact share, with a
|
|
/// one-tap "Add contact" action for incoming shares not yet on the radio.
|
|
class SharedContactCard extends StatefulWidget {
|
|
final ContactShare share;
|
|
final bool isOutgoing;
|
|
final double textScale;
|
|
final Color textColor;
|
|
final Color metaColor;
|
|
|
|
const SharedContactCard({
|
|
super.key,
|
|
required this.share,
|
|
required this.isOutgoing,
|
|
required this.textScale,
|
|
required this.textColor,
|
|
required this.metaColor,
|
|
});
|
|
|
|
@override
|
|
State<SharedContactCard> createState() => _SharedContactCardState();
|
|
}
|
|
|
|
class _SharedContactCardState extends State<SharedContactCard> {
|
|
bool _adding = false;
|
|
|
|
Future<void> _add(MeshCoreConnector connector) async {
|
|
if (_adding) return;
|
|
setState(() => _adding = true);
|
|
var ok = true;
|
|
try {
|
|
await connector.addContactFromCard(widget.share.toScannedContact());
|
|
} catch (_) {
|
|
ok = false;
|
|
}
|
|
if (!mounted) return;
|
|
setState(() => _adding = false);
|
|
final l10n = context.l10n;
|
|
showDismissibleSnackBar(
|
|
context,
|
|
content: Text(
|
|
ok ? l10n.contacts_contactImported : l10n.contacts_contactImportFailed,
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final l10n = context.l10n;
|
|
final share = widget.share;
|
|
final scale = widget.textScale;
|
|
final connector = context.watch<MeshCoreConnector>();
|
|
final isSelf = connector.selfPublicKeyHex == share.publicKeyHex;
|
|
final isSaved = connector.getContactByPubKeyHex(share.publicKeyHex) != null;
|
|
final displayName = share.name.isEmpty ? share.shortKey : share.name;
|
|
|
|
Widget? action;
|
|
if (!widget.isOutgoing) {
|
|
if (isSelf) {
|
|
action = _status(Icons.person_outline, l10n.contactShare_isYou);
|
|
} else if (isSaved) {
|
|
// Still offer a re-add: the app's list can lag the radio (e.g. the
|
|
// contact was dropped on the radio or by another client), and adding
|
|
// again just refreshes an existing entry.
|
|
action = Wrap(
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
|
spacing: 8,
|
|
children: [
|
|
_status(Icons.check_circle_outline, l10n.contactShare_saved),
|
|
TextButton(
|
|
onPressed: connector.isConnected && !_adding
|
|
? () => _add(connector)
|
|
: null,
|
|
style: TextButton.styleFrom(
|
|
foregroundColor: widget.textColor,
|
|
minimumSize: const Size(48, 48),
|
|
),
|
|
child: Text(
|
|
_adding ? l10n.contactShare_adding : l10n.contactShare_addAgain,
|
|
style: TextStyle(
|
|
fontSize: 14 * scale,
|
|
fontWeight: FontWeight.w600,
|
|
decoration: TextDecoration.underline,
|
|
decorationColor: widget.textColor,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
} else {
|
|
action = SizedBox(
|
|
width: double.infinity,
|
|
height: 48,
|
|
child: FilledButton.icon(
|
|
onPressed: connector.isConnected && !_adding
|
|
? () => _add(connector)
|
|
: null,
|
|
icon: _adding
|
|
? const SizedBox(
|
|
width: 18,
|
|
height: 18,
|
|
child: CircularProgressIndicator(strokeWidth: 2),
|
|
)
|
|
: const Icon(Icons.person_add_alt),
|
|
label: Text(
|
|
_adding ? l10n.contactShare_adding : l10n.contactShare_add,
|
|
style: TextStyle(
|
|
fontSize: 14 * scale,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
widget.isOutgoing
|
|
? l10n.contactShare_headerOutgoing
|
|
: l10n.contactShare_headerIncoming,
|
|
style: TextStyle(
|
|
color: widget.metaColor,
|
|
fontSize: 12 * scale,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Row(
|
|
children: [
|
|
AvatarCircle(name: displayName, size: 44),
|
|
const SizedBox(width: 12),
|
|
Flexible(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
displayName,
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(
|
|
color: widget.textColor,
|
|
fontSize: 16 * scale,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
Text(
|
|
contactShareTypeLabel(l10n, share.type),
|
|
style: TextStyle(
|
|
color: widget.metaColor,
|
|
fontSize: 13 * scale,
|
|
),
|
|
),
|
|
Text(
|
|
'<${share.shortKey}>',
|
|
style: MeshTheme.mono(
|
|
fontSize: 12 * scale,
|
|
color: widget.metaColor,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
if (action != null) ...[const SizedBox(height: 10), action],
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _status(IconData icon, String label) {
|
|
return Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(icon, size: 20 * widget.textScale, color: widget.textColor),
|
|
const SizedBox(width: 6),
|
|
Text(
|
|
label,
|
|
style: TextStyle(
|
|
color: widget.textColor,
|
|
fontSize: 14 * widget.textScale,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|