mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
possibility to change label from default: 'devicename: isotimestamp'
This commit is contained in:
parent
75aa1a231a
commit
f057d6b370
2 changed files with 57 additions and 7 deletions
|
|
@ -855,7 +855,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
|||
);
|
||||
}
|
||||
|
||||
void _shareLocation() {
|
||||
Future<void> _shareLocation() async {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final lat = connector.selfLatitude;
|
||||
final lon = connector.selfLongitude;
|
||||
|
|
@ -866,8 +866,34 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
|||
return;
|
||||
}
|
||||
|
||||
final label =
|
||||
final defaultLabel =
|
||||
'${connector.deviceDisplayName} ${DateTime.now().toUtc().toIso8601String()}';
|
||||
final controller = TextEditingController(text: defaultLabel);
|
||||
|
||||
final label = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(context.l10n.chat_shareLocation),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
decoration: InputDecoration(labelText: context.l10n.chat_location),
|
||||
autofocus: true,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(context.l10n.common_cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, controller.text.trim()),
|
||||
child: Text(context.l10n.common_save),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (label == null || label.isEmpty) return;
|
||||
|
||||
final markerText =
|
||||
'm:${lat.toStringAsFixed(6)},${lon.toStringAsFixed(6)}|$label|loc';
|
||||
connector.sendChannelMessage(widget.channel, markerText);
|
||||
|
|
|
|||
|
|
@ -505,7 +505,7 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||
);
|
||||
}
|
||||
|
||||
void _shareLocation(MeshCoreConnector connector) async {
|
||||
Future<void> _shareLocation(MeshCoreConnector connector) async {
|
||||
final lat = connector.selfLatitude;
|
||||
final lon = connector.selfLongitude;
|
||||
if (lat == null || lon == null) {
|
||||
|
|
@ -515,10 +515,34 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||
return;
|
||||
}
|
||||
|
||||
// Use the contact name + ISO timestamp as the marker label so the recipient
|
||||
// can see when the location was shared.
|
||||
final label =
|
||||
'${widget.contact.name}: ${DateTime.now().toUtc().toIso8601String()}';
|
||||
final defaultLabel =
|
||||
'${connector.deviceDisplayName} ${DateTime.now().toUtc().toIso8601String()}';
|
||||
final controller = TextEditingController(text: defaultLabel);
|
||||
|
||||
final label = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(context.l10n.chat_shareLocation),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
decoration: InputDecoration(labelText: context.l10n.chat_location),
|
||||
autofocus: true,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(context.l10n.common_cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, controller.text.trim()),
|
||||
child: Text(context.l10n.common_save),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (label == null || label.isEmpty) return;
|
||||
|
||||
final markerText =
|
||||
'm:${lat.toStringAsFixed(6)},${lon.toStringAsFixed(6)}|$label|loc';
|
||||
connector.sendMessage(widget.contact, markerText);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue