Compare commits

...

9 Commits

Author SHA1 Message Date
stopflock
adbe8c340c increase nav timeout to 2m 2025-12-05 17:06:14 -06:00
stopflock
8c4f53ff7b nav UX tweaks 2025-12-05 16:36:04 -06:00
stopflock
b1a39a2320 roadmap 2025-12-05 16:03:12 -06:00
stopflock
59064f7165 Get rid of errant "default 250" in max nodes localizations 2025-12-05 15:50:40 -06:00
stopflock
24214e94f9 Fix node edge blinking, prevent nav+edit conflicts, smarter follow-me w/rt nav 2025-12-05 15:27:01 -06:00
stopflock
6cda350f22 Got rid of some redundant / can never happen type of if statements 2025-12-04 21:12:17 -06:00
stopflock
89f8ad2e0a Clean up nav state when offline mode is enabled 2025-12-04 19:34:51 -06:00
stopflock
cc1a335a49 Fix search/nav button offline behavior 2025-12-04 19:08:18 -06:00
stopflock
473d65c83e Was accidentally calling edit sheet on node tap instead of tags shet 2025-12-04 18:29:43 -06:00
22 changed files with 381 additions and 83 deletions

View File

@@ -101,12 +101,7 @@ cp lib/keys.dart.example lib/keys.dart
- Are offline areas preferred for fast loading even when online? Check working.
### Current Development
- Decide what to do for extracting nodes attached to a way/relation:
- Auto extract (how?)
- Leave it alone (wrong answer unless user chooses intentionally)
- Manual cleanup (cognitive load for users)
- Delete the old one (also wrong answer unless user chooses intentionally)
- Give multiple of these options??
- Optional reason message when deleting
- Dropdown on "refine tags" page to select acceptable options for camera:mount= (is this a boolean property of a profile?)
- Option to pull in profiles from NSI (man_made=surveillance only?)
@@ -127,6 +122,12 @@ cp lib/keys.dart.example lib/keys.dart
- Grab the full latest database for each profile just like for suspected locations (instead of overpass)
- Optional custom icons for profiles to aid identification
- Custom device providers and OSM/Overpass alternatives
- Offer options for extracting nodes which are attached to a way/relation:
- Auto extract (how?)
- Leave it alone (wrong answer unless user chooses intentionally)
- Manual cleanup (cognitive load for users)
- Delete the old one (also wrong answer unless user chooses intentionally)
- Give multiple of these options??
---

147
V1.6.2_CHANGES_SUMMARY.md Normal file
View File

@@ -0,0 +1,147 @@
# v1.6.2 Changes Summary
## Issues Addressed
### 1. Navigation Interaction Conflict Prevention
**Problem**: When navigation sheet is open (route planning or route overview) and user taps a node to view tags, competing UI states create conflicts and inconsistent behavior.
**Root Cause**: Two interaction modes trying to operate simultaneously:
- **Route planning/overview** (temporary selection states)
- **Node examination** (inspect/edit individual devices)
**Solution**: **Prevention over management** - disable conflicting interactions entirely:
- Nodes and suspected locations are **dimmed and non-clickable** during `isInSearchMode` or `showingOverview`
- Visual feedback (0.5 opacity) indicates interactive elements are temporarily disabled
- Clean UX: users must complete/cancel navigation before examining nodes
**Brutalist Approach**: Prevent the conflict from ever happening rather than managing complex state transitions. Single condition check disables taps and applies dimming consistently across all interactive map elements.
### 2. Node Edge Blinking Bug
**Problem**: Nodes appear/disappear exactly when their centers cross screen edges, causing "blinking" effect as they pop in/out of existence at screen periphery.
**Root Cause**: Node rendering uses exact `camera.visibleBounds` while data prefetching expands bounds by 3x. This creates a mismatch where data exists but isn't rendered until nodes cross the exact screen boundary.
**Solution**: Expanded rendering bounds by 1.3x while keeping data prefetch at 3x:
- Added `kNodeRenderingBoundsExpansion = 1.3` constant in `dev_config.dart`
- Added `_expandBounds()` method to `MapDataManager` (reusing proven logic from prefetch service)
- Modified `getNodesForRendering()` to use expanded bounds for rendering decisions
- Nodes now appear before sliding into view and stay visible until after sliding out
**Brutalist Approach**: Simple bounds expansion using proven mathematical logic. No complex visibility detection or animation state tracking.
### 3. Route Overview Follow-Me Management
**Problem**: Route overview didn't disable follow-me mode, causing unexpected map jumps. Route resume didn't intelligently handle follow-me based on user proximity to route.
**Root Cause**: No coordination between route overview display and follow-me mode. Resume logic didn't consider user location relative to route path.
**Solution**: Smart follow-me management for route overview workflow:
- **Opening overview**: Store current follow-me mode and disable it to prevent map jumps
- **Resume from overview**: Check if user is within configurable distance (500m) of route path
- **Near route**: Center on GPS location and restore previous follow-me mode
- **Far from route**: Center on route start without follow-me
- **Zoom level**: Use level 16 for resume instead of 14
**Brutalist Approach**: Simple distance-to-route calculation with clear decision logic. No complex state machine - just store/restore with proximity-based decisions.
## Files Modified
### Core Logic Changes
- `lib/widgets/map/map_data_manager.dart` - Added bounds expansion for node rendering
- `lib/dev_config.dart` - Added rendering bounds expansion constant
### Navigation Interaction Prevention
- `lib/widgets/map/marker_layer_builder.dart` - Added dimming and tap disabling for conflicting navigation states
- `lib/widgets/map/node_markers.dart` - Added `enabled` parameter to prevent tap handler fallbacks
- `lib/widgets/map/suspected_location_markers.dart` - Added `enabled` and `shouldDimAll` parameters for consistent behavior
- Removed navigation state cleanup code (prevention approach eliminates need)
### Route Overview Follow-Me Management
- `lib/screens/coordinators/navigation_coordinator.dart` - Added follow-me tracking and smart resume logic
- `lib/dev_config.dart` - Added route proximity threshold and resume zoom level constants
### Version & Documentation
- `pubspec.yaml` - Updated to v1.6.2+28
- `assets/changelog.json` - Added v1.6.2 changelog entry
- `V1.6.2_CHANGES_SUMMARY.md` - This documentation
## Technical Implementation Details
### Navigation Interaction Prevention Pattern
```dart
// Disable node interactions when navigation is in conflicting state
final shouldDisableNodeTaps = appState.isInSearchMode || appState.showingOverview;
// Apply to all interactive elements
onNodeTap: shouldDisableNodeTaps ? null : onNodeTap,
onLocationTap: shouldDisableNodeTaps ? null : onSuspectedLocationTap,
shouldDim: shouldDisableNodeTaps, // Visual feedback via dimming
```
This pattern prevents conflicts by making competing interactions impossible rather than trying to resolve them after they occur.
### Bounds Expansion Implementation
```dart
/// Expand bounds by the given multiplier, maintaining center point.
/// Used to expand rendering bounds to prevent nodes blinking at screen edges.
LatLngBounds _expandBounds(LatLngBounds bounds, double multiplier) {
final centerLat = (bounds.north + bounds.south) / 2;
final centerLng = (bounds.east + bounds.west) / 2;
final latSpan = (bounds.north - bounds.south) * multiplier / 2;
final lngSpan = (bounds.east - bounds.west) * multiplier / 2;
return LatLngBounds(
LatLng(centerLat - latSpan, centerLng - lngSpan),
LatLng(centerLat + latSpan, centerLng + lngSpan),
);
}
```
The expansion maintains the center point while scaling the bounds uniformly. Factor of 1.3x provides smooth transitions without excessive over-rendering.
## Testing Recommendations
### Issue 1 - Navigation Interaction Prevention
1. **Search mode dimming**: Enter search mode → verify all nodes and suspected locations are dimmed (0.5 opacity)
2. **Search mode taps disabled**: In search mode → tap dimmed nodes → verify no response (no tag sheet opens)
3. **Route overview dimming**: Start route → open route overview → verify nodes are dimmed and non-clickable
4. **Active route compatibility**: Follow active route (no overview) → tap nodes → verify tag sheets open normally
5. **Visual consistency**: Compare dimming with existing selected node dimming behavior
6. **Suspected location consistency**: Verify suspected locations dim and disable the same as nodes
### Issue 2 - Node Edge Blinking
1. **Pan testing**: Pan map slowly and verify nodes appear smoothly before entering view (not popping in at edge)
2. **Pan exit**: Pan map to move nodes out of view and verify they disappear smoothly after leaving view
3. **Zoom testing**: Zoom in/out and verify nodes don't blink during zoom operations
4. **Performance**: Verify expanded rendering doesn't cause performance issues with high node counts
5. **Different zoom levels**: Test at various zoom levels to ensure expansion works consistently
### Regression Testing
1. **Navigation functionality**: Verify all navigation features still work normally (search, route planning, active navigation)
2. **Sheet interactions**: Verify all sheet types (tag, edit, add, suspected location) still open/close properly
3. **Map interactions**: Verify node selection, editing, and map controls work normally
4. **Performance**: Monitor for any performance degradation from bounds expansion
## Architecture Notes
### Why Brutalist Approach Succeeded
Both fixes follow the "brutalist code" philosophy:
1. **Simple, explicit solutions** rather than complex state management
2. **Consistent patterns** applied uniformly across similar situations
3. **Clear failure points** with obvious debugging paths
4. **No clever abstractions** that could hide bugs
### Bounds Expansion Benefits
- **Mathematical simplicity**: Reuses proven bounds expansion logic
- **Performance aware**: 1.3x expansion provides smooth UX without excessive computation
- **Configurable**: Expansion factor isolated in dev_config for easy adjustment
- **Future-proof**: Could easily add different expansion factors for different scenarios
### Interaction Prevention Benefits
- **Eliminates complexity**: No state transition management needed
- **Clear visual feedback**: Users understand when interactions are disabled
- **Consistent behavior**: Same dimming/disabling across all interactive elements
- **Fewer edge cases**: Impossible states can't occur
- **Negative code commit**: Removed more code than added
This approach ensures robust, maintainable code that handles edge cases gracefully while remaining easy to understand and modify.

View File

@@ -1,8 +1,23 @@
{
"1.6.3": {
"content": [
"• Fixed navigation sheet button flow - route to/from buttons no longer reappear after selecting second location",
"• Added cancel button when selecting second route point for easier exit from route planning"
]
},
"1.6.2": {
"content": [
"• Improved node rendering bounds - nodes appear slightly before sliding into view and stay visible until just after sliding out, eliminating edge blinking",
"• Navigation interaction conflict prevention - nodes and suspected locations are now dimmed and non-clickable during route planning and route overview to prevent state conflicts",
"• Enhanced route overview behavior - follow-me is automatically disabled when opening overview and intelligently restored when resuming based on proximity to route",
"• Smart route resume - centers on GPS location with follow-me if near route, or route start without follow-me if far away, with configurable proximity threshold"
]
},
"1.6.1": {
"content": [
"• IMPROVED: Navigation route calculation timeout increased from 15 to 30 seconds - better success rate for complex routes in dense areas",
"• TECHNICAL: Route timeout is now configurable in dev_config for easier future adjustments"
"• Navigation route calculation timeout increased from 15 to 30 seconds - better success rate for complex routes in dense areas",
"• Route timeout is now configurable in dev_config for easier future adjustments",
"• Fix accidentally opening edit sheet on node tap instead of tags sheet"
]
},
"1.6.0": {

View File

@@ -61,7 +61,7 @@ const Duration kChangesetAutoCloseTimeout = Duration(minutes: 59); // Give up an
const double kChangesetCloseBackoffMultiplier = 2.0;
// Navigation routing configuration
const Duration kNavigationRoutingTimeout = Duration(seconds: 30); // HTTP timeout for routing requests
const Duration kNavigationRoutingTimeout = Duration(seconds: 120); // HTTP timeout for routing requests
// Suspected locations CSV URL
const String kSuspectedLocationsCsvUrl = 'https://alprwatch.org/suspected-locations/deflock-latest.csv';
@@ -93,6 +93,9 @@ const Duration kDebounceCameraRefresh = Duration(milliseconds: 500);
// Pre-fetch area configuration
const double kPreFetchAreaExpansionMultiplier = 3.0; // Expand visible bounds by this factor for pre-fetching
const double kNodeRenderingBoundsExpansion = 1.3; // Expand visible bounds by this factor for node rendering to prevent edge blinking
const double kRouteProximityThresholdMeters = 500.0; // Distance threshold for determining if user is near route when resuming navigation
const double kResumeNavigationZoomLevel = 16.0; // Zoom level when resuming navigation
const int kPreFetchZoomLevel = 10; // Always pre-fetch at this zoom level for consistent area sizes
const int kMaxPreFetchSplitDepth = 3; // Maximum recursive splits when hitting Overpass node limit

View File

@@ -53,7 +53,7 @@
"aboutSubtitle": "App-Informationen und Credits",
"languageSubtitle": "Wählen Sie Ihre bevorzugte Sprache",
"maxNodes": "Max. angezeigte Knoten",
"maxNodesSubtitle": "Obergrenze für die Anzahl der Knoten auf der Karte festlegen (Standard: 250).",
"maxNodesSubtitle": "Obergrenze für die Anzahl der Knoten auf der Karte festlegen.",
"maxNodesWarning": "Sie möchten das wahrscheinlich nicht tun, es sei denn, Sie sind absolut sicher, dass Sie einen guten Grund dafür haben.",
"offlineMode": "Offline-Modus",
"offlineModeSubtitle": "Alle Netzwerkanfragen außer für lokale/Offline-Bereiche deaktivieren.",

View File

@@ -85,7 +85,7 @@
"aboutSubtitle": "App information and credits",
"languageSubtitle": "Choose your preferred language",
"maxNodes": "Max nodes drawn",
"maxNodesSubtitle": "Set an upper limit for the number of nodes on the map (default: 250).",
"maxNodesSubtitle": "Set an upper limit for the number of nodes on the map.",
"maxNodesWarning": "You probably don't want to do that unless you are absolutely sure you have a good reason for it.",
"offlineMode": "Offline Mode",
"offlineModeSubtitle": "Disable all network requests except for local/offline areas.",

View File

@@ -85,7 +85,7 @@
"aboutSubtitle": "Información de la aplicación y créditos",
"languageSubtitle": "Elige tu idioma preferido",
"maxNodes": "Máx. nodos dibujados",
"maxNodesSubtitle": "Establecer un límite superior para el número de nodos en el mapa (predeterminado: 250).",
"maxNodesSubtitle": "Establecer un límite superior para el número de nodos en el mapa.",
"maxNodesWarning": "Probablemente no quieras hacer eso a menos que estés absolutamente seguro de que tienes una buena razón para ello.",
"offlineMode": "Modo Sin Conexión",
"offlineModeSubtitle": "Deshabilitar todas las solicitudes de red excepto para áreas locales/sin conexión.",

View File

@@ -85,7 +85,7 @@
"aboutSubtitle": "Informations sur l'application et crédits",
"languageSubtitle": "Choisissez votre langue préférée",
"maxNodes": "Max. nœuds dessinés",
"maxNodesSubtitle": "Définir une limite supérieure pour le nombre de nœuds sur la carte (par défaut: 250).",
"maxNodesSubtitle": "Définir une limite supérieure pour le nombre de nœuds sur la carte.",
"maxNodesWarning": "Vous ne voulez probablement pas faire cela à moins d'être absolument sûr d'avoir une bonne raison de le faire.",
"offlineMode": "Mode Hors Ligne",
"offlineModeSubtitle": "Désactiver toutes les requêtes réseau sauf pour les zones locales/hors ligne.",

View File

@@ -85,7 +85,7 @@
"aboutSubtitle": "Informazioni sull'applicazione e crediti",
"languageSubtitle": "Scegli la tua lingua preferita",
"maxNodes": "Max nodi disegnati",
"maxNodesSubtitle": "Imposta un limite superiore per il numero di nodi sulla mappa (predefinito: 250).",
"maxNodesSubtitle": "Imposta un limite superiore per il numero di nodi sulla mappa.",
"maxNodesWarning": "Probabilmente non vuoi farlo a meno che non sei assolutamente sicuro di avere una buona ragione per farlo.",
"offlineMode": "Modalità Offline",
"offlineModeSubtitle": "Disabilita tutte le richieste di rete tranne per aree locali/offline.",

View File

@@ -85,7 +85,7 @@
"aboutSubtitle": "Informações do aplicativo e créditos",
"languageSubtitle": "Escolha seu idioma preferido",
"maxNodes": "Máx. de nós desenhados",
"maxNodesSubtitle": "Definir um limite superior para o número de nós no mapa (padrão: 250).",
"maxNodesSubtitle": "Definir um limite superior para o número de nós no mapa.",
"maxNodesWarning": "Você provavelmente não quer fazer isso a menos que tenha certeza absoluta de que tem uma boa razão para isso.",
"offlineMode": "Modo Offline",
"offlineModeSubtitle": "Desabilitar todas as requisições de rede exceto para áreas locais/offline.",

View File

@@ -85,7 +85,7 @@
"aboutSubtitle": "应用程序信息和鸣谢",
"languageSubtitle": "选择您的首选语言",
"maxNodes": "最大节点绘制数",
"maxNodesSubtitle": "设置地图上节点数量的上限默认250。",
"maxNodesSubtitle": "设置地图上节点数量的上限。",
"maxNodesWarning": "除非您确定有充分的理由,否则您可能不想这样做。",
"offlineMode": "离线模式",
"offlineModeSubtitle": "禁用除本地/离线区域外的所有网络请求。",

View File

@@ -38,8 +38,7 @@ class MapInteractionHandler {
debugPrint('[MapInteractionHandler] Could not center map on node: $e');
}
// Start edit session for the node
appState.startEditSession(node);
// Note: Edit session is NOT started here - only when user explicitly presses Edit button
}
/// Handle suspected location tap with selection and highlighting

View File

@@ -3,12 +3,14 @@ import 'package:flutter_map_animations/flutter_map_animations.dart';
import 'package:latlong2/latlong.dart';
import 'package:provider/provider.dart';
import '../../app_state.dart';
import '../../app_state.dart' show AppState, FollowMeMode;
import '../../widgets/map_view.dart';
import '../../dev_config.dart';
/// Coordinates all navigation and routing functionality including route planning,
/// map centering, zoom management, and route visualization.
class NavigationCoordinator {
FollowMeMode? _previousFollowMeMode; // Track follow-me mode before overview
/// Start a route with automatic follow-me detection and appropriate centering
void startRoute({
@@ -56,8 +58,7 @@ class NavigationCoordinator {
// Hide the overview
appState.hideRouteOverview();
// Zoom and center for resumed route
// For resume, we always center on user if GPS is available, otherwise start pin
// Get user location to determine centering and follow-me behavior
LatLng? userLocation;
try {
userLocation = mapViewKey?.currentState?.getUserLocation();
@@ -65,12 +66,53 @@ class NavigationCoordinator {
debugPrint('[NavigationCoordinator] Could not get user location for route resume: $e');
}
_zoomAndCenterForRoute(
mapController: mapController,
followMeEnabled: appState.followMeMode != FollowMeMode.off, // Use current follow-me state
userLocation: userLocation,
routeStart: appState.routeStart,
);
// Determine if user is near the route path
bool isNearRoute = false;
if (userLocation != null && appState.routePath != null) {
isNearRoute = _isUserNearRoute(userLocation, appState.routePath!);
}
// Choose center point and follow-me behavior
LatLng centerPoint;
bool shouldEnableFollowMe = false;
if (isNearRoute && userLocation != null) {
// User is near route - center on GPS and enable follow-me
centerPoint = userLocation;
shouldEnableFollowMe = true;
debugPrint('[NavigationCoordinator] User near route - centering on GPS with follow-me');
} else {
// User far from route or no GPS - center on route start
centerPoint = appState.routeStart ?? userLocation ?? LatLng(0, 0);
shouldEnableFollowMe = false;
debugPrint('[NavigationCoordinator] User far from route - centering on start without follow-me');
}
// Apply the centering and zoom
try {
mapController.animateTo(
dest: centerPoint,
zoom: kResumeNavigationZoomLevel,
duration: const Duration(milliseconds: 800),
curve: Curves.easeOut,
);
} catch (e) {
debugPrint('[NavigationCoordinator] Could not animate to resume location: $e');
}
// Set follow-me mode based on proximity
if (shouldEnableFollowMe) {
// Restore previous follow-me mode if user is near route
final modeToRestore = _previousFollowMeMode ?? FollowMeMode.follow;
appState.setFollowMeMode(modeToRestore);
debugPrint('[NavigationCoordinator] Restored follow-me mode: $modeToRestore');
} else {
// Keep follow-me off if user is far from route
debugPrint('[NavigationCoordinator] Keeping follow-me off - user far from route');
}
// Clear stored follow-me mode
_previousFollowMeMode = null;
}
/// Handle navigation button press with route overview logic
@@ -80,12 +122,15 @@ class NavigationCoordinator {
}) {
final appState = context.read<AppState>();
if (appState.isInRouteMode) {
// Show route overview (zoom out to show full route)
if (appState.showRouteButton) {
// Route button - show route overview and zoom to show route
// Store current follow-me mode and disable it to prevent unexpected map jumps during overview
_previousFollowMeMode = appState.followMeMode;
appState.setFollowMeMode(FollowMeMode.off);
appState.showRouteOverview();
zoomToShowFullRoute(appState: appState, mapController: mapController);
} else {
// Not in route - handle based on current state
// Search button - toggle search mode
if (appState.isInSearchMode) {
// Exit search mode
appState.clearSearchResults();
@@ -146,6 +191,20 @@ class NavigationCoordinator {
}
}
/// Check if user location is near the route path
bool _isUserNearRoute(LatLng userLocation, List<LatLng> routePath) {
if (routePath.isEmpty) return false;
// Check distance to each point in the route path
for (final routePoint in routePath) {
final distance = const Distance().as(LengthUnit.Meter, userLocation, routePoint);
if (distance <= kRouteProximityThresholdMeters) {
return true;
}
}
return false;
}
/// Internal method to zoom and center for route start/resume
void _zoomAndCenterForRoute({
required AnimatedMapController mapController,

View File

@@ -291,7 +291,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
mapController: _mapController,
onSelectedNodeChanged: (id) => setState(() => _selectedNodeId = id),
);
final controller = _scaffoldKey.currentState!.showBottomSheet(
(ctx) => Padding(
padding: EdgeInsets.only(
@@ -348,7 +348,7 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
location: location,
mapController: _mapController,
);
final controller = _scaffoldKey.currentState!.showBottomSheet(
(ctx) => Padding(
padding: EdgeInsets.only(
@@ -385,14 +385,20 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
_sheetCoordinator.setEditSheetShown(false);
}
// Auto-open navigation sheet when needed - simplified logic (only in dev mode)
// Auto-open navigation sheet when needed - only when online and in nav features mode
if (kEnableNavigationFeatures) {
final shouldShowNavSheet = appState.isInSearchMode || appState.showingOverview;
final shouldShowNavSheet = !appState.offlineMode && (appState.isInSearchMode || appState.showingOverview);
if (shouldShowNavSheet && !_sheetCoordinator.navigationSheetShown) {
_sheetCoordinator.setNavigationSheetShown(true);
WidgetsBinding.instance.addPostFrameCallback((_) => _openNavigationSheet());
} else if (!shouldShowNavSheet) {
} else if (!shouldShowNavSheet && _sheetCoordinator.navigationSheetShown) {
_sheetCoordinator.setNavigationSheetShown(false);
// When sheet should close (including going offline), clean up navigation state
if (appState.offlineMode) {
WidgetsBinding.instance.addPostFrameCallback((_) {
appState.cancelNavigation();
});
}
}
}
@@ -491,8 +497,8 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
}
},
),
// Search bar (slides in when in search mode) - only online since search doesn't work offline
if (!appState.offlineMode && appState.isInSearchMode)
// Search bar (slides in when in search mode)
if (appState.isInSearchMode)
Positioned(
top: 0,
left: 0,

View File

@@ -207,8 +207,15 @@ class NavigationState extends ChangeNotifier {
_routeEndAddress = _provisionalPinAddress;
}
// BRUTALIST FIX: Set calculating state BEFORE clearing isSettingSecondPoint
// to prevent UI from briefly showing route buttons again
_isSettingSecondPoint = false;
_isCalculating = true;
_routingError = null; // Clear any previous errors
// Notify listeners immediately to update UI before async calculation starts
notifyListeners();
_calculateRoute();
}

View File

@@ -24,6 +24,21 @@ class MapDataManager {
}
}
/// Expand bounds by the given multiplier, maintaining center point.
/// Used to expand rendering bounds to prevent nodes blinking at screen edges.
LatLngBounds _expandBounds(LatLngBounds bounds, double multiplier) {
final centerLat = (bounds.north + bounds.south) / 2;
final centerLng = (bounds.east + bounds.west) / 2;
final latSpan = (bounds.north - bounds.south) * multiplier / 2;
final lngSpan = (bounds.east - bounds.west) * multiplier / 2;
return LatLngBounds(
LatLng(centerLat - latSpan, centerLng - lngSpan),
LatLng(centerLat + latSpan, centerLng + lngSpan),
);
}
/// Get nodes to render based on current map state
/// Returns a MapDataResult containing all relevant node data and limit state
MapDataResult getNodesForRendering({
@@ -39,10 +54,13 @@ class MapDataManager {
bool isLimitActive = false;
if (currentZoom >= minZoom) {
// Above minimum zoom - get cached nodes directly (no Provider needed)
allNodes = (mapBounds != null)
? NodeProviderWithCache.instance.getCachedNodesForBounds(mapBounds)
: <OsmNode>[];
// Above minimum zoom - get cached nodes with expanded bounds to prevent edge blinking
if (mapBounds != null) {
final expandedBounds = _expandBounds(mapBounds, kNodeRenderingBoundsExpansion);
allNodes = NodeProviderWithCache.instance.getCachedNodesForBounds(expandedBounds);
} else {
allNodes = <OsmNode>[];
}
// Filter out invalid coordinates before applying limit
final validNodes = allNodes.where((node) {

View File

@@ -159,7 +159,7 @@ class MapOverlays extends StatelessWidget {
children: [
// Search/Navigation button - show search button always, show route button only in dev mode when online
if (onSearchPressed != null) ...[
if (appState.showSearchButton || (enableNavigationFeatures(offlineMode: appState.offlineMode) && appState.showRouteButton)) ...[
if ((!appState.offlineMode && appState.showSearchButton) || appState.showRouteButton) ...[
FloatingActionButton(
mini: true,
heroTag: "search_nav",

View File

@@ -62,16 +62,22 @@ class MarkerLayerBuilder {
return LayoutBuilder(
builder: (context, constraints) {
// Determine if we should dim node markers (when suspected location is selected)
final shouldDimNodes = appState.selectedSuspectedLocation != null;
// Determine if nodes should be dimmed and/or disabled
final shouldDimNodes = appState.selectedSuspectedLocation != null ||
appState.isInSearchMode ||
appState.showingOverview;
// Disable node interactions when navigation is in conflicting state
final shouldDisableNodeTaps = appState.isInSearchMode || appState.showingOverview;
final markers = NodeMarkersBuilder.buildNodeMarkers(
nodes: nodesToRender,
mapController: mapController.mapController,
userLocation: userLocation,
selectedNodeId: selectedNodeId,
onNodeTap: onNodeTap,
onNodeTap: onNodeTap, // Keep the original callback
shouldDim: shouldDimNodes,
enabled: !shouldDisableNodeTaps, // Use enabled parameter instead
);
// Build suspected location markers (respect same zoom and count limits as nodes)
@@ -101,7 +107,9 @@ class MarkerLayerBuilder {
locations: filteredSuspectedLocations,
mapController: mapController.mapController,
selectedLocationId: appState.selectedSuspectedLocation?.ticketNo,
onLocationTap: onSuspectedLocationTap,
onLocationTap: onSuspectedLocationTap, // Keep the original callback
shouldDimAll: shouldDisableNodeTaps,
enabled: !shouldDisableNodeTaps, // Use enabled parameter instead
),
);
}

View File

@@ -13,11 +13,13 @@ class NodeMapMarker extends StatefulWidget {
final OsmNode node;
final MapController mapController;
final void Function(OsmNode)? onNodeTap;
final bool enabled;
const NodeMapMarker({
required this.node,
required this.mapController,
this.onNodeTap,
this.enabled = true,
Key? key,
}) : super(key: key);
@@ -31,6 +33,8 @@ class _NodeMapMarkerState extends State<NodeMapMarker> {
static const Duration tapTimeout = kMarkerTapTimeout;
void _onTap() {
if (!widget.enabled) return; // Don't respond to taps when disabled
_tapTimer = Timer(tapTimeout, () {
// Don't center immediately - let the sheet opening handle the coordinated animation
@@ -48,6 +52,8 @@ class _NodeMapMarkerState extends State<NodeMapMarker> {
}
void _onDoubleTap() {
if (!widget.enabled) return; // Don't respond to double taps when disabled
_tapTimer?.cancel();
widget.mapController.move(widget.node.coord, widget.mapController.camera.zoom + kNodeDoubleTapZoomDelta);
}
@@ -96,6 +102,7 @@ class NodeMarkersBuilder {
int? selectedNodeId,
void Function(OsmNode)? onNodeTap,
bool shouldDim = false,
bool enabled = true,
}) {
final markers = <Marker>[
// Node markers
@@ -116,6 +123,7 @@ class NodeMarkersBuilder {
node: n,
mapController: mapController,
onNodeTap: onNodeTap,
enabled: enabled,
),
),
);

View File

@@ -13,11 +13,13 @@ class SuspectedLocationMapMarker extends StatefulWidget {
final SuspectedLocation location;
final MapController mapController;
final void Function(SuspectedLocation)? onLocationTap;
final bool enabled;
const SuspectedLocationMapMarker({
required this.location,
required this.mapController,
this.onLocationTap,
this.enabled = true,
Key? key,
}) : super(key: key);
@@ -31,6 +33,8 @@ class _SuspectedLocationMapMarkerState extends State<SuspectedLocationMapMarker>
static const Duration tapTimeout = kMarkerTapTimeout;
void _onTap() {
if (!widget.enabled) return; // Don't respond to taps when disabled
_tapTimer = Timer(tapTimeout, () {
// Use callback if provided, otherwise fallback to direct modal
if (widget.onLocationTap != null) {
@@ -46,6 +50,8 @@ class _SuspectedLocationMapMarkerState extends State<SuspectedLocationMapMarker>
}
void _onDoubleTap() {
if (!widget.enabled) return; // Don't respond to double taps when disabled
_tapTimer?.cancel();
widget.mapController.move(widget.location.centroid, widget.mapController.camera.zoom + kNodeDoubleTapZoomDelta);
}
@@ -73,6 +79,8 @@ class SuspectedLocationMarkersBuilder {
required MapController mapController,
String? selectedLocationId,
void Function(SuspectedLocation)? onLocationTap,
bool shouldDimAll = false,
bool enabled = true,
}) {
final markers = <Marker>[];
@@ -81,7 +89,7 @@ class SuspectedLocationMarkersBuilder {
// Check if this location should be highlighted (selected) or dimmed
final isSelected = selectedLocationId == location.ticketNo;
final shouldDim = selectedLocationId != null && !isSelected;
final shouldDim = shouldDimAll || (selectedLocationId != null && !isSelected);
markers.add(
Marker(
@@ -94,6 +102,7 @@ class SuspectedLocationMarkersBuilder {
location: location,
mapController: mapController,
onLocationTap: onLocationTap,
enabled: enabled,
),
),
),

View File

@@ -93,40 +93,44 @@ class NavigationSheet extends StatelessWidget {
children: [
_buildDragHandle(),
// SEARCH MODE: Initial location with route options
if (navigationMode == AppNavigationMode.search && !appState.isSettingSecondPoint && !appState.isCalculating && !appState.showingOverview && provisionalLocation != null) ...[
// SEARCH MODE: Initial location with route options (only when no route points are set yet)
if (navigationMode == AppNavigationMode.search &&
!appState.isSettingSecondPoint &&
!appState.isCalculating &&
!appState.showingOverview &&
provisionalLocation != null &&
appState.routeStart == null &&
appState.routeEnd == null) ...[
_buildLocationInfo(
label: LocalizationService.instance.t('navigation.location'),
coordinates: provisionalLocation,
address: provisionalAddress,
),
const SizedBox(height: 16),
// Only show routing buttons if navigation features are enabled
if (enableNavigationFeatures(offlineMode: appState.offlineMode)) ...[
Row(
children: [
Expanded(
child: ElevatedButton.icon(
icon: const Icon(Icons.directions),
label: Text(LocalizationService.instance.t('navigation.routeTo')),
onPressed: () {
appState.startRoutePlanning(thisLocationIsStart: false);
},
),
),
const SizedBox(width: 12),
Expanded(
child: ElevatedButton.icon(
icon: const Icon(Icons.my_location),
label: Text(LocalizationService.instance.t('navigation.routeFrom')),
onPressed: () {
appState.startRoutePlanning(thisLocationIsStart: true);
},
),
),
],
),
],
// Show routing buttons (sheet only opens when online, so always available)
Row(
children: [
Expanded(
child: ElevatedButton.icon(
icon: const Icon(Icons.directions),
label: Text(LocalizationService.instance.t('navigation.routeTo')),
onPressed: () {
appState.startRoutePlanning(thisLocationIsStart: false);
},
),
),
const SizedBox(width: 12),
Expanded(
child: ElevatedButton.icon(
icon: const Icon(Icons.my_location),
label: Text(LocalizationService.instance.t('navigation.routeFrom')),
onPressed: () {
appState.startRoutePlanning(thisLocationIsStart: true);
},
),
),
],
),
],
// SETTING SECOND POINT: Show both points and select button
@@ -187,13 +191,27 @@ class NavigationSheet extends StatelessWidget {
const SizedBox(height: 16),
],
ElevatedButton.icon(
icon: const Icon(Icons.check),
label: Text(LocalizationService.instance.t('navigation.selectLocation')),
onPressed: appState.areRoutePointsTooClose ? null : () {
debugPrint('[NavigationSheet] Select Location button pressed');
appState.selectSecondRoutePoint();
},
Row(
children: [
Expanded(
child: ElevatedButton.icon(
icon: const Icon(Icons.check),
label: Text(LocalizationService.instance.t('navigation.selectLocation')),
onPressed: appState.areRoutePointsTooClose ? null : () {
debugPrint('[NavigationSheet] Select Location button pressed');
appState.selectSecondRoutePoint();
},
),
),
const SizedBox(width: 12),
Expanded(
child: ElevatedButton.icon(
icon: const Icon(Icons.close),
label: Text(LocalizationService.instance.t('actions.cancel')),
onPressed: () => appState.cancelNavigation(),
),
),
],
),
],

View File

@@ -1,7 +1,7 @@
name: deflockapp
description: Map public surveillance infrastructure with OpenStreetMap
publish_to: "none"
version: 1.6.1+27 # The thing after the + is the version code, incremented with each release
version: 1.6.3+29 # The thing after the + is the version code, incremented with each release
environment:
sdk: ">=3.5.0 <4.0.0" # oauth2_client 4.x needs Dart 3.5+