mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-02-12 16:52:51 +00:00
Area size estimates based on preview tile size if available
This commit is contained in:
@@ -3,8 +3,8 @@ import 'package:flutter/material.dart';
|
||||
|
||||
/// Developer/build-time configuration for global/non-user-tunable constants.
|
||||
|
||||
// Example: Default tile storage estimate (KB per tile), for size estimates
|
||||
const double kTileEstimateKb = 25.0;
|
||||
// Fallback tile storage estimate (KB per tile), used when no preview tile data is available
|
||||
const double kFallbackTileEstimateKb = 25.0;
|
||||
|
||||
// Direction cone for map view
|
||||
const double kDirectionConeHalfAngle = 30.0; // degrees
|
||||
|
||||
@@ -62,7 +62,8 @@ class _DownloadAreaDialogState extends State<DownloadAreaDialog> {
|
||||
final maxPossibleZoom = _calculateMaxZoomForTileLimit(bounds, minZoom);
|
||||
|
||||
final nTiles = computeTileList(bounds, minZoom, maxZoom).length;
|
||||
final totalMb = (nTiles * kTileEstimateKb) / 1024.0;
|
||||
final tileEstimateKb = _getTileEstimateKb();
|
||||
final totalMb = (nTiles * tileEstimateKb) / 1024.0;
|
||||
final roundedMb = (totalMb * 10).round() / 10; // Round to nearest tenth
|
||||
|
||||
setState(() {
|
||||
@@ -84,8 +85,22 @@ class _DownloadAreaDialogState extends State<DownloadAreaDialog> {
|
||||
}
|
||||
return kAbsoluteMaxZoom;
|
||||
}
|
||||
|
||||
|
||||
/// Get tile size estimate in KB, using preview tile data if available, otherwise fallback to constant
|
||||
double _getTileEstimateKb() {
|
||||
final appState = context.read<AppState>();
|
||||
final selectedTileType = appState.selectedTileType;
|
||||
|
||||
if (selectedTileType?.previewTile != null) {
|
||||
// Use actual preview tile size
|
||||
final previewSizeBytes = selectedTileType!.previewTile!.length;
|
||||
final previewSizeKb = previewSizeBytes / 1024.0;
|
||||
return previewSizeKb;
|
||||
} else {
|
||||
// Fall back to configured estimate
|
||||
return kFallbackTileEstimateKb;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
Reference in New Issue
Block a user