mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-26 13:36:39 +10:00
ran formating
This commit is contained in:
@@ -687,24 +687,24 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_gpxExport(GpxExport exporter) async {
|
_gpxExport(GpxExport exporter) async {
|
||||||
final l10n = context.l10n;
|
final l10n = context.l10n;
|
||||||
final result = await exporter.exportGPX();
|
final result = await exporter.exportGPX();
|
||||||
if(!mounted) return;
|
if (!mounted) return;
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case gpxExportSuccess:
|
case gpxExportSuccess:
|
||||||
ScaffoldMessenger.of(
|
ScaffoldMessenger.of(
|
||||||
context,
|
context,
|
||||||
).showSnackBar(SnackBar(content: Text(l10n.settings_gpxExportSuccess)));
|
).showSnackBar(SnackBar(content: Text(l10n.settings_gpxExportSuccess)));
|
||||||
case gpxExportNoContacts:
|
case gpxExportNoContacts:
|
||||||
ScaffoldMessenger.of(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
context,
|
SnackBar(content: Text(l10n.settings_gpxExportNoContacts)),
|
||||||
).showSnackBar(SnackBar(content: Text(l10n.settings_gpxExportNoContacts)));
|
);
|
||||||
case gpxExportNotAvailable:
|
case gpxExportNotAvailable:
|
||||||
ScaffoldMessenger.of(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
context,
|
SnackBar(content: Text(l10n.settings_gpxExportNotAvailable)),
|
||||||
).showSnackBar(SnackBar(content: Text(l10n.settings_gpxExportNotAvailable)));
|
);
|
||||||
case gpxExportFailed:
|
case gpxExportFailed:
|
||||||
ScaffoldMessenger.of(
|
ScaffoldMessenger.of(
|
||||||
context,
|
context,
|
||||||
@@ -728,7 +728,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
_gpxExport(exporter);
|
_gpxExport(exporter);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.download_outlined),
|
leading: const Icon(Icons.download_outlined),
|
||||||
title: Text(l10n.settings_gpxExportContacts),
|
title: Text(l10n.settings_gpxExportContacts),
|
||||||
subtitle: Text(l10n.settings_gpxExportContactsSubtitle),
|
subtitle: Text(l10n.settings_gpxExportContactsSubtitle),
|
||||||
|
|||||||
+41
-24
@@ -35,19 +35,29 @@ class GpxExport {
|
|||||||
|
|
||||||
GpxExport(this._connector);
|
GpxExport(this._connector);
|
||||||
|
|
||||||
void _addContact(String name, double lat, double lon, String desc, [double? ele]) {
|
void _addContact(
|
||||||
_contacts.add(ContactExport(
|
String name,
|
||||||
name: name.trim(),
|
double lat,
|
||||||
lat: lat,
|
double lon,
|
||||||
lon: lon,
|
String desc, [
|
||||||
desc: desc.trim(),
|
double? ele,
|
||||||
ele: ele,
|
]) {
|
||||||
));
|
_contacts.add(
|
||||||
|
ContactExport(
|
||||||
|
name: name.trim(),
|
||||||
|
lat: lat,
|
||||||
|
lon: lon,
|
||||||
|
desc: desc.trim(),
|
||||||
|
ele: ele,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addRepeaters() {
|
void addRepeaters() {
|
||||||
final contacts = _connector.contacts;
|
final contacts = _connector.contacts;
|
||||||
final repeaters = contacts.where((c) => c.type == advTypeRepeater || c.type == advTypeRoom).toList();
|
final repeaters = contacts
|
||||||
|
.where((c) => c.type == advTypeRepeater || c.type == advTypeRoom)
|
||||||
|
.toList();
|
||||||
for (var repeater in repeaters) {
|
for (var repeater in repeaters) {
|
||||||
if (repeater.latitude == null || repeater.longitude == null) {
|
if (repeater.latitude == null || repeater.longitude == null) {
|
||||||
continue;
|
continue;
|
||||||
@@ -79,7 +89,7 @@ class GpxExport {
|
|||||||
|
|
||||||
void addAll() {
|
void addAll() {
|
||||||
final contacts = _connector.contacts;
|
final contacts = _connector.contacts;
|
||||||
for (var repeater in contacts.toList()) {
|
for (var repeater in contacts.toList()) {
|
||||||
if (repeater.latitude == null || repeater.longitude == null) {
|
if (repeater.latitude == null || repeater.longitude == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -104,24 +114,30 @@ class GpxExport {
|
|||||||
..version = '1.1'
|
..version = '1.1'
|
||||||
..creator = 'meshcore-open Repeater Exporter'
|
..creator = 'meshcore-open Repeater Exporter'
|
||||||
..metadata = Metadata(
|
..metadata = Metadata(
|
||||||
name: 'Meshcore Repeaters',
|
name: 'Meshcore Repeaters',
|
||||||
desc: 'Repeater & room locations exported from meshcore-open',
|
desc: 'Repeater & room locations exported from meshcore-open',
|
||||||
time: DateTime.now().toUtc(),
|
time: DateTime.now().toUtc(),
|
||||||
);
|
);
|
||||||
|
|
||||||
gpx.wpts = _contacts.map((c) => Wpt(
|
gpx.wpts = _contacts
|
||||||
lat: c.lat,
|
.map(
|
||||||
lon: c.lon,
|
(c) => Wpt(
|
||||||
ele: c.ele,
|
lat: c.lat,
|
||||||
name: c.name,
|
lon: c.lon,
|
||||||
desc: c.desc,
|
ele: c.ele,
|
||||||
)).toList();
|
name: c.name,
|
||||||
|
desc: c.desc,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
|
|
||||||
final xml = GpxWriter().asString(gpx, pretty: true);
|
final xml = GpxWriter().asString(gpx, pretty: true);
|
||||||
|
|
||||||
// 2. Save to file
|
// 2. Save to file
|
||||||
final dir = await getApplicationDocumentsDirectory();
|
final dir = await getApplicationDocumentsDirectory();
|
||||||
final timestamp = DateTime.now().toUtc().toIso8601String()
|
final timestamp = DateTime.now()
|
||||||
|
.toUtc()
|
||||||
|
.toIso8601String()
|
||||||
.replaceAll(':', '-')
|
.replaceAll(':', '-')
|
||||||
.replaceAll('.', '-')
|
.replaceAll('.', '-')
|
||||||
.split('T')
|
.split('T')
|
||||||
@@ -134,7 +150,8 @@ class GpxExport {
|
|||||||
// 3. Modern share call (2025+ style)
|
// 3. Modern share call (2025+ style)
|
||||||
final result = await SharePlus.instance.share(
|
final result = await SharePlus.instance.share(
|
||||||
ShareParams(
|
ShareParams(
|
||||||
text: 'Repeater locations exported from meshcore-open app as GPX file.',
|
text:
|
||||||
|
'Repeater locations exported from meshcore-open app as GPX file.',
|
||||||
subject: 'Meshcore Repeaters GPX Export',
|
subject: 'Meshcore Repeaters GPX Export',
|
||||||
files: [XFile(path)],
|
files: [XFile(path)],
|
||||||
// Optional: sharePositionOrigin: ... (if you want iPad popover positioning)
|
// Optional: sharePositionOrigin: ... (if you want iPad popover positioning)
|
||||||
@@ -162,4 +179,4 @@ class GpxExport {
|
|||||||
}
|
}
|
||||||
return gpxExportFailed;
|
return gpxExportFailed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user