Merge pull request #588 from ericszimmermann/ez_share_location
Share location marker from chat
This commit is contained in:
25 files changed
+627
-71
No files matched your search
@@ -711,6 +711,7 @@
|
|||||||
"map_shareMarkerHere": "Marker hier teilen",
|
"map_shareMarkerHere": "Marker hier teilen",
|
||||||
"map_pinLabel": "Pin-Beschriftung",
|
"map_pinLabel": "Pin-Beschriftung",
|
||||||
"map_label": "Beschriftung",
|
"map_label": "Beschriftung",
|
||||||
|
"map_labelUpdateHint": "Wenn Sie denselben Namen verwenden wie zuvor, wird die Markierung bei MeshCore Open-Empfängern aktualisiert.",
|
||||||
"map_pointOfInterest": "Punkt von Interesse",
|
"map_pointOfInterest": "Punkt von Interesse",
|
||||||
"map_sendToContact": "An Kontakt senden",
|
"map_sendToContact": "An Kontakt senden",
|
||||||
"map_sendToChannel": "An Kanal senden",
|
"map_sendToChannel": "An Kanal senden",
|
||||||
|
|||||||
@@ -1145,6 +1145,7 @@
|
|||||||
"map_setAsMyLocation": "Set as my location",
|
"map_setAsMyLocation": "Set as my location",
|
||||||
"map_pinLabel": "Pin label",
|
"map_pinLabel": "Pin label",
|
||||||
"map_label": "Label",
|
"map_label": "Label",
|
||||||
|
"map_labelUpdateHint": "Using the same label as before will update the marker for MeshCore Open recipients.",
|
||||||
"map_pointOfInterest": "Point of interest",
|
"map_pointOfInterest": "Point of interest",
|
||||||
"map_sendToContact": "Send to contact",
|
"map_sendToContact": "Send to contact",
|
||||||
"map_sendToChannel": "Send to channel",
|
"map_sendToChannel": "Send to channel",
|
||||||
|
|||||||
@@ -3916,6 +3916,12 @@ abstract class AppLocalizations {
|
|||||||
/// **'Label'**
|
/// **'Label'**
|
||||||
String get map_label;
|
String get map_label;
|
||||||
|
|
||||||
|
/// No description provided for @map_labelUpdateHint.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Using the same label as before will update the marker for MeshCore Open recipients.'**
|
||||||
|
String get map_labelUpdateHint;
|
||||||
|
|
||||||
/// No description provided for @map_pointOfInterest.
|
/// No description provided for @map_pointOfInterest.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
|
|||||||
@@ -2190,6 +2190,10 @@ class AppLocalizationsBg extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => 'Етикет';
|
String get map_label => 'Етикет';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => 'Точка на интерес';
|
String get map_pointOfInterest => 'Точка на интерес';
|
||||||
|
|
||||||
|
|||||||
@@ -2187,6 +2187,10 @@ class AppLocalizationsDe extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => 'Beschriftung';
|
String get map_label => 'Beschriftung';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Wenn Sie denselben Namen verwenden wie zuvor, wird die Markierung bei MeshCore Open-Empfängern aktualisiert.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => 'Punkt von Interesse';
|
String get map_pointOfInterest => 'Punkt von Interesse';
|
||||||
|
|
||||||
|
|||||||
@@ -2154,6 +2154,10 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => 'Label';
|
String get map_label => 'Label';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => 'Point of interest';
|
String get map_pointOfInterest => 'Point of interest';
|
||||||
|
|
||||||
|
|||||||
@@ -2182,6 +2182,10 @@ class AppLocalizationsEs extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => 'Etiqueta';
|
String get map_label => 'Etiqueta';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => 'Punto de interés';
|
String get map_pointOfInterest => 'Punto de interés';
|
||||||
|
|
||||||
|
|||||||
@@ -2190,6 +2190,10 @@ class AppLocalizationsFr extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => 'Étiquette';
|
String get map_label => 'Étiquette';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => 'Point d\'intérêt';
|
String get map_pointOfInterest => 'Point d\'intérêt';
|
||||||
|
|
||||||
|
|||||||
@@ -2179,6 +2179,10 @@ class AppLocalizationsHu extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => 'Címke';
|
String get map_label => 'Címke';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => 'Érdekes pont';
|
String get map_pointOfInterest => 'Érdekes pont';
|
||||||
|
|
||||||
|
|||||||
@@ -2188,6 +2188,10 @@ class AppLocalizationsIt extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => 'Etichetta';
|
String get map_label => 'Etichetta';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => 'Punto di interesse';
|
String get map_pointOfInterest => 'Punto di interesse';
|
||||||
|
|
||||||
|
|||||||
@@ -2091,6 +2091,10 @@ class AppLocalizationsJa extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => 'ラベル';
|
String get map_label => 'ラベル';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => '興味地点';
|
String get map_pointOfInterest => '興味地点';
|
||||||
|
|
||||||
|
|||||||
@@ -2097,6 +2097,10 @@ class AppLocalizationsKo extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => '레이블';
|
String get map_label => '레이블';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => '관심 지점';
|
String get map_pointOfInterest => '관심 지점';
|
||||||
|
|
||||||
|
|||||||
@@ -2173,6 +2173,10 @@ class AppLocalizationsNl extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => 'Label';
|
String get map_label => 'Label';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => 'Interessepunt';
|
String get map_pointOfInterest => 'Interessepunt';
|
||||||
|
|
||||||
|
|||||||
@@ -2205,6 +2205,10 @@ class AppLocalizationsPl extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => 'Etykieta';
|
String get map_label => 'Etykieta';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => 'Punkt zainteresowań';
|
String get map_pointOfInterest => 'Punkt zainteresowań';
|
||||||
|
|
||||||
|
|||||||
@@ -2186,6 +2186,10 @@ class AppLocalizationsPt extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => 'Rótulo';
|
String get map_label => 'Rótulo';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => 'Ponto de interesse';
|
String get map_pointOfInterest => 'Ponto de interesse';
|
||||||
|
|
||||||
|
|||||||
@@ -2191,6 +2191,10 @@ class AppLocalizationsRu extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => 'Подпись';
|
String get map_label => 'Подпись';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => 'Точка интереса';
|
String get map_pointOfInterest => 'Точка интереса';
|
||||||
|
|
||||||
|
|||||||
@@ -2178,6 +2178,10 @@ class AppLocalizationsSk extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => 'Značka';
|
String get map_label => 'Značka';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => 'Bod záujmu';
|
String get map_pointOfInterest => 'Bod záujmu';
|
||||||
|
|
||||||
|
|||||||
@@ -2172,6 +2172,10 @@ class AppLocalizationsSl extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => 'Oznaka';
|
String get map_label => 'Oznaka';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => 'Točka zanimivosti';
|
String get map_pointOfInterest => 'Točka zanimivosti';
|
||||||
|
|
||||||
|
|||||||
@@ -2162,6 +2162,10 @@ class AppLocalizationsSv extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => 'Etikett';
|
String get map_label => 'Etikett';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => 'Plats av intresse';
|
String get map_pointOfInterest => 'Plats av intresse';
|
||||||
|
|
||||||
|
|||||||
@@ -2181,6 +2181,10 @@ class AppLocalizationsUk extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => 'Мітка';
|
String get map_label => 'Мітка';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => 'Точка інтересу';
|
String get map_pointOfInterest => 'Точка інтересу';
|
||||||
|
|
||||||
|
|||||||
@@ -2065,6 +2065,10 @@ class AppLocalizationsZh extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get map_label => '标签';
|
String get map_label => '标签';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get map_labelUpdateHint =>
|
||||||
|
'Using the same label as before will update the marker for MeshCore Open recipients.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get map_pointOfInterest => '兴趣点';
|
String get map_pointOfInterest => '兴趣点';
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import '../widgets/received_image_message.dart';
|
|||||||
import '../widgets/byte_count_input.dart';
|
import '../widgets/byte_count_input.dart';
|
||||||
import '../widgets/chat_day_separator.dart';
|
import '../widgets/chat_day_separator.dart';
|
||||||
import '../widgets/empty_state.dart';
|
import '../widgets/empty_state.dart';
|
||||||
|
|
||||||
import '../widgets/chat_zoom_wrapper.dart';
|
import '../widgets/chat_zoom_wrapper.dart';
|
||||||
import '../widgets/emoji_picker.dart';
|
import '../widgets/emoji_picker.dart';
|
||||||
import '../widgets/gif_message.dart';
|
import '../widgets/gif_message.dart';
|
||||||
@@ -2011,6 +2012,79 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildInputBar() {
|
Widget _buildInputBar() {
|
||||||
|
Future<String?> promptForMarkerLabel(
|
||||||
|
BuildContext context, {
|
||||||
|
required double lat,
|
||||||
|
required double lon,
|
||||||
|
required String defaultLabel,
|
||||||
|
required String flags,
|
||||||
|
}) async {
|
||||||
|
final controller = TextEditingController(text: defaultLabel);
|
||||||
|
controller.selection = TextSelection(
|
||||||
|
baseOffset: 0,
|
||||||
|
extentOffset: controller.text.length,
|
||||||
|
);
|
||||||
|
final focusNode = FocusNode();
|
||||||
|
|
||||||
|
final latStr = lat.toStringAsFixed(6);
|
||||||
|
final lonStr = lon.toStringAsFixed(6);
|
||||||
|
final prefix = 'm:$latStr,$lonStr|';
|
||||||
|
final suffix = '|$flags';
|
||||||
|
final overheadBytes = utf8.encode(prefix + suffix).length;
|
||||||
|
final maxForContact = maxContactMessageBytes();
|
||||||
|
final maxForChannel = maxChannelMessageBytes(null);
|
||||||
|
final maxPayload = maxForContact < maxForChannel
|
||||||
|
? maxForContact
|
||||||
|
: maxForChannel;
|
||||||
|
final allowedLabelBytes = (maxPayload - overheadBytes) > 0
|
||||||
|
? (maxPayload - overheadBytes)
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
final result = await showDialog<String>(
|
||||||
|
context: context,
|
||||||
|
builder: (dialogContext) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (dialogContext.mounted) {
|
||||||
|
focusNode.requestFocus();
|
||||||
|
controller.selection = TextSelection(
|
||||||
|
baseOffset: 0,
|
||||||
|
extentOffset: controller.text.length,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(dialogContext.l10n.map_pinLabel),
|
||||||
|
content: ByteCountedTextField(
|
||||||
|
focusNode: focusNode,
|
||||||
|
maxBytes: allowedLabelBytes,
|
||||||
|
controller: controller,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
helperText: dialogContext.l10n.map_labelUpdateHint,
|
||||||
|
helperMaxLines: 3,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(dialogContext, null),
|
||||||
|
child: Text(dialogContext.l10n.common_cancel),
|
||||||
|
),
|
||||||
|
FilledButton(
|
||||||
|
onPressed: () =>
|
||||||
|
Navigator.pop(dialogContext, controller.text.trim()),
|
||||||
|
child: Text(dialogContext.l10n.common_share),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
} finally {
|
||||||
|
focusNode.dispose();
|
||||||
|
controller.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final connector = context.watch<MeshCoreConnector>();
|
final connector = context.watch<MeshCoreConnector>();
|
||||||
final maxBytes = maxChannelMessageBytes(connector.selfName);
|
final maxBytes = maxChannelMessageBytes(connector.selfName);
|
||||||
final settings = context.watch<AppSettingsService>().settings;
|
final settings = context.watch<AppSettingsService>().settings;
|
||||||
@@ -2041,44 +2115,135 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
PopupMenuButton<String>(
|
Builder(
|
||||||
icon: const Icon(Icons.add_circle_outline),
|
builder: (menuContext) {
|
||||||
position: PopupMenuPosition.over,
|
return IconButton(
|
||||||
offset: Offset(0, showImageAction ? -112 : -64),
|
icon: const Icon(Icons.add_circle_outline),
|
||||||
tooltip: context.l10n.chat_selectSendAction,
|
tooltip: context.l10n.chat_selectSendAction,
|
||||||
onSelected: (action) {
|
onPressed: () async {
|
||||||
switch (action) {
|
final RenderBox button =
|
||||||
case 'gif':
|
menuContext.findRenderObject() as RenderBox;
|
||||||
_showGifPicker(context);
|
final RenderBox overlay =
|
||||||
break;
|
Overlay.of(menuContext).context.findRenderObject()
|
||||||
case 'meshcore-image':
|
as RenderBox;
|
||||||
_showImageSendPreview();
|
final Offset buttonOffset = button.localToGlobal(
|
||||||
break;
|
Offset.zero,
|
||||||
}
|
ancestor: overlay,
|
||||||
|
);
|
||||||
|
final items = <PopupMenuEntry<String>>[
|
||||||
|
PopupMenuItem(
|
||||||
|
value: 'gif',
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.gif_box),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Text(context.l10n.chat_sendGif),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
if (showImageAction) {
|
||||||
|
items.add(
|
||||||
|
PopupMenuItem(
|
||||||
|
value: 'meshcore-image',
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.image_outlined),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Text(context.l10n.chat_sendImageLora),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (context.read<MeshCoreConnector>().selfLatitude !=
|
||||||
|
null &&
|
||||||
|
context.read<MeshCoreConnector>().selfLongitude !=
|
||||||
|
null) {
|
||||||
|
items.add(
|
||||||
|
PopupMenuItem(
|
||||||
|
value: 'send-my-location',
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.my_location),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Text(context.l10n.map_shareMarkerHere),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final menuHeight =
|
||||||
|
items.length * kMinInteractiveDimension + 16;
|
||||||
|
final menuTop = (buttonOffset.dy - menuHeight).clamp(
|
||||||
|
8.0,
|
||||||
|
overlay.size.height,
|
||||||
|
);
|
||||||
|
final position = RelativeRect.fromLTRB(
|
||||||
|
buttonOffset.dx,
|
||||||
|
menuTop,
|
||||||
|
overlay.size.width -
|
||||||
|
buttonOffset.dx -
|
||||||
|
button.size.width,
|
||||||
|
overlay.size.height - buttonOffset.dy,
|
||||||
|
);
|
||||||
|
|
||||||
|
final selected = await showMenu<String>(
|
||||||
|
context: menuContext,
|
||||||
|
position: position,
|
||||||
|
items: items,
|
||||||
|
);
|
||||||
|
if (!mounted || !menuContext.mounted) return;
|
||||||
|
if (selected == null) return;
|
||||||
|
switch (selected) {
|
||||||
|
case 'gif':
|
||||||
|
_showGifPicker(context);
|
||||||
|
break;
|
||||||
|
case 'meshcore-image':
|
||||||
|
_showImageSendPreview();
|
||||||
|
break;
|
||||||
|
case 'send-my-location':
|
||||||
|
final connector = context
|
||||||
|
.read<MeshCoreConnector>();
|
||||||
|
if (connector.selfLatitude == null ||
|
||||||
|
connector.selfLongitude == null) {
|
||||||
|
showDismissibleSnackBar(
|
||||||
|
context,
|
||||||
|
content: Text(
|
||||||
|
context.l10n.map_connectToShareMarkers,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
final lat = connector.selfLatitude!;
|
||||||
|
final lon = connector.selfLongitude!;
|
||||||
|
final initialLabel =
|
||||||
|
connector.selfName?.isNotEmpty == true
|
||||||
|
? connector.selfName!
|
||||||
|
: context.l10n.map_sharedPin;
|
||||||
|
final label = await promptForMarkerLabel(
|
||||||
|
context,
|
||||||
|
lat: lat,
|
||||||
|
lon: lon,
|
||||||
|
defaultLabel: initialLabel,
|
||||||
|
flags: 'poi',
|
||||||
|
);
|
||||||
|
if (label == null || label.trim().isEmpty) break;
|
||||||
|
if (!mounted || !menuContext.mounted) break;
|
||||||
|
final connector2 = context
|
||||||
|
.read<MeshCoreConnector>();
|
||||||
|
final markerText =
|
||||||
|
'm:${lat.toStringAsFixed(6)},${lon.toStringAsFixed(6)}|${label.trim()}|poi';
|
||||||
|
connector2.sendChannelMessage(
|
||||||
|
widget.channel,
|
||||||
|
markerText,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
itemBuilder: (context) => [
|
|
||||||
PopupMenuItem(
|
|
||||||
value: 'gif',
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
const Icon(Icons.gif_box),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Text(context.l10n.chat_sendGif),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (showImageAction)
|
|
||||||
PopupMenuItem(
|
|
||||||
value: 'meshcore-image',
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
const Icon(Icons.image_outlined),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Text(context.l10n.chat_sendImageLora),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
if (settings.translationEnabled)
|
if (settings.translationEnabled)
|
||||||
MessageTranslationButton(
|
MessageTranslationButton(
|
||||||
|
|||||||
@@ -472,6 +472,79 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildInputBar(MeshCoreConnector connector) {
|
Widget _buildInputBar(MeshCoreConnector connector) {
|
||||||
|
Future<String?> promptForMarkerLabel(
|
||||||
|
BuildContext context, {
|
||||||
|
required double lat,
|
||||||
|
required double lon,
|
||||||
|
required String defaultLabel,
|
||||||
|
required String flags,
|
||||||
|
}) async {
|
||||||
|
final controller = TextEditingController(text: defaultLabel);
|
||||||
|
controller.selection = TextSelection(
|
||||||
|
baseOffset: 0,
|
||||||
|
extentOffset: controller.text.length,
|
||||||
|
);
|
||||||
|
final focusNode = FocusNode();
|
||||||
|
|
||||||
|
final latStr = lat.toStringAsFixed(6);
|
||||||
|
final lonStr = lon.toStringAsFixed(6);
|
||||||
|
final prefix = 'm:$latStr,$lonStr|';
|
||||||
|
final suffix = '|$flags';
|
||||||
|
final overheadBytes = utf8.encode(prefix + suffix).length;
|
||||||
|
final maxForContact = maxContactMessageBytes();
|
||||||
|
final maxForChannel = maxChannelMessageBytes(null);
|
||||||
|
final maxPayload = maxForContact < maxForChannel
|
||||||
|
? maxForContact
|
||||||
|
: maxForChannel;
|
||||||
|
final allowedLabelBytes = (maxPayload - overheadBytes) > 0
|
||||||
|
? (maxPayload - overheadBytes)
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
final result = await showDialog<String>(
|
||||||
|
context: context,
|
||||||
|
builder: (dialogContext) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (dialogContext.mounted) {
|
||||||
|
focusNode.requestFocus();
|
||||||
|
controller.selection = TextSelection(
|
||||||
|
baseOffset: 0,
|
||||||
|
extentOffset: controller.text.length,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(dialogContext.l10n.map_pinLabel),
|
||||||
|
content: ByteCountedTextField(
|
||||||
|
focusNode: focusNode,
|
||||||
|
maxBytes: allowedLabelBytes,
|
||||||
|
controller: controller,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
helperText: dialogContext.l10n.map_labelUpdateHint,
|
||||||
|
helperMaxLines: 3,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(dialogContext, null),
|
||||||
|
child: Text(dialogContext.l10n.common_cancel),
|
||||||
|
),
|
||||||
|
FilledButton(
|
||||||
|
onPressed: () =>
|
||||||
|
Navigator.pop(dialogContext, controller.text.trim()),
|
||||||
|
child: Text(dialogContext.l10n.common_share),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
} finally {
|
||||||
|
focusNode.dispose();
|
||||||
|
controller.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final maxBytes = maxContactMessageBytes();
|
final maxBytes = maxContactMessageBytes();
|
||||||
final scheme = Theme.of(context).colorScheme;
|
final scheme = Theme.of(context).colorScheme;
|
||||||
final settings = context.watch<AppSettingsService>().settings;
|
final settings = context.watch<AppSettingsService>().settings;
|
||||||
@@ -486,10 +559,106 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
Builder(
|
||||||
icon: const Icon(Icons.gif_box_outlined),
|
builder: (menuContext) {
|
||||||
tooltip: context.l10n.chat_sendGif,
|
return IconButton(
|
||||||
onPressed: () => _showGifPicker(context),
|
icon: const Icon(Icons.add_circle_outline),
|
||||||
|
tooltip: context.l10n.chat_selectSendAction,
|
||||||
|
onPressed: () async {
|
||||||
|
final RenderBox button =
|
||||||
|
menuContext.findRenderObject() as RenderBox;
|
||||||
|
final RenderBox overlay =
|
||||||
|
Overlay.of(menuContext).context.findRenderObject()
|
||||||
|
as RenderBox;
|
||||||
|
final Offset buttonOffset = button.localToGlobal(
|
||||||
|
Offset.zero,
|
||||||
|
ancestor: overlay,
|
||||||
|
);
|
||||||
|
const menuHeight = 2 * kMinInteractiveDimension + 16;
|
||||||
|
final menuTop = (buttonOffset.dy - menuHeight).clamp(
|
||||||
|
8.0,
|
||||||
|
overlay.size.height,
|
||||||
|
);
|
||||||
|
final position = RelativeRect.fromLTRB(
|
||||||
|
buttonOffset.dx,
|
||||||
|
menuTop,
|
||||||
|
overlay.size.width -
|
||||||
|
buttonOffset.dx -
|
||||||
|
button.size.width,
|
||||||
|
overlay.size.height - buttonOffset.dy,
|
||||||
|
);
|
||||||
|
|
||||||
|
final selected = await showMenu<String>(
|
||||||
|
context: menuContext,
|
||||||
|
position: position,
|
||||||
|
items: [
|
||||||
|
PopupMenuItem(
|
||||||
|
value: 'gif',
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.gif_box),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Text(context.l10n.chat_sendGif),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
value: 'send-my-location',
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.my_location),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Text(context.l10n.map_shareMarkerHere),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
if (!mounted || !menuContext.mounted) return;
|
||||||
|
if (selected == null) return;
|
||||||
|
switch (selected) {
|
||||||
|
case 'gif':
|
||||||
|
_showGifPicker(context);
|
||||||
|
break;
|
||||||
|
case 'send-my-location':
|
||||||
|
final connector = context.read<MeshCoreConnector>();
|
||||||
|
if (connector.selfLatitude == null ||
|
||||||
|
connector.selfLongitude == null) {
|
||||||
|
showDismissibleSnackBar(
|
||||||
|
context,
|
||||||
|
content: Text(
|
||||||
|
context.l10n.map_connectToShareMarkers,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
final lat = connector.selfLatitude!;
|
||||||
|
final lon = connector.selfLongitude!;
|
||||||
|
final initialLabel =
|
||||||
|
connector.selfName?.isNotEmpty == true
|
||||||
|
? connector.selfName!
|
||||||
|
: context.l10n.map_sharedPin;
|
||||||
|
final label = await promptForMarkerLabel(
|
||||||
|
context,
|
||||||
|
lat: lat,
|
||||||
|
lon: lon,
|
||||||
|
defaultLabel: initialLabel,
|
||||||
|
flags: 'poi',
|
||||||
|
);
|
||||||
|
if (label == null || label.trim().isEmpty) break;
|
||||||
|
if (!mounted || !menuContext.mounted) break;
|
||||||
|
final connector2 = context.read<MeshCoreConnector>();
|
||||||
|
final markerText =
|
||||||
|
'm:${lat.toStringAsFixed(6)},${lon.toStringAsFixed(6)}|${label.trim()}|poi';
|
||||||
|
connector2.sendMessage(
|
||||||
|
_resolveContact(connector2),
|
||||||
|
markerText,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
if (settings.translationEnabled)
|
if (settings.translationEnabled)
|
||||||
MessageTranslationButton(
|
MessageTranslationButton(
|
||||||
|
|||||||
+107
-29
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -36,6 +37,7 @@ import 'chat_screen.dart';
|
|||||||
import 'contacts_screen.dart';
|
import 'contacts_screen.dart';
|
||||||
import '../theme/mesh_theme.dart';
|
import '../theme/mesh_theme.dart';
|
||||||
import '../widgets/mesh_ui.dart';
|
import '../widgets/mesh_ui.dart';
|
||||||
|
import '../widgets/byte_count_input.dart';
|
||||||
import '../widgets/repeater_login_dialog.dart';
|
import '../widgets/repeater_login_dialog.dart';
|
||||||
import '../widgets/room_login_dialog.dart';
|
import '../widgets/room_login_dialog.dart';
|
||||||
import '../helpers/guessed_location_estimator.dart';
|
import '../helpers/guessed_location_estimator.dart';
|
||||||
@@ -3119,7 +3121,11 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final label = await _promptForLabel(context, defaultLabel);
|
final initialLabel =
|
||||||
|
connector.selfName == null || connector.selfName!.isEmpty
|
||||||
|
? defaultLabel
|
||||||
|
: connector.selfName!;
|
||||||
|
final label = await _promptForLabel(context, position, initialLabel, flags);
|
||||||
if (label == null || !mounted) return;
|
if (label == null || !mounted) return;
|
||||||
|
|
||||||
final markerText = _formatMarkerMessage(position, label, flags);
|
final markerText = _formatMarkerMessage(position, label, flags);
|
||||||
@@ -3135,42 +3141,114 @@ class _MapScreenState extends State<MapScreen> with DisconnectNavigationMixin {
|
|||||||
|
|
||||||
Future<String?> _promptForLabel(
|
Future<String?> _promptForLabel(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
|
LatLng position,
|
||||||
String defaultLabel,
|
String defaultLabel,
|
||||||
|
String flags,
|
||||||
) async {
|
) async {
|
||||||
final controller = TextEditingController(text: defaultLabel);
|
final controller = TextEditingController(text: defaultLabel);
|
||||||
controller.selection = TextSelection(
|
controller.selection = TextSelection(
|
||||||
baseOffset: 0,
|
baseOffset: 0,
|
||||||
extentOffset: controller.text.length,
|
extentOffset: controller.text.length,
|
||||||
);
|
);
|
||||||
return showDialog<String>(
|
final focusNode = FocusNode();
|
||||||
context: context,
|
// Compute available bytes for the label taking marker overhead into
|
||||||
builder: (dialogContext) => AlertDialog(
|
// account. Use a conservative limit based on both contact and channel
|
||||||
title: Text(context.l10n.map_pinLabel),
|
// message maxima.
|
||||||
content: TextField(
|
final lat = position.latitude.toStringAsFixed(6);
|
||||||
controller: controller,
|
final lon = position.longitude.toStringAsFixed(6);
|
||||||
decoration: InputDecoration(
|
final prefix = 'm:$lat,$lon|';
|
||||||
hintText: context.l10n.map_label,
|
final suffix = '|$flags';
|
||||||
border: const OutlineInputBorder(),
|
final overheadBytes = utf8.encode(prefix + suffix).length;
|
||||||
),
|
final maxForContact = maxContactMessageBytes();
|
||||||
),
|
final maxForChannel = maxChannelMessageBytes(null);
|
||||||
actions: [
|
final maxPayload = maxForContact < maxForChannel
|
||||||
TextButton(
|
? maxForContact
|
||||||
onPressed: () => Navigator.pop(dialogContext),
|
: maxForChannel;
|
||||||
child: Text(context.l10n.common_cancel),
|
final allowedLabelBytes = (maxPayload - overheadBytes) > 0
|
||||||
),
|
? (maxPayload - overheadBytes)
|
||||||
TextButton(
|
: 0;
|
||||||
onPressed: () {
|
|
||||||
final label = controller.text.trim().replaceAll('|', '/');
|
try {
|
||||||
Navigator.pop(
|
final result = await showDialog<String>(
|
||||||
dialogContext,
|
context: context,
|
||||||
label.isEmpty ? defaultLabel : label,
|
builder: (dialogContext) {
|
||||||
|
final scheme = Theme.of(dialogContext).colorScheme;
|
||||||
|
// Request focus and ensure selection after the frame so the
|
||||||
|
// keyboard appears and text is selected for replacement.
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (dialogContext.mounted) {
|
||||||
|
focusNode.requestFocus();
|
||||||
|
controller.selection = TextSelection(
|
||||||
|
baseOffset: 0,
|
||||||
|
extentOffset: controller.text.length,
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
child: Text(context.l10n.common_continue),
|
});
|
||||||
),
|
return AlertDialog(
|
||||||
],
|
title: Text(dialogContext.l10n.map_pinLabel),
|
||||||
),
|
content: ByteCountedTextField(
|
||||||
);
|
focusNode: focusNode,
|
||||||
|
maxBytes: allowedLabelBytes,
|
||||||
|
controller: controller,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: dialogContext.l10n.map_label,
|
||||||
|
helperText: dialogContext.l10n.map_labelUpdateHint,
|
||||||
|
helperMaxLines: 3,
|
||||||
|
helperStyle: TextStyle(
|
||||||
|
color: _overlaySecondaryTextColor,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(MeshRadii.md),
|
||||||
|
borderSide: BorderSide(color: scheme.outlineVariant),
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(MeshRadii.md),
|
||||||
|
borderSide: BorderSide(color: scheme.outlineVariant),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(MeshRadii.md),
|
||||||
|
borderSide: BorderSide(color: scheme.primary, width: 1.5),
|
||||||
|
),
|
||||||
|
filled: true,
|
||||||
|
fillColor: scheme.surfaceContainerLow,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 18,
|
||||||
|
vertical: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onSubmitted: (_) {
|
||||||
|
final label = controller.text.trim().replaceAll('|', '/');
|
||||||
|
Navigator.pop(
|
||||||
|
dialogContext,
|
||||||
|
label.isEmpty ? defaultLabel : label,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(dialogContext),
|
||||||
|
child: Text(dialogContext.l10n.common_cancel),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
final label = controller.text.trim().replaceAll('|', '/');
|
||||||
|
Navigator.pop(
|
||||||
|
dialogContext,
|
||||||
|
label.isEmpty ? defaultLabel : label,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Text(dialogContext.l10n.common_continue),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
} finally {
|
||||||
|
focusNode.dispose();
|
||||||
|
controller.dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String _formatMarkerMessage(LatLng position, String label, String flags) {
|
String _formatMarkerMessage(LatLng position, String label, String flags) {
|
||||||
|
|||||||
+65
-1
@@ -1 +1,65 @@
|
|||||||
{}
|
{
|
||||||
|
"bg": [
|
||||||
|
"map_labelUpdateHint"
|
||||||
|
],
|
||||||
|
|
||||||
|
"es": [
|
||||||
|
"map_labelUpdateHint"
|
||||||
|
],
|
||||||
|
|
||||||
|
"fr": [
|
||||||
|
"map_labelUpdateHint"
|
||||||
|
],
|
||||||
|
|
||||||
|
"hu": [
|
||||||
|
"map_labelUpdateHint"
|
||||||
|
],
|
||||||
|
|
||||||
|
"it": [
|
||||||
|
"map_labelUpdateHint"
|
||||||
|
],
|
||||||
|
|
||||||
|
"ja": [
|
||||||
|
"map_labelUpdateHint"
|
||||||
|
],
|
||||||
|
|
||||||
|
"ko": [
|
||||||
|
"map_labelUpdateHint"
|
||||||
|
],
|
||||||
|
|
||||||
|
"nl": [
|
||||||
|
"map_labelUpdateHint"
|
||||||
|
],
|
||||||
|
|
||||||
|
"pl": [
|
||||||
|
"map_labelUpdateHint"
|
||||||
|
],
|
||||||
|
|
||||||
|
"pt": [
|
||||||
|
"map_labelUpdateHint"
|
||||||
|
],
|
||||||
|
|
||||||
|
"ru": [
|
||||||
|
"map_labelUpdateHint"
|
||||||
|
],
|
||||||
|
|
||||||
|
"sk": [
|
||||||
|
"map_labelUpdateHint"
|
||||||
|
],
|
||||||
|
|
||||||
|
"sl": [
|
||||||
|
"map_labelUpdateHint"
|
||||||
|
],
|
||||||
|
|
||||||
|
"sv": [
|
||||||
|
"map_labelUpdateHint"
|
||||||
|
],
|
||||||
|
|
||||||
|
"uk": [
|
||||||
|
"map_labelUpdateHint"
|
||||||
|
],
|
||||||
|
|
||||||
|
"zh": [
|
||||||
|
"map_labelUpdateHint"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in new issue
Block a user