mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
ran formating
This commit is contained in:
parent
978ea4790d
commit
d1009d3c20
2 changed files with 50 additions and 33 deletions
|
|
@ -687,24 +687,24 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
_gpxExport(GpxExport exporter) async {
|
||||
final l10n = context.l10n;
|
||||
final result = await exporter.exportGPX();
|
||||
if(!mounted) return;
|
||||
if (!mounted) return;
|
||||
switch (result) {
|
||||
case gpxExportSuccess:
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(l10n.settings_gpxExportSuccess)));
|
||||
case gpxExportNoContacts:
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(l10n.settings_gpxExportNoContacts)));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(l10n.settings_gpxExportNoContacts)),
|
||||
);
|
||||
case gpxExportNotAvailable:
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(l10n.settings_gpxExportNotAvailable)));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(l10n.settings_gpxExportNotAvailable)),
|
||||
);
|
||||
case gpxExportFailed:
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
|
|
@ -728,7 +728,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||
_gpxExport(exporter);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
ListTile(
|
||||
leading: const Icon(Icons.download_outlined),
|
||||
title: Text(l10n.settings_gpxExportContacts),
|
||||
subtitle: Text(l10n.settings_gpxExportContactsSubtitle),
|
||||
|
|
|
|||
|
|
@ -35,19 +35,29 @@ class GpxExport {
|
|||
|
||||
GpxExport(this._connector);
|
||||
|
||||
void _addContact(String name, double lat, double lon, String desc, [double? ele]) {
|
||||
_contacts.add(ContactExport(
|
||||
name: name.trim(),
|
||||
lat: lat,
|
||||
lon: lon,
|
||||
desc: desc.trim(),
|
||||
ele: ele,
|
||||
));
|
||||
void _addContact(
|
||||
String name,
|
||||
double lat,
|
||||
double lon,
|
||||
String desc, [
|
||||
double? ele,
|
||||
]) {
|
||||
_contacts.add(
|
||||
ContactExport(
|
||||
name: name.trim(),
|
||||
lat: lat,
|
||||
lon: lon,
|
||||
desc: desc.trim(),
|
||||
ele: ele,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void addRepeaters() {
|
||||
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) {
|
||||
if (repeater.latitude == null || repeater.longitude == null) {
|
||||
continue;
|
||||
|
|
@ -79,7 +89,7 @@ class GpxExport {
|
|||
|
||||
void addAll() {
|
||||
final contacts = _connector.contacts;
|
||||
for (var repeater in contacts.toList()) {
|
||||
for (var repeater in contacts.toList()) {
|
||||
if (repeater.latitude == null || repeater.longitude == null) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -104,24 +114,30 @@ class GpxExport {
|
|||
..version = '1.1'
|
||||
..creator = 'meshcore-open Repeater Exporter'
|
||||
..metadata = Metadata(
|
||||
name: 'Meshcore Repeaters',
|
||||
desc: 'Repeater & room locations exported from meshcore-open',
|
||||
time: DateTime.now().toUtc(),
|
||||
);
|
||||
name: 'Meshcore Repeaters',
|
||||
desc: 'Repeater & room locations exported from meshcore-open',
|
||||
time: DateTime.now().toUtc(),
|
||||
);
|
||||
|
||||
gpx.wpts = _contacts.map((c) => Wpt(
|
||||
lat: c.lat,
|
||||
lon: c.lon,
|
||||
ele: c.ele,
|
||||
name: c.name,
|
||||
desc: c.desc,
|
||||
)).toList();
|
||||
gpx.wpts = _contacts
|
||||
.map(
|
||||
(c) => Wpt(
|
||||
lat: c.lat,
|
||||
lon: c.lon,
|
||||
ele: c.ele,
|
||||
name: c.name,
|
||||
desc: c.desc,
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
|
||||
final xml = GpxWriter().asString(gpx, pretty: true);
|
||||
|
||||
// 2. Save to file
|
||||
final dir = await getApplicationDocumentsDirectory();
|
||||
final timestamp = DateTime.now().toUtc().toIso8601String()
|
||||
final timestamp = DateTime.now()
|
||||
.toUtc()
|
||||
.toIso8601String()
|
||||
.replaceAll(':', '-')
|
||||
.replaceAll('.', '-')
|
||||
.split('T')
|
||||
|
|
@ -134,7 +150,8 @@ class GpxExport {
|
|||
// 3. Modern share call (2025+ style)
|
||||
final result = await SharePlus.instance.share(
|
||||
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',
|
||||
files: [XFile(path)],
|
||||
// Optional: sharePositionOrigin: ... (if you want iPad popover positioning)
|
||||
|
|
@ -162,4 +179,4 @@ class GpxExport {
|
|||
}
|
||||
return gpxExportFailed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue