Route distance timeout warning

This commit is contained in:
stopflock
2025-12-06 15:07:34 -06:00
parent b02623deac
commit 4fba26ff55
7 changed files with 81 additions and 3 deletions
+2
View File
@@ -114,6 +114,8 @@ class AppState extends ChangeNotifier {
bool get settingRouteStart => _navigationState.settingRouteStart;
bool get isSettingSecondPoint => _navigationState.isSettingSecondPoint;
bool get areRoutePointsTooClose => _navigationState.areRoutePointsTooClose;
double? get distanceFromFirstPoint => _navigationState.distanceFromFirstPoint;
bool get distanceExceedsWarningThreshold => _navigationState.distanceExceedsWarningThreshold;
bool get isCalculating => _navigationState.isCalculating;
bool get showingOverview => _navigationState.showingOverview;
String? get routingError => _navigationState.routingError;
+1
View File
@@ -128,6 +128,7 @@ const double kNodeProximityWarningDistance = 15.0; // meters - distance threshol
// Navigation route planning configuration
const double kNavigationMinRouteDistance = 100.0; // meters - minimum distance between start and end points
const double kNavigationDistanceWarningThreshold = 20000.0; // meters - distance threshold for timeout warning (30km)
// Node display configuration
const int kDefaultMaxNodes = 500; // Default maximum number of nodes to render on the map at once
+18
View File
@@ -87,6 +87,24 @@ class NavigationState extends ChangeNotifier {
return distance < kNavigationMinRouteDistance;
}
/// Get distance from first navigation point to provisional location during second point selection
double? get distanceFromFirstPoint {
if (!_isSettingSecondPoint || _provisionalPinLocation == null) return null;
final firstPoint = _nextPointIsStart ? _routeEnd : _routeStart;
if (firstPoint == null) return null;
return const Distance().as(LengthUnit.Meter, firstPoint, _provisionalPinLocation!);
}
/// Check if distance between points would likely cause timeout issues
bool get distanceExceedsWarningThreshold {
final distance = distanceFromFirstPoint;
if (distance == null) return false;
return distance > kNavigationDistanceWarningThreshold;
}
/// BRUTALIST: Single entry point to search mode
void enterSearchMode(LatLng mapCenter) {
debugPrint('[NavigationState] enterSearchMode - current mode: $_mode');
+44 -1
View File
@@ -161,7 +161,50 @@ class NavigationSheet extends StatelessWidget {
coordinates: provisionalLocation,
address: provisionalAddress,
),
const SizedBox(height: 16),
const SizedBox(height: 8),
// Show distance from first point
if (appState.distanceFromFirstPoint != null) ...[
Text(
'Distance: ${(appState.distanceFromFirstPoint! / 1000).toStringAsFixed(1)} km',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.grey[600],
),
),
const SizedBox(height: 8),
],
// Show distance warning if threshold exceeded
if (appState.distanceExceedsWarningThreshold) ...[
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.amber.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
border: Border.all(color: Colors.amber.withOpacity(0.3)),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Icons.warning_amber, color: Colors.amber[700], size: 20),
const SizedBox(width: 8),
Expanded(
child: Text(
'Trips longer than ${(kNavigationDistanceWarningThreshold / 1000).toStringAsFixed(0)} km are likely to time out. We are working to improve this; stay tuned.',
style: TextStyle(
fontSize: 14,
color: Colors.amber[700],
),
),
),
],
),
),
const SizedBox(height: 8),
],
// Show warning message if locations are too close
if (appState.areRoutePointsTooClose) ...[