Merge remote-tracking branch 'origin/dev' into test-regions

This commit is contained in:
zjs81
2026-06-15 22:52:31 -07:00
12 changed files with 283 additions and 221 deletions
+11 -1
View File
@@ -1,3 +1,4 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_linkify/flutter_linkify.dart'; import 'package:flutter_linkify/flutter_linkify.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
@@ -20,6 +21,7 @@ class LinkHandler {
required String text, required String text,
required TextStyle style, required TextStyle style,
TextStyle? linkStyle, TextStyle? linkStyle,
VoidCallback? onSecondaryTap,
}) { }) {
final effectiveLinkStyle = linkStyle ?? defaultLinkStyle(context, style); final effectiveLinkStyle = linkStyle ?? defaultLinkStyle(context, style);
const options = LinkifyOptions(humanize: false, defaultToHttps: false); const options = LinkifyOptions(humanize: false, defaultToHttps: false);
@@ -27,7 +29,7 @@ class LinkHandler {
void onOpen(LinkableElement link) => handleLinkTap(context, link.url); void onOpen(LinkableElement link) => handleLinkTap(context, link.url);
if (PlatformInfo.isDesktop) { if (PlatformInfo.isDesktop) {
return SelectableLinkify( final linkify = SelectableLinkify(
text: text, text: text,
style: style, style: style,
linkStyle: effectiveLinkStyle, linkStyle: effectiveLinkStyle,
@@ -35,6 +37,14 @@ class LinkHandler {
linkifiers: linkifiers, linkifiers: linkifiers,
onOpen: onOpen, onOpen: onOpen,
); );
if (onSecondaryTap == null) return linkify;
return Listener(
onPointerDown: (event) {
if (event.buttons & kSecondaryMouseButton != 0) onSecondaryTap();
},
behavior: HitTestBehavior.translucent,
child: linkify,
);
} }
return Linkify( return Linkify(
text: text, text: text,
+15 -3
View File
@@ -110,8 +110,7 @@ class _BleDebugLogScreenState extends State<BleDebugLogScreen> {
final entry = entries[index]; final entry = entries[index];
final time = final time =
'${entry.timestamp.hour.toString().padLeft(2, '0')}:${entry.timestamp.minute.toString().padLeft(2, '0')}:${entry.timestamp.second.toString().padLeft(2, '0')}'; '${entry.timestamp.hour.toString().padLeft(2, '0')}:${entry.timestamp.minute.toString().padLeft(2, '0')}:${entry.timestamp.second.toString().padLeft(2, '0')}';
return GestureDetector( Future<void> copyHex() async {
onLongPress: () async {
await Clipboard.setData( await Clipboard.setData(
ClipboardData( ClipboardData(
text: entry.payload text: entry.payload
@@ -123,7 +122,20 @@ class _BleDebugLogScreenState extends State<BleDebugLogScreen> {
.join(''), .join(''),
), ),
); );
}, if (context.mounted) {
showDismissibleSnackBar(
context,
content: Text(
context.l10n.debugLog_bleCopied,
),
);
}
}
return GestureDetector(
onTap: copyHex,
onLongPress: copyHex,
onSecondaryTap: copyHex,
child: Container( child: Container(
color: MeshPalette.bg, color: MeshPalette.bg,
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
+3
View File
@@ -665,6 +665,9 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
fontStyle: FontStyle.italic, fontStyle: FontStyle.italic,
color: textColor.withValues(alpha: 0.72), color: textColor.withValues(alpha: 0.72),
), ),
onSecondaryTap: PlatformInfo.isDesktop
? () => _showMessageActions(message)
: null,
), ),
), ),
], ],
+2 -4
View File
@@ -446,9 +446,8 @@ class _ChannelsScreenState extends State<ChannelsScreen>
channelMessageStore, channelMessageStore,
channel, channel,
), ),
child: GestureDetector( onSecondaryTap: PlatformInfo.isDesktop
onSecondaryTapUp: PlatformInfo.isDesktop ? () => _showChannelActions(
? (_) => _showChannelActions(
this.context, this.context,
connector, connector,
channelMessageStore, channelMessageStore,
@@ -594,7 +593,6 @@ class _ChannelsScreenState extends State<ChannelsScreen>
], ],
), ),
), ),
),
); );
} }
+3
View File
@@ -1435,6 +1435,9 @@ class _MessageBubble extends StatelessWidget {
color: textColor.withValues(alpha: 0.72), color: textColor.withValues(alpha: 0.72),
fontSize: bodyFontSize * textScale, fontSize: bodyFontSize * textScale,
), ),
onSecondaryTap: PlatformInfo.isDesktop
? onLongPress
: null,
), ),
), ),
], ],
+3 -7
View File
@@ -147,13 +147,6 @@ class _DiscoveryScreenState extends State<DiscoveryScreen> {
connector, connector,
index, index,
); );
if (PlatformInfo.isDesktop) {
return GestureDetector(
onSecondaryTapUp: (_) =>
_showContactContextMenu(contact, connector),
child: tile,
);
}
return tile; return tile;
}, },
), ),
@@ -204,6 +197,9 @@ class _DiscoveryScreenState extends State<DiscoveryScreen> {
} }
}, },
onLongPress: () => _showContactContextMenu(contact, connector), onLongPress: () => _showContactContextMenu(contact, connector),
onSecondaryTap: PlatformInfo.isDesktop
? () => _showContactContextMenu(contact, connector)
: null,
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10), padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
child: Row( child: Row(
children: [ children: [
@@ -430,6 +430,7 @@ class _LineOfSightMapScreenState extends State<LineOfSightMapScreen> {
minZoom: _mapMinZoom, minZoom: _mapMinZoom,
maxZoom: _mapMaxZoom, maxZoom: _mapMaxZoom,
onLongPress: (_, point) => _addCustomPoint(point), onLongPress: (_, point) => _addCustomPoint(point),
onSecondaryTap: (_, point) => _addCustomPoint(point),
onPositionChanged: (camera, hasGesture) { onPositionChanged: (camera, hasGesture) {
final shouldShow = camera.zoom >= _labelZoomThreshold; final shouldShow = camera.zoom >= _labelZoomThreshold;
if (!_didReceivePositionUpdate || if (!_didReceivePositionUpdate ||
+41 -23
View File
@@ -285,6 +285,31 @@ class _MapScreenState extends State<MapScreen> {
); );
} }
void _handleMapContextPress(
BuildContext context,
MeshCoreConnector connector,
LatLng latLng,
) {
if (_isSelectingPoi) {
setState(() {
_isSelectingPoi = false;
});
_shareMarker(
context: context,
connector: connector,
position: latLng,
defaultLabel: context.l10n.map_pointOfInterest,
flags: 'poi',
);
return;
}
_showShareMarkerAtPositionSheet(
context: context,
connector: connector,
position: latLng,
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Builder( return Builder(
@@ -708,24 +733,10 @@ class _MapScreenState extends State<MapScreen> {
} }
}, },
onLongPress: (_, latLng) { onLongPress: (_, latLng) {
if (_isSelectingPoi) { _handleMapContextPress(context, connector, latLng);
setState(() { },
_isSelectingPoi = false; onSecondaryTap: (_, latLng) {
}); _handleMapContextPress(context, connector, latLng);
_shareMarker(
context: context,
connector: connector,
position: latLng,
defaultLabel: context.l10n.map_pointOfInterest,
flags: 'poi',
);
return;
}
_showShareMarkerAtPositionSheet(
context: context,
connector: connector,
position: latLng,
);
}, },
onPositionChanged: (camera, hasGesture) { onPositionChanged: (camera, hasGesture) {
// Track zoom in half-step buckets so cluster/marker // Track zoom in half-step buckets so cluster/marker
@@ -1181,9 +1192,12 @@ class _MapScreenState extends State<MapScreen> {
width: 48, width: 48,
height: 48, height: 48,
child: GestureDetector( child: GestureDetector(
onLongPress: () => _isBuildingPathTrace onLongPress: () {
? _showNodeInfo(context, guess.contact) if (_isBuildingPathTrace) _showNodeInfo(context, guess.contact);
: null, },
onSecondaryTap: () {
if (_isBuildingPathTrace) _showNodeInfo(context, guess.contact);
},
onTap: () => _isBuildingPathTrace onTap: () => _isBuildingPathTrace
? _addToPath(context, guess.contact, position: guess.position) ? _addToPath(context, guess.contact, position: guess.position)
: _selectNode(guess.contact, guessedPosition: guess.position), : _selectNode(guess.contact, guessedPosition: guess.position),
@@ -1383,8 +1397,12 @@ class _MapScreenState extends State<MapScreen> {
height: size, height: size,
child: GestureDetector( child: GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onLongPress: () => onLongPress: () {
_isBuildingPathTrace ? _showNodeInfo(context, contact) : null, if (_isBuildingPathTrace) _showNodeInfo(context, contact);
},
onSecondaryTap: () {
if (_isBuildingPathTrace) _showNodeInfo(context, contact);
},
onTap: () => _isBuildingPathTrace onTap: () => _isBuildingPathTrace
? _addToPath(context, contact) ? _addToPath(context, contact)
: _selectNode(contact), : _selectNode(contact),
+3 -1
View File
@@ -515,7 +515,9 @@ class _RegionManagementScreenState extends State<RegionManagementScreen> {
}, },
child: Text( child: Text(
context.l10n.common_delete, context.l10n.common_delete,
style: TextStyle(color: Theme.of(dialogContext).colorScheme.error), style: TextStyle(
color: Theme.of(dialogContext).colorScheme.error,
),
), ),
), ),
], ],
+3
View File
@@ -50,6 +50,7 @@ class MeshCard extends StatelessWidget {
final Widget child; final Widget child;
final VoidCallback? onTap; final VoidCallback? onTap;
final VoidCallback? onLongPress; final VoidCallback? onLongPress;
final VoidCallback? onSecondaryTap;
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry padding;
final EdgeInsetsGeometry margin; final EdgeInsetsGeometry margin;
final Color? color; final Color? color;
@@ -61,6 +62,7 @@ class MeshCard extends StatelessWidget {
required this.child, required this.child,
this.onTap, this.onTap,
this.onLongPress, this.onLongPress,
this.onSecondaryTap,
this.padding = const EdgeInsets.all(14), this.padding = const EdgeInsets.all(14),
this.margin = const EdgeInsets.symmetric(horizontal: 16, vertical: 4), this.margin = const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
this.color, this.color,
@@ -89,6 +91,7 @@ class MeshCard extends StatelessWidget {
HapticFeedback.selectionClick(); HapticFeedback.selectionClick();
onLongPress!(); onLongPress!();
}, },
onSecondaryTap: onSecondaryTap,
child: Padding(padding: padding, child: child), child: Padding(padding: padding, child: child),
), ),
), ),
+15 -3
View File
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../connector/meshcore_connector.dart'; import '../connector/meshcore_connector.dart';
import '../utils/platform_info.dart';
import '../helpers/path_helper.dart'; import '../helpers/path_helper.dart';
import '../l10n/l10n.dart'; import '../l10n/l10n.dart';
import '../models/contact.dart'; import '../models/contact.dart';
@@ -534,7 +535,13 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
l10n.routing_deliveryCounts(record.successCount, record.failureCount), l10n.routing_deliveryCounts(record.successCount, record.failureCount),
]; ];
return Card( return GestureDetector(
behavior: HitTestBehavior.opaque,
onSecondaryTapUp: PlatformInfo.isDesktop && hasBytes
? (_) =>
_showPathDetail(context, connector, contact, record.pathBytes)
: null,
child: Card(
margin: const EdgeInsets.symmetric(vertical: 4), margin: const EdgeInsets.symmetric(vertical: 4),
child: ListTile( child: ListTile(
enabled: hasBytes, enabled: hasBytes,
@@ -581,10 +588,15 @@ class _RoutingSheetBodyState extends State<_RoutingSheetBody> {
? () => _applyHistoryPath(connector, contact, record) ? () => _applyHistoryPath(connector, contact, record)
: null, : null,
onLongPress: hasBytes onLongPress: hasBytes
? () => ? () => _showPathDetail(
_showPathDetail(context, connector, contact, record.pathBytes) context,
connector,
contact,
record.pathBytes,
)
: null, : null,
), ),
),
); );
} }
@@ -8,6 +8,7 @@ class TranslatedMessageContent extends StatelessWidget {
final TextStyle style; final TextStyle style;
final TextStyle? originalStyle; final TextStyle? originalStyle;
final bool showOriginalFirst; final bool showOriginalFirst;
final VoidCallback? onSecondaryTap;
const TranslatedMessageContent({ const TranslatedMessageContent({
super.key, super.key,
@@ -16,6 +17,7 @@ class TranslatedMessageContent extends StatelessWidget {
this.originalText, this.originalText,
this.originalStyle, this.originalStyle,
this.showOriginalFirst = true, this.showOriginalFirst = true,
this.onSecondaryTap,
}); });
@override @override
@@ -36,12 +38,14 @@ class TranslatedMessageContent extends StatelessWidget {
fontStyle: FontStyle.italic, fontStyle: FontStyle.italic,
fontSize: style.fontSize, fontSize: style.fontSize,
), ),
onSecondaryTap: onSecondaryTap,
) )
: null; : null;
final translatedWidget = LinkHandler.buildLinkifyText( final translatedWidget = LinkHandler.buildLinkifyText(
context: context, context: context,
text: trimmedDisplay, text: trimmedDisplay,
style: style, style: style,
onSecondaryTap: onSecondaryTap,
); );
if (!shouldShowOriginal) { if (!shouldShowOriginal) {