Allow OSM offline downloads, disable button for restricted providers

Allow offline area downloads for OSM tile server. Move the "downloads
not permitted" check from inside the download dialog to the download
button itself — the button is now disabled (greyed out) when the
current tile type doesn't support offline downloads.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Doug Borg
2026-03-04 09:47:42 -07:00
parent 2d92214bed
commit f3f40f36ef
4 changed files with 38 additions and 70 deletions
-36
View File
@@ -267,42 +267,6 @@ class _DownloadAreaDialogState extends State<DownloadAreaDialog> {
final selectedProvider = appState.selectedTileProvider;
final selectedTileType = appState.selectedTileType;
// Check if the tile provider allows offline downloads
if (selectedTileType != null && !selectedTileType.allowsOfflineDownload) {
if (!context.mounted) return;
// Capture navigator before popping, since context is
// deactivated after Navigator.pop.
final navigator = Navigator.of(context);
navigator.pop();
showDialog(
context: navigator.context,
builder: (context) => AlertDialog(
title: Row(
children: [
const Icon(Icons.block, color: Colors.orange),
const SizedBox(width: 10),
Text(locService.t('download.title')),
],
),
content: Text(
locService.t(
'download.offlineNotPermitted',
params: [
selectedProvider?.name ?? locService.t('download.currentTileProvider'),
],
),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(locService.t('actions.ok')),
),
],
),
);
return;
}
// Guard: provider and tile type must be non-null for a
// useful offline area (fetchLocalTile requires exact match).
if (selectedProvider == null || selectedTileType == null) {