mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-08-17 00:20:40 +02:00
remove cameras from world map area
This commit is contained in:
@@ -421,7 +421,9 @@ class _OfflineAreasSectionState extends State<_OfflineAreasSection> {
|
|||||||
subtitle += '\nTiles: ${area.tilesTotal}';
|
subtitle += '\nTiles: ${area.tilesTotal}';
|
||||||
}
|
}
|
||||||
subtitle += '\nSize: $diskStr';
|
subtitle += '\nSize: $diskStr';
|
||||||
subtitle += '\nCameras: ${area.cameras.length}';
|
if (!area.isPermanent) {
|
||||||
|
subtitle += '\nCameras: ${area.cameras.length}';
|
||||||
|
}
|
||||||
return Card(
|
return Card(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: Icon(area.status == OfflineAreaStatus.complete
|
leading: Icon(area.status == OfflineAreaStatus.complete
|
||||||
@@ -436,46 +438,47 @@ class _OfflineAreasSectionState extends State<_OfflineAreasSection> {
|
|||||||
? area.name
|
? area.name
|
||||||
: 'Area ${area.id.substring(0, 6)}...'),
|
: 'Area ${area.id.substring(0, 6)}...'),
|
||||||
),
|
),
|
||||||
IconButton(
|
if (!area.isPermanent)
|
||||||
icon: const Icon(Icons.edit, size: 20),
|
IconButton(
|
||||||
tooltip: 'Rename area',
|
icon: const Icon(Icons.edit, size: 20),
|
||||||
onPressed: () async {
|
tooltip: 'Rename area',
|
||||||
String? newName = await showDialog<String>(
|
onPressed: () async {
|
||||||
context: context,
|
String? newName = await showDialog<String>(
|
||||||
builder: (ctx) {
|
context: context,
|
||||||
final ctrl = TextEditingController(text: area.name);
|
builder: (ctx) {
|
||||||
return AlertDialog(
|
final ctrl = TextEditingController(text: area.name);
|
||||||
title: const Text('Rename Offline Area'),
|
return AlertDialog(
|
||||||
content: TextField(
|
title: const Text('Rename Offline Area'),
|
||||||
controller: ctrl,
|
content: TextField(
|
||||||
maxLength: 40,
|
controller: ctrl,
|
||||||
decoration: const InputDecoration(labelText: 'Area Name'),
|
maxLength: 40,
|
||||||
autofocus: true,
|
decoration: const InputDecoration(labelText: 'Area Name'),
|
||||||
),
|
autofocus: true,
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.pop(ctx),
|
|
||||||
child: const Text('Cancel'),
|
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
actions: [
|
||||||
onPressed: () {
|
TextButton(
|
||||||
Navigator.pop(ctx, ctrl.text.trim());
|
onPressed: () => Navigator.pop(ctx),
|
||||||
},
|
child: const Text('Cancel'),
|
||||||
child: const Text('Rename'),
|
),
|
||||||
),
|
ElevatedButton(
|
||||||
],
|
onPressed: () {
|
||||||
);
|
Navigator.pop(ctx, ctrl.text.trim());
|
||||||
},
|
},
|
||||||
);
|
child: const Text('Rename'),
|
||||||
if (newName != null && newName.trim().isNotEmpty) {
|
),
|
||||||
setState(() {
|
],
|
||||||
area.name = newName.trim();
|
);
|
||||||
service.saveAreasToDisk();
|
},
|
||||||
});
|
);
|
||||||
}
|
if (newName != null && newName.trim().isNotEmpty) {
|
||||||
},
|
setState(() {
|
||||||
),
|
area.name = newName.trim();
|
||||||
if (area.isPermanent)
|
service.saveAreasToDisk();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (area.isPermanent && area.status != OfflineAreaStatus.downloading)
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.refresh, color: Colors.blue),
|
icon: const Icon(Icons.refresh, color: Colors.blue),
|
||||||
tooltip: 'Refresh/re-download world tiles',
|
tooltip: 'Refresh/re-download world tiles',
|
||||||
@@ -494,7 +497,7 @@ class _OfflineAreasSectionState extends State<_OfflineAreasSection> {
|
|||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
else if (area.status != OfflineAreaStatus.downloading)
|
else if (!area.isPermanent && area.status != OfflineAreaStatus.downloading)
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.delete, color: Colors.red),
|
icon: const Icon(Icons.delete, color: Colors.red),
|
||||||
tooltip: 'Delete offline area',
|
tooltip: 'Delete offline area',
|
||||||
|
|||||||
@@ -212,9 +212,13 @@ class OfflineAreaService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// STEP 2: Fetch cameras for this bbox (all, not limited!)
|
// STEP 2: Fetch cameras for this bbox (all, not limited!)
|
||||||
final cameras = await _downloadAllCameras(bounds);
|
if (!area.isPermanent) {
|
||||||
area.cameras = cameras;
|
final cameras = await _downloadAllCameras(bounds);
|
||||||
await _saveCameras(cameras, directory);
|
area.cameras = cameras;
|
||||||
|
await _saveCameras(cameras, directory);
|
||||||
|
} else {
|
||||||
|
area.cameras = [];
|
||||||
|
}
|
||||||
await getAreaSizeBytes(area);
|
await getAreaSizeBytes(area);
|
||||||
|
|
||||||
area.status = OfflineAreaStatus.complete;
|
area.status = OfflineAreaStatus.complete;
|
||||||
|
|||||||
Reference in New Issue
Block a user